/// <summary> /// 获取提现结果 /// </summary> /// <param name="item"></param> /// <param name="code"></param> /// <param name="msg"></param> public void GetDrawCashResult(DrawCashApply item, ref int code, ref string msg, out C_UserInfo userinfo) { item.drawState = (int)DrawCashState.提现失败; userinfo = C_UserInfoBLL.SingleModel.GetModel(item.userId); if (userinfo != null) { PayCenterSetting setting = PayCenterSettingBLL.SingleModel.GetPayCenterSetting(userinfo.appId); if (setting == null) { msg = "提现失败更新提现申请记录失败PayCenterSetting为NULL"; } else { WxPayData data = new WxPayData(); data.SetValue("openid", userinfo.OpenId); //openid data.SetValue("amount", item.cashMoney); //取款金额 data.SetValue("re_user_name", ReplaceSpecialChar(userinfo.NickName, '?')); //收款用户姓名 data.SetValue("desc", string.Format("{0},小程序{1}提现{2}元", ReplaceSpecialChar(userinfo.NickName, '?'), Enum.GetName(typeof(DrawCashApplyType), item.applyType), item.cashMoneyStr)); data.SetValue("partner_trade_no", item.partner_trade_no); //订单号 data.SetValue("spbill_create_ip", ConfigurationManager.AppSettings["IP"]); //订单号 WxPayData result = WxPayApi.CompanyPay(data, setting); if (result != null) { try { string resultStr = result.ToJson(); //企业付款(客户提现),接收返回数据 //---------------------- //判断执行提现结果 //---------------------- int i = DrawResult(result, item.cashMoney, setting); if (i == 1) { msg = "提现成功"; code = 1; item.drawState = (int)DrawCashState.提现成功; } else if (i == -2) { code = -1; //表示微信那边返回错误码为“SYSTEMERROR”时,一定要使用原单号重试,否则可能造成重复支付等资金风险。 //该提现记录不能算失败也不能算成功,维持原状等待下次提现队列 msg = "返回错误码为“SYSTEMERROR”等待下次提现队列提现返回结果" + resultStr; } else { code = 0; msg = result.GetValue("err_code_des").ToString(); } } catch (Exception ex) { msg = "提现失败发生异常" + ex.Message; } } else { msg = "提现失败(证书路径不存在)"; } } } else { msg = "提现用户不存在"; } item.DrawTime = DateTime.Now; DrawCashApplyBLL.SingleModel.Update(item, "drawState,DrawTime"); writeLog(msg); }