protected override XResp Execute() { var user = DB.x_user.SingleOrDefault(o => o.user_id == user_id); if (user == null) { throw new XExcep("T用户不存在"); } if (amount <= 0) { throw new XExcep("T充值金额非法"); } x_charge depositItem = new x_charge(); depositItem.x_user = user; depositItem.amount = amount; depositItem.result = "MANUAL"; depositItem.user_id = user.user_id; depositItem.audit_status = 2; depositItem.audit_time = DateTime.Now; depositItem.audit_user = mg.mgr_id; depositItem.ctime = DateTime.Now; depositItem.fail_reason = reason; user.balance += amount; SubmitDBChanges(); return(new XResp()); }
protected override XResp Execute() { var user = DB.x_user.SingleOrDefault(o => o.uid == uid || o.tel == uid); if (user == null) { throw new XExcep("0x0018"); } if (amount <= 0) { throw new XExcep("0x0019"); } var depositItem = new x_charge(); depositItem.x_user = user; depositItem.amount = amount; depositItem.result = "后台充值成功"; depositItem.user_id = user.user_id; depositItem.audit_status = 2; depositItem.audit_time = DateTime.Now; depositItem.audit_user = mg.mgr_id; depositItem.ctime = DateTime.Now; user.balance += amount; SubmitDBChanges(); return(new XResp()); }
protected override XResp Execute() { if (amount > cfg.max_deposit || amount < cfg.min_deposit) { throw new XExcep("0x0056"); } var depositLog = new x_charge(); depositLog.amount = amount; depositLog.ctime = DateTime.Now; depositLog.audit_status = 1;//1为待审核 cu.x_charge.Add(depositLog); SubmitDBChanges(); var c = CacheHelper.Get <string>("pay." + cu.id); if (!string.IsNullOrEmpty(c)) { throw new XExcep("0x0048"); } CacheHelper.Save("pay." + cu.id, "1"); var co = Wx.Pay.MdOrder(cu.nickname + "_" + cu.id + "充值" + amount, "chg_" + depositLog.charge_id + "", (int)(amount * 100) + "", "http://" + cfg.domain + "/wx/notify-2-" + depositLog.charge_id + ".html", cu.wx_opid, cfg.wx_appid, cfg.wx_mch_id, cfg.wx_paykey, false); CacheHelper.Remove("pay." + cu.id); SubmitDBChanges(); if (co.return_code == "FAIL") { throw new XExcep(co.return_msg); } if (co.result_code == "FAIL") { throw new XExcep(co.err_code + "," + co.err_code_des + "," + depositLog.charge_id); } if (string.IsNullOrEmpty(co.prepay_id)) { throw new XExcep("0x0051"); } var ps = new Dictionary <string, string>(); ps.Add("appId", cfg.wx_appid); ps.Add("timeStamp", Tools.GetGreenTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); ps.Add("nonceStr", Tools.GetRandRom(24, 3)); ps.Add("package", "prepay_id=" + co.prepay_id); ps.Add("signType", "MD5"); var r = new od() { id = depositLog.charge_id, amount = depositLog.amount.Value, ns = ps["nonceStr"], ts = ps["timeStamp"], pkg = ps["package"], sign = Wx.ToSign(ps, false, cfg.wx_paykey), fromDeposit = 2 }; return(r); }