protected void Print_Btn_Click(object sender, EventArgs e) { int devID = DataConvert.CLng(Request.Form["Dev_R"]); if (devID < 1) { function.WriteErrMsg("你还没有选择打印设备!"); } int Num = DataConvert.CLng(Num_T.Text.Replace(" ", "")); if (Num < 1) { function.WriteErrMsg("请输入正确的打印数量!"); } int orderID = DataConvert.CLng(Order_DP.SelectedValue); int tlpID = DataConvert.CLng(Tlp_DP.SelectedValue); //------------------------------ DataTable orderDT = DBCenter.Sel("ZL_OrderInfo", "ID=" + orderID); M_Shop_PrintTlp tlpMod = tlpBll.SelReturnModel(tlpID); M_Shop_PrintDevice devMod = devBll.SelReturnModel(devID); string msg = orderCOM.TlpDeal(tlpMod.Content, orderDT); msgBll.Insert(msg, tlpMod.ID, devMod, Num); function.WriteSuccessMsg("信息已发送", "MessageList.aspx"); }
protected void Save_Btn_Click(object sender, EventArgs e) { M_Shop_PrintDevice devMod = new M_Shop_PrintDevice(); if (Mid > 0) { devMod = devBll.SelReturnModel(Mid); } devMod.Alias = Alias_T.Text.Trim(); devMod.DeviceNo = DeviceNo_T.Text.Replace(" ", ""); devMod.MemberCode = MemberCode_T.Text.Replace(" ", ""); devMod.SecurityKey = SecurityKey_T.Text.Replace(" ", ""); devMod.Remind = Remind_T.Text.Trim(); devMod.IsDefault = IsDefault_C.Checked ? 1 : 0; devMod.ShopName = ShopName_T.Text.Trim(); if (Mid > 0)//修改 { devBll.UpdateByID(devMod); if (IsDefault_C.Checked) { devBll.SetDefault(Mid); } } else { int newMid = devBll.Insert(devMod); if (IsDefault_C.Checked) { devBll.SetDefault(newMid); } } function.WriteSuccessMsg("操作成功!", "ListDevice.aspx"); }
private void MyBind() { M_Shop_PrintMessage msgMod = msgBll.SelReturnModel(Mid); M_Shop_PrintDevice devMod = devBll.SelReturnModel(msgMod.DevID); ReqTime_L.Text = msgMod.ReqTime.ToString(); Alias_L.Text = devMod.Alias; ShopName_L.Text = devMod.ShopName; ReqStatus_L.Text = msgBll.DealReqStatus(msgMod.ReqStatus); Detail_T.Text = msgMod.Detail; }
/// <summary> /// 添加打印记录,同时发送打印指令 /// </summary> /// <param name="content">消息内容</param> /// <param name="tlpID">模板ID</param> /// <param name="devMod">打印设备Mod</param> /// <param name="num">打印数量,默认为1</param> public int Insert(string content, int tlpID, M_Shop_PrintDevice devMod, int num = 1) { M_Shop_PrintMessage msgMod = new M_Shop_PrintMessage(); msgMod.ReqTime = DateTime.Now; msgMod.Detail = content; msgMod.DevID = devMod.ID; msgMod.Mode = 2; msgMod.TlpID = tlpID; for (int i = 0; i < num; i++) { msgMod.ReqStatus = printBll.SendFreeMessage(msgMod, devMod.DeviceNo); } msgMod.TaskStatus = "0"; return(Insert(msgMod)); }
private void MyBind() { if (Mid > 0) { M_Shop_PrintDevice devMod = devBll.SelReturnModel(Mid); Alias_T.Text = devMod.Alias; DeviceNo_T.Text = devMod.DeviceNo; MemberCode_T.Text = devMod.MemberCode; SecurityKey_T.Text = devMod.SecurityKey; Remind_T.Text = devMod.Remind; IsDefault_C.Checked = devMod.IsDefault == 1; ShopName_T.Text = devMod.ShopName; Since_L.Text = devMod.Since.ToShortDateString(); addon_tb.Visible = true; } }
protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e) { int id = DataConverter.CLng(e.CommandArgument); switch (e.CommandName) { case "reprint": M_Shop_PrintMessage msgMod = msgBll.SelReturnModel(id); M_Shop_PrintDevice devMod = devBll.SelReturnModel(msgMod.DevID); msgMod.ReqStatus = printBll.SendFreeMessage(msgMod, devMod.DeviceNo); msgBll.Insert(msgMod); function.WriteSuccessMsg("已重新发送"); break; } MyBind(); }
protected void Print_Btn_Click(object sender, EventArgs e) { int devID = DataConvert.CLng(Request.Form["Dev_R"]); if (devID < 1) { function.WriteErrMsg("你还没有选择打印设备!"); } int Num = DataConvert.CLng(Num_T.Text.Replace(" ", "")); if (Num < 1) { function.WriteErrMsg("请输入正确的打印数量!"); } M_Shop_PrintDevice devMod = devBll.SelReturnModel(devID); string msg = Msg_T.Text; msgBll.Insert(msg, -1, devMod, Num); function.WriteSuccessMsg("信息已发送", "MessageList.aspx"); }
/// <summary> /// 获取用户所有打印设备的编码 /// </summary> /// <returns></returns> //public string GetAllDeviceNo() //{ // string ids = string.Empty; // List<M_Shop_PrintDevice> Devices = ListDevice(); // foreach (M_Shop_PrintDevice device in Devices) // { // ids += device.DeviceNo + ","; // } // if (!string.IsNullOrEmpty(ids)) { ids.TrimEnd(','); } // return ids; //} /// <summary> /// 打印自定义格式消息 /// </summary> /// <param name="Message">要打印的消息对象</param> /// <returns></returns> public string SendFreeMessage(M_Shop_PrintMessage msgMod, string DeviceNo) { B_Shop_PrintDevice printBll = new B_Shop_PrintDevice(); M_Shop_PrintDevice printMod = printBll.SelModeByDevice(DeviceNo); if (string.IsNullOrEmpty(DeviceNo)) { throw new Exception("设备编号不能为空"); } if (string.IsNullOrEmpty(msgMod.Detail)) { throw new Exception("内容不能为空"); } long reqTime = GetCurrentMilli(); string qstr = "memberCode=" + HttpUtility.UrlEncode(printMod.MemberCode, Encoding.UTF8); qstr += "&deviceNo=" + HttpUtility.UrlEncode(DeviceNo, Encoding.UTF8); qstr += "&msgNo=" + HttpUtility.UrlEncode(msgMod.MsgNo, Encoding.UTF8); qstr += "&msgDetail=" + HttpUtility.UrlEncode(msgMod.Detail, Encoding.UTF8); qstr += "&mode=" + HttpUtility.UrlEncode(msgMod.Mode.ToString(), Encoding.UTF8);; qstr += "&reqTime=" + reqTime; qstr += "&securityCode=" + StringHelper.MD5(printMod.MemberCode + msgMod.Detail + DeviceNo + msgMod.MsgNo + reqTime + printMod.SecurityKey); return(SendMessage(qstr)); }
///// <summary> ///// 查询打印状态 ///// </summary> ///// <param name="msgNo"></param> //public string QueryState(string msgNo) //{ // long reqTime = GetCurrentMilli(); // return APIHelper.GetWebResult("http://my.feyin.net/api/queryState?memberCode=" + MemberCode + "&reqTime=" + reqTime + "&msgNo=" + msgNo + "&securityCode" + StringHelper.MD5(MemberCode + reqTime + SecurityKey + msgNo)); //} ///// <summary> ///// 查询设备列表 ///// </summary> //public List<M_Shop_PrintDevice> ListDevice() //{ // List<M_Shop_PrintDevice> Devices = new List<M_Shop_PrintDevice>(); // long reqTime = GetCurrentMilli(); // string result = APIHelper.GetWebResult("http://my.feyin.net/api/listDevice?memberCode=" + MemberCode + "&reqTime=" + reqTime + "&securityCode=" + StringHelper.MD5(MemberCode + reqTime + SecurityKey)); // XmlDocument xmlDoc = new XmlDocument(); // xmlDoc.LoadXml(result); // XmlNodeList xnl = xmlDoc.GetElementsByTagName("device"); // for (int i = 0; i < xnl.Count; i++) // { // M_Shop_PrintDevice deviceMod = new M_Shop_PrintDevice(); // deviceMod.DeviceNo = xnl[i].Attributes["id"].Value; // XmlNode xnAdr = xnl[i].SelectSingleNode("address"); // if (xnAdr != null) { } // XmlNode xnSe = xnl[i].SelectSingleNode("since"); // if (xnSe != null) { deviceMod.Since = DataConverter.CDate(xnSe.InnerText); } // //XmlNode xnSc = xnl[i].SelectSingleNode("simCode"); // //if (xnSc != null) { deviceMod.SimCode = xnSc.InnerText; } // XmlNode xnLc = xnl[i].SelectSingleNode("lastConnected"); // if (xnLc != null) { deviceMod.LastConnected = DataConverter.CDate(xnLc.InnerText); } // XmlNode xnDs = xnl[i].SelectSingleNode("deviceStatus"); // if (xnDs != null) { deviceMod.DeviceStatus = xnDs.InnerText; } // XmlNode xnPs = xnl[i].SelectSingleNode("paperStatus"); // if (xnPs != null) { deviceMod.PaperStatus = xnPs.InnerText; } // Devices.Add(deviceMod); // } // return Devices; //} /// <summary> /// 查询异常列表 /// </summary> public string ListException(M_Shop_PrintDevice printMod) { long reqTime = GetCurrentMilli(); return(APIHelper.GetWebResult("http://my.feyin.net/api/listException?memberCode=" + printMod.MemberCode + "&reqTime=" + reqTime + "&securityCode" + StringHelper.MD5(printMod.MemberCode + reqTime + printMod.SecurityKey))); }
//支付成功时执行的操作 private void PayOrder_Success(WxPayData result) { ZLLog.L(ZLEnum.Log.pay, "微信:微信支付 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee")); try { M_Order_PayLog paylogMod = new M_Order_PayLog(); M_Payment pinfo = payBll.SelModelByPayNo(result.GetValue("out_trade_no").ToString()); if (pinfo == null) { throw new Exception("支付单不存在"); } //支付单检测合为一个方法 if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { throw new Exception("支付单状态不为未支付"); } pinfo.Status = (int)M_Payment.PayStatus.HasPayed; pinfo.PlatformInfo = "微信扫码|公众号支付"; pinfo.SuccessTime = DateTime.Now; pinfo.PayTime = DateTime.Now; pinfo.CStatus = true; //1=100, double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100; pinfo.MoneyTrue = tradeAmt; payBll.Update(pinfo); DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum); foreach (DataRow dr in orderDT.Rows) { M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString()); OrderHelper.FinalStep(pinfo, orderMod, paylogMod); if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse) { M_UserInfo mu = buser.SelReturnModel(orderMod.Userid); new B_Shop_MoneyRegular().AddMoneyByMin(mu, orderMod.Ordersamount, ",订单号[" + orderMod.OrderNo + "]"); } orderCom.SendMessage(orderMod, paylogMod, "payed"); //orderCom.SaveSnapShot(orderMod); if (orderMod.Ordertype != 6) { buser.ChangeVirtualMoney(orderMod.Userid, new M_UserExpHis() { score = orderMod.Ordersamount, ScoreType = 3, detail = "在线消费赠送积分:" + orderMod.Ordersamount }); } //订单返利 OrderRebates(orderMod.Userid, orderMod.Ordersamount); //订单打印 int orderID = DataConvert.CLng(dr["ID"].ToString()); int StoreID = DataConvert.CLng(dr["StoreID"].ToString()); int devID = GetPrintDevice(StoreID); //设备ID int tlpID = GetPrintModelID(StoreID); //模板ID int printnum = GetPrintNum(StoreID); //------------------------------ DataTable orderDT1 = DBCenter.Sel("ZL_OrderInfo", "ID=" + orderID); M_Shop_PrintTlp tlpMod = tlpBll.SelReturnModel(tlpID); M_Shop_PrintDevice devMod = devBll.SelReturnModel(devID); string msg = orderCOM.TlpDeal(tlpMod.Content, orderDT1); ZLLog.L(ZLEnum.Log.pay, msg); msgBll.Insert(msg, tlpMod.ID, devMod, printnum); //function.WriteSuccessMsg("信息已发送", "MessageList.aspx"); //发送微信通知 try { userappMod = userappBll.SelModelByUid(DataConvert.CLng(dr["UserID"]), "wechat"); if (userappMod != null) { WxAPI wxapi = WxAPI.Code_Get(1); if (dr["Ordertype"].ToString() == "6") { M_UserInfo userMod = buser.GetUserByUserID(DataConvert.CLng(dr["UserID"])); wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "vRUiDj-k6EGjwQC2GO4oU1G37CJjiu2fZ-ePBj1jJ60", "http://v.wodian8.com/User/Order/OrderList1.aspx", "{\"first\": {\"value\":\"您好,您已经充值成功。\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + DataConvert.CDouble(dr["Ordersamount"]).ToString("0.00") + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + userMod.Purse.ToString("0.00") + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"感谢您对我们的信任,我们将为您提供更优质的服务。\",\"color\":\"#173177\"}}"); } else { wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "E-yWv8GVKeJHymtTB0zOGKnEv6LXodjr-M6tj1sLzfM", "http://v.wodian8.com/User/Order/OrderList1.aspx", "{\"first\": {\"value\":\"您的订单支付成功!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + dr["OrderNo"].ToString() + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + GetProname(DataConvert.CLng(dr["ID"])) + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + DataConvert.CDouble(dr["Ordersamount"]).ToString("0.00") + "\",\"color\":\"#173177\"},\"keyword4\": {\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"点击查看订单详情!\",\"color\":\"#173177\"}}"); } } } catch (Exception ex) { ZLLog.L(ZLEnum.Log.pay, new M_Log() { Action = "发送微信通知报错", Message = "原因:" + ex.Message }); throw; } } ZLLog.L(ZLEnum.Log.pay, "微信支付成功!支付单:" + result.GetValue("out_trade_no").ToString()); } catch (Exception ex) { ZLLog.L(ZLEnum.Log.pay, new M_Log() { Action = "支付回调报错", Message = "平台:微信,支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message }); } }