public void InsertMgooOrder() { MgooOrders.Orders order = new MgooOrders.Orders(); order.AddOrder(this.user_id, this.device_id, this.openid, this.order_no, this.product_body, "", this.total_fee, this.time_start, this.time_expire, this.tariff_id); }
public override void ProcessNotify() { WxPayData notifyData = GetNotifyData(); //检查支付结果中transaction_id是否存在 if (!notifyData.IsSet("transaction_id")) { //若transaction_id不存在,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "支付结果中微信订单号不存在"); Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml()); page.Response.Write(res.ToXml()); page.Response.End(); } this.transaction_id = notifyData.GetValue("transaction_id").ToString(); //查询订单,判断订单真实性 if (!QueryOrder(this.transaction_id)) { //若订单查询失败,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml()); page.Response.Write(res.ToXml()); page.Response.End(); } //查询订单成功 else { WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml()); //result_code等于SUCCESS,代表支付成功 Log.Info(this.GetType().ToString(), "-----result_code:" + notifyData.GetValue("result_code") + ",微信订单号" + this.transaction_id); if (notifyData.GetValue("result_code").ToString() == "SUCCESS") { this.trade_no = notifyData.GetValue("out_trade_no").toStringEmpty(); this.time_end = notifyData.GetValue("time_end").toStringEmpty(); this.trade_type = notifyData.GetValue("trade_type").ToString(); this.fee_type = notifyData.GetValue("fee_type").toStringEmpty(); this.bank_type = notifyData.GetValue("bank_type").toStringEmpty(); this.device_name = notifyData.GetValue("attach").ToString(); string openid = notifyData.GetValue("openid").ToString(); string total_fee = notifyData.GetValue("total_fee").ToString(); MgooOrders.Orders o = new MgooOrders.Orders(); bool success = o.ModifyOrderStatus(transaction_id, fee_type, time_end, bank_type, trade_type, trade_no, !device_name.StartsWith("success_notify")); if (success) { string emailTitle = null; Task task = null; if (device_name.StartsWith("success_notify")) { task = Task.Run(() => { try { MG_DAL.YiwenGPSEntities db = new MG_DAL.YiwenGPSEntities(); var dev = db.Devices.Find(Convert.ToInt32(device_name.Split(',')[1])); dev.HireExpireDate = Convert.ToDateTime(DateTime.Now.AddYears(2).AddMonths(-1).ToString("yyyy-MM-25 00:00:00")); dev.ActiveDate = DateTime.Now; db.SaveChangesAsync(); var urserid = device_name.Split(',')[2]; var status = device_name.Split(',')[3]; emailTitle = "设备激活充值成功"; device_name = string.IsNullOrEmpty(dev.DeviceName) ? dev.SerialNumber : dev.DeviceName; ///用户在代理商线下用微信支付 扫码支付 激活设备 Weixin.Devices wd = new Weixin.Devices(new Common.AuthHeader() { UserID = urserid }); wd.AddDevice(dev.SerialNumber, dev.DevicePassword, urserid, "-1", isAdd: true, ifMoneyModel: false); } catch (Exception ex) { Common.Log.Error(this, ex); } }); } if (task != null) { task.Wait(); } Task.Run(() => o.SendMail(trade_no, emailTitle)); Task.Run(() => o.PaySuccessPush(openid, device_name, total_fee, time_end, o.GetBankName(bank_type), trade_no)); } } page.Response.Write(res.ToXml()); page.Response.End(); } }