示例#1
0
        public ActionResult Pay(int UserId, decimal Amount = 0)
        {
            if (UserId == 0 || Amount < 500M)
            {
                return(new RedirectResult($"/Prompt?state=-100&msg=参数错误&url=/debug/"));
            }

            var user = userDao.Single(UserId);


            Logic.VipType vip   = (Logic.VipType)user.VipType;
            decimal[]     r     = Constant.GetRate(0, vip);
            ToolPay       tp    = new ToolPay(Amount, r[0], r[1], 0.0038M, 1M);
            PayRecord     model = new PayRecord();

            model.UserId         = UserId;
            model.Amount         = Amount;
            model.Platform       = 1;
            model.Ip             = "1.1.1.1";
            model.BankCard       = "622202XXXXXXXXXXXXXX";
            model.Fee            = tp.PayFee;
            model.Rate           = tp.Rate1;
            model.Fee3           = tp.Rate3;
            model.State          = 10;
            model.DrawState      = 10;
            model.WithDrawAmount = model.Amount - model.Fee;//结算金额
            model.ActualAmount   = tp.ActualAmount;
            model.DrawBankCard   = "622222XXXXXX";
            model.BankCode       = "ICBC";
            model.PayerName      = user.RealName;
            model.PayerPhone     = user.Mobile;
            model.ChannelType    = 4;
            model.Income         = tp.Income;
            model.DrawIncome     = tp.Rate3 - 1;//结算收益

            var result = payRecordDao.Insert(model);

            int    backState = result > 0 ? 0 : -100;
            string message   = result > 0 ? "操作成功" : "操作失败";

            //交易成功回调
            UsersDepository.NoticeSuccess(result, UserId);

            return(new RedirectResult($"/Prompt?state={backState}&msg={message}&url=/debug/"));
        }
示例#2
0
        private bool WithDrawHandle()
        {
            bool flag = false;

            if (listViewPayRecord != null && listViewPayRecord.Count > 0)
            {
                while (listViewPayRecord.Count > 0)
                {
                    var item = listViewPayRecord[0];

                    Logic.ChannelType Channel = (Logic.ChannelType)item.ChannelType;
                    ResultModel       result  = new ResultModel();
                    result.backState = -100;
                    string msg = "";
                    switch (Channel)
                    {
                    case Logic.ChannelType.易宝:
                        msg = "支付失败";
                        var yeepayResult = YeepayDepository.TradeReviceQuery(item.RequestId.ToString(), (int)Logic.Platform.系统);
                        if (yeepayResult.backState == 0 && yeepayResult.tradeReceives.Count > 0 && yeepayResult.tradeReceives[0].status == "SUCCESS")
                        {
                            result.backState = 0;
                            msg = "支付成功";
                        }
                        break;

                    case Logic.ChannelType.荣邦科技积分:
                    case Logic.ChannelType.荣邦3:
                        msg = "支付失败";
                        var masgettResult = MasgetDepository.PaymentjournalGet(item.RequestId, (int)Logic.Platform.系统, Channel);
                        if (masgettResult.backState == 0 && masgettResult.data.respcode == 2)
                        {
                            result.backState = 0;
                            msg = "支付成功";
                        }
                        break;

                    case Logic.ChannelType.荣邦科技无积分:
                        break;

                    case Logic.ChannelType.腾付通:
                        var TengResult = TengDepository.PayDebitQuery(item.RequestId, (int)Logic.Platform.系统);
                        if (TengResult.backState == 0 && TengResult.status == "3")
                        {
                            result.backState = 0;
                            msg = "支付成功";
                        }
                        else
                        {
                            msg = TengResult.respMsg;
                        }
                        break;

                    case Logic.ChannelType.米刷:
                        var mishuaResult = MiShuaDepository.CheckDzero(item.RequestId, Logic.Platform.系统);
                        if (mishuaResult.backState == 0 && mishuaResult.Data.status == "00" && mishuaResult.Data.qfStatus == "SUCCESS")
                        {
                            result.backState = 0;
                            msg = "支付成功";
                        }
                        break;

                    default:
                        break;
                    }
                    bool f = false;
                    //Logs.WriteLog($"处理数据:{JsonConvert.SerializeObject(result)}", "d:\\Log\\自动处理", "资金队列");
                    //处理数据
                    f = payRecordDao.UpdateState(item.ID, result.backState == 0 ? 10 : -1, msg);
                    if (f)
                    {
                        //交易成功回调
                        UsersDepository.NoticeSuccess(item.ID, item.UserId);

                        int num = Convert.ToInt32(_tbxWithDrawSuccess.Text);
                        num++;
                        _tbxWithDrawSuccess.Text = num.ToString();
                    }
                    else
                    {
                        int num = Convert.ToInt32(_tbxWithDrawFail.Text);
                        num++;
                        _tbxWithDrawFail.Text = num.ToString();
                    }


                    listViewPayRecord.Remove(item);
                    Thread.Sleep(ConfigInfo.theadTime);
                }
            }
            else
            {
                //两小时前的数据被处理
                listViewPayRecord = viewPayRecordDao.GetQuery(10, " State not in(10,-1) and DATEDIFF(HOUR,CTime,GETDATE())>2  ", null, "order by id asc");
                if (listViewPayRecord != null && listViewPayRecord.Count > 0)
                {
                    return(WithDrawHandle());
                }
            }
            return(flag);
        }
示例#3
0
        //米刷回调
        public string MiShuaNotice()
        {
            HttpRequestBase request      = HttpContext.Request;
            Stream          stream       = request.InputStream;
            string          json         = string.Empty;
            string          responseJson = string.Empty;

            if (stream.Length != 0)
            {
                StreamReader streamReader = new StreamReader(stream);
                json = streamReader.ReadToEnd();
            }

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + json.ToString(), "d:\\Log\\MiShua", "MiShuaNotice");

            lock (lockMiShuaNotice)
            {
                string result = "fail";

                //json= "{\"payload\":\"mdvFvn5Aa9C + HONo6E9Sp7JmUGFaC5DTrwfmiB3d + sNpXUptNtMnKwy6tB2creQR2NxhGynCoTaQ85FbgDXlkDXRx8n0cPBaijKpWu2sTKjAm1kRUO / j7Qoh5TH0LR7UGVVJRPvnT5HvCVU9KizqfObhyaccjJnlHC9bq + mTdwaJ0gdJzACZhycS18vYDadrFyWyCaoPoShRzB3w3yGxIK6NhAY18iN9qjjWSsJWcfppzVCcu + yMiMnB8MZ8J2EGVohl6QlE4NrEQknEbWwcgwVV8xa07pBW2Z / QESzA6 / 7jO4e3ZSZcZ3SIartYZsrE7kG3vvWAYr2zFK745OUWeXSdNP0a5MpWP3K39RWWMYLfM7FKr9qAbuEl2vbGHjgC5zve5M3oiCPNuG / 5k5iDAzdgyElrP5PD / bF + E97hihNSK0zmhzZOZcXERZEzq6svBA7iSWKF1H2pCxLwtVNeacHHJIU0QR0VpTgyyEO2KV7JTDVBtVnLyZJhfQNY38r0CKE9Ysy22iruIq + pmBheGFi7tCvvaw + fJfIAykbUiW3lNHWlFImekq3h1KivAHJGhVFQfL2XjT + 7zxw2a9QhsOgwhaA5TvdtgtqLY + bkrvoG9UDo1A / IlRDV23SG5N50q0 / fvoL4QlZkseew5geu0OGvPWysurll87JqCGaQO3sewDEE9RIXyCuPPxCQTJ6qad636PyVANEYoK5PXVm116E03GTWp7 / +zGZXI + L5lgpJdFFuFfqbZ745PvKQ0GIrNxsx5ZaviB7yuos5IvVbG3F944pn / N31Jz5nBISQkx0zmQqJ8lZblue9XWPGC14T / 2 / 8E1y5lvuAc5EICRa9EfEYvOeH1NER3VnxexCeq2g\u003d\",\"state\":\"Successful\",\"sign\":\"3C1FF7EFED5D760F3CE4672DD7A4811B\",\"mchNo\":\"100445\",\"code\":0}";
                respModel <noticeMiShuaModel> model = new respModel <noticeMiShuaModel>();


                model = JsonConvert.DeserializeObject <respModel <noticeMiShuaModel> >(json);


                bool flag = false;
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\MiShua", "MiShuaNotice");
                yeepayLogParasDao.Init(Convert.ToInt32(model.Data.tradeNo), JsonConvert.SerializeObject(model), 2);

                result = "SUCCESS";
                if (model.Data.status == "00" && model.Data.qfStatus == "SUCCESS")//处理成功
                {
                    var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.Data.tradeNo));
                    var pay       = payRecordDao.Single(yeepayLog.KeyId);
                    if (pay.DrawState == 10)
                    {
                        Logs.WriteLog($"重复处理:State=10,orderId:{model.Data.tradeNo},返回结果:{result}", "d:\\Log\\MiShua", "MiShuaNotice");
                        return(result);
                    }
                    pay.State      = 10;
                    pay.DrawState  = 10;
                    pay.UTime      = DateTime.Now;
                    pay.HandleTime = DateTime.Now;
                    flag           = payRecordDao.Update(pay);
                    Logs.WriteLog($"代付成功:flag={flag}", "d:\\Log\\MiShua", "MiShuaNotice");
                    yeepayLogDao.UpdateState(Convert.ToInt32(model.Data.tradeNo), model.Data.status, model.Data.statusDesc, 10);

                    //交易成功回调
                    UsersDepository.NoticeSuccess(pay.ID, pay.UserId);
                }
                else if (model.Data.status == "00" && model.Data.qfStatus != "SUCCESS")
                {
                    var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.Data.tradeNo));
                    var pay       = payRecordDao.Single(yeepayLog.KeyId);
                    if (pay.State == 5)
                    {
                        Logs.WriteLog($"重复处理:State=5,orderId:{model.Data.tradeNo},返回结果:{result}", "d:\\Log\\MiShua", "MiShuaNotice");
                        return(result);
                    }
                    pay.State      = 5;
                    pay.DrawState  = 0;
                    pay.UTime      = DateTime.Now;
                    pay.HandleTime = DateTime.Now;
                    flag           = payRecordDao.Update(pay);
                    Logs.WriteLog($"支付成功:flag={flag}", "d:\\Log\\MiShua", "MiShuaNotice");
                    yeepayLogDao.UpdateState(Convert.ToInt32(model.Data.tradeNo), model.Data.status, model.Data.statusDesc, 5);
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\MiShua", "MiShuaNotice");
                return(result);
            }
        }
示例#4
0
        //腾付通  代付回调
        public string NoticeWithTeng()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Teng", "NoticeWithTeng");

            lock (lockNoticeWithTeng)
            {
                string        result = "fail";
                respTengModel model  = new respTengModel();
                model.version  = TQuery.GetString("version");
                model.agentId  = TQuery.GetString("agentId");
                model.merId    = TQuery.GetString("merId");
                model.orderId  = TQuery.GetString("orderId");
                model.respCode = TQuery.GetString("respCode");
                model.respMsg  = TQuery.GetString("respMsg");
                model.sign     = TQuery.GetString("sign");

                //string json = "{\"agentId\":\"A1000000009\",\"merId\":\"1000000010\",\"orderId\":\"100001261\",\"respCode\":\"00\",\"respMsg\":\"成功\",\"sign\":\"C3735B3E932CA3335ED7258E9DB21524\",\"version\":\"1.0.0\"}";
                //model = JsonConvert.DeserializeObject<respTengModel>(json);
                bool flag = false;
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Teng", "NoticeWithTeng");
                yeepayLogParasDao.Init(Convert.ToInt32(model.orderId), JsonConvert.SerializeObject(model), 2);

                if (TengDepository.isSign(model))
                {
                    if (model.backState == 0)//处理成功
                    {
                        result = "SUCCESS";
                        var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.orderId));
                        var pay       = payRecordDao.Single(yeepayLog.KeyId);
                        if (pay.State == 10)
                        {
                            Logs.WriteLog($"重复处理:State=10,orderId:{model.orderId},返回结果:{result}", "d:\\Log\\Teng", "NoticeWithTeng");
                            return(result);
                        }
                        pay.State      = 10;
                        pay.DrawState  = 10;
                        pay.UTime      = DateTime.Now;
                        pay.HandleTime = DateTime.Now;
                        flag           = payRecordDao.Update(pay);
                        Logs.WriteLog($"修改支付订单结果:flag={flag}", "d:\\Log\\Teng", "NoticeWithTeng");
                        //交易成功回调
                        UsersDepository.NoticeSuccess(pay.ID, pay.UserId);
                        yeepayLogDao.UpdateState(Convert.ToInt32(model.orderId), model.respCode, model.respMsg, 10);
                    }
                }
                else
                {
                    Logs.WriteLog($"签名比对失败:sign:{model.sign}", "d:\\Log\\Teng", "NoticeWithTeng");
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\Teng", "NoticeWithTeng");
                return(result);
            }
        }
示例#5
0
        // 易宝结算回调
        public string withDrawApi()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Yeepay", "WithDrawApiNotice");


            noticeWithDrawApiModel model = new noticeWithDrawApiModel();

            model.mainCustomerNumber = TQuery.GetString("mainCustomerNumber");
            model.externalNo         = TQuery.GetString("externalNo");
            model.customerNumber     = TQuery.GetString("customerNumber");
            model.serialNo           = TQuery.GetString("serialNo");
            model.transferStatus     = TQuery.GetString("transferStatus");
            model.requestTime        = TQuery.GetString("requestTime");
            model.handleTime         = TQuery.GetString("handleTime");
            model.transferWay        = TQuery.GetString("transferWay");
            model.receiver           = TQuery.GetString("receiver");
            model.receiverBankCardNo = TQuery.GetString("receiverBankCardNo");
            model.receiverBank       = TQuery.GetString("receiverBank");
            model.amount             = TQuery.GetString("amount");
            model.fee          = TQuery.GetString("fee");
            model.basicFee     = TQuery.GetString("basicFee");
            model.exTargetFee  = TQuery.GetString("exTargetFee");
            model.actualAmount = TQuery.GetString("actualAmount");
            model.failReason   = TQuery.GetString("failReason");
            model.hmac         = TQuery.GetString("hmac");
            model.code         = TQuery.GetString("code");
            model.message      = TQuery.GetString("message");
            //string json = "{\"actualAmount\":\"98.62\",\"amount\":\"99.62\",\"basicFee\":\"1.0\",\"customerNumber\":\"10019642647\",\"exTargetFee\":\"0.0\",\"externalNo\":\"100000178\",\"failReason\":\"\",\"fee\":\"0\",\"handleTime\":\"2018-03-07 17:18:39\",\"hmac\":\"8200ea9ccdf38d43a0e0ba9606bb504a\",\"mainCustomerNumber\":\"10018708270\",\"receiver\":\"渠*树\",\"receiverBank\":\"中国银行\",\"receiverBankCardNo\":\"621790*********6547\",\"requestTime\":\"2018-03-07 17:18:38\",\"serialNo\":\"SKBRJT325245e2492a4fdfad9066b89a0ef4a9\",\"transferStatus\":\"SUCCESSED\",\"transferWay\":\"1\"}";
            //string json = "{\"actualAmount\":\"175.23\",\"amount\":\"177.23\",\"basicFee\":\"2.0\",\"customerNumber\":\"10020136223\",\"exTargetFee\":\"0.0\",\"externalNo\":\"100000245\",\"failReason\":\"\",\"fee\":\"0\",\"handleTime\":\"2018-03-13 15:01:57\",\"hmac\":\"bbed9dfa537fef9658d27f1e444c210c\",\"mainCustomerNumber\":\"10018708270\",\"receiver\":\"王*凯\",\"receiverBank\":\"中国银行\",\"receiverBankCardNo\":\"621790*********9332\",\"requestTime\":\"2018-03-13 15:01:54\",\"serialNo\":\"SKBRJTa4ce8f5595c54e47a12a939f1202a680\",\"transferStatus\":\"SUCCESSED\",\"transferWay\":\"1\"}";
            //string json = "{\"actualAmount\":\"103.6\",\"amount\":\"104.6\",\"basicFee\":\"1.0\",\"customerNumber\":\"10020136223\",\"exTargetFee\":\"0.0\",\"externalNo\":\"100000233\",\"failReason\":\"\",\"fee\":\"0\",\"handleTime\":\"2018-03-12 22:32:14\",\"hmac\":\"b5a06307c9e40dffe7b697ea20045406\",\"mainCustomerNumber\":\"10018708270\",\"receiver\":\"王*凯\",\"receiverBank\":\"中国银行\",\"receiverBankCardNo\":\"621790*********9332\",\"requestTime\":\"2018-03-12 22:32:14\",\"serialNo\":\"SKBRJT7262630296714a8191468c61d4235399\",\"transferStatus\":\"SUCCESSED\",\"transferWay\":\"1\"}";
            //model = JsonConvert.DeserializeObject<noticeWithDrawApiModel>(json);

            lock (lockWithDrawApi)
            {
                bool   flag   = false;
                string result = "fail";
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Yeepay", "WithDrawApiNotice");

                //签名验证
                StringBuilder sb = new StringBuilder();
                sb.Append(model.mainCustomerNumber);
                sb.Append(model.customerNumber);
                sb.Append(model.externalNo);
                sb.Append(model.serialNo);
                sb.Append(model.transferStatus);
                sb.Append(model.requestTime);
                sb.Append(model.handleTime);
                sb.Append(model.transferWay);
                sb.Append(model.receiver);
                sb.Append(model.receiverBankCardNo);
                sb.Append(model.receiverBank);
                sb.Append(model.amount);
                sb.Append(model.fee);
                sb.Append(model.basicFee);
                sb.Append(model.exTargetFee);
                sb.Append(model.actualAmount);
                sb.Append(model.failReason);

                string sign = ITOrm.Utility.Encryption.EncryptionHelper.HMACMD5(ITOrm.Payment.Yeepay.YeepayDepository.YeepayHmacKey, sb.ToString());
                if (model.hmac != sign)
                {
                    Logs.WriteLog($"签名比对失败:mac:{model.hmac},sign:{sign}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                    return(result);
                }

                yeepayLogParasDao.Init(Convert.ToInt32(model.externalNo), JsonConvert.SerializeObject(model), 2);

                int state = -1;
                switch (model.transferStatus)
                {
                case "SUCCESSED":
                    state = 10;
                    break;

                case "RECEIVED":
                    state = 1;
                    break;

                case "PROCESSING":
                    state = 2;
                    break;

                case "FAILED":
                    state = -1;
                    break;

                case "REFUNED":
                    state = -2;
                    break;

                case "CANCELLED":
                    state = -3;
                    break;

                default:
                    state = -4;
                    break;
                }
                //更新
                yeepayLogDao.UpdateState(Convert.ToInt32(model.externalNo), model.transferStatus == "SUCCESSED" ? "0000" : "9999", model.failReason, state);
                var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.externalNo));
                var draw      = withDrawDao.Single(yeepayLog.KeyId);
                var pay       = payRecordDao.Single(draw.PayId);
                if (draw.State == 10)
                {
                    result = "SUCCESS";
                    Logs.WriteLog($"重复处理 :{result},draw.State ==10", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                    return(result);
                }


                //修改订单信息
                draw.UTime    = DateTime.Now;
                draw.State    = state;
                draw.Message  = model.failReason;
                pay.DrawState = state;
                if (state == 10)
                {
                    draw.HandleTime         = Convert.ToDateTime(model.handleTime);
                    draw.Receiver           = model.receiver;
                    draw.ReceiverBankCardNo = model.receiverBankCardNo;
                    draw.ReceiverBank       = model.receiverBank;
                    draw.Fee          = Convert.ToDecimal(model.fee);
                    draw.BasicFee     = Convert.ToDecimal(model.basicFee);
                    draw.ExTargetFee  = Convert.ToDecimal(model.exTargetFee);
                    draw.ActualAmount = Convert.ToDecimal(model.actualAmount);
                    pay.HandleTime    = draw.HandleTime;
                    //pay.DrawBankCard = draw.ReceiverBankCardNo;
                }
                flag = withDrawDao.Update(draw);
                Logs.WriteLog($"结算订单修改:flag:{flag},transferStatus:{model.transferStatus},state:{state}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                flag = payRecordDao.Update(pay);
                Logs.WriteLog($"支付订单修改:flag:{flag},transferStatus:{model.transferStatus},state:{state}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                if (pay.State == 10)
                {
                    //交易成功回调
                    UsersDepository.NoticeSuccess(pay.ID, pay.UserId);
                }
                if (flag)
                {
                    result = "SUCCESS";
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                return(result);
            }
        }
示例#6
0
        //荣邦科技  支付回调
        public string backpayNotice()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Masget", "backpayNotice");


            bool flag = false;


            //string json= "{\"Appid\":\"402862423\",\"Data\":\"5JuUVmDLj4r9d-7FhjaEn1LtxEUAdBv3Aco2lYdyOhzPEWt-ZFCPe8vHFDaPvrc8AG4s0cH1lJ393A1aSWCRTTGEp5rDl0aYCp2ijBlN_jyAp8HwEDdYpGyKE5PkO8XGLmjbPPyj3zLXVNuHvgHuhTRiQ5pNgNTj6ZG2vSqsmednikP5MOEo4HBQX_mTMpzi_P_fnTFHfK4MlVmPamHqxdG1uOeu2vLPJjVB01crohdtiEBU-ZE6WHsRwmgxVPrcUdWCSzsipukK4Ebgfzz34F8d4ZBcOnR0aNz7_ZB-xDLK66yNBnhI7V6fY-Pg_oaqK13Cc9tJYssbzqPX4S5Ek29KX4lous7BCyjvYYJmp_3MTbDU0Sq1t_A8IMUeNI8K4iHyubHYnS2-vclmwIY0_YnYqOSuZASS12juzDR_nDyFzf_k5iWbMQ_E6vEoGTz0Vmq-r93rDZkpcXeS2TRYjnkZNXSRvihdqL3ZA4BtCt9uRDQ02E3hemJDetnCGAYRfm8d_yoHQhc_GNcIXA_MQt-lzVT2Cp1Qj2kPDBxjZyVm7SlL_ticf44MvitGpxxueDOywcJkV0Az0iVyWsjuAXDJovBaoSCA-AZAi35jYcV3_O0hv1Qne9juWhDm7JKh_OGEP2qVf8MfgNDNB8yOXK258UMoEfQEfzk5uQT3txjmq75BqpwEXrpA44AjEBTpxSvbIYID-crcBrYbhHpzP3X1zMJXh3TeAerTC-QigIx4u6FdDMXyzFD9PpyFft2kixCnf1P0xL1azAYRlD6H7UmgJC-wfZR-eFR3_hrbC8RymD8AVdwiJGzSikPERAIXcQbF760M4qIfATg71WC6lirRuL-wRrFwCtbrcurzHxp95kUMSlF1UH0XI5p7S6GZ\",\"Method\":\"paymentreport\",\"Sign\":\"b6609c9bf0b74b23249a733c9dd2524e\"}";
            //JObject data = JObject.Parse(json);
            //string Secretkey = "dxn47a9egzljq3pw";
            //string AesD = ITOrm.Payment.Masget.AES.Decrypt(data["Data"].ToString(), Secretkey, Secretkey);
            //string lastSign =$"{data["Data"].ToString()}{Secretkey}";
            //string sign = SecurityHelper.GetMD5String(lastSign);

            lock (lockbackpayNotice)
            {
                noticeMasgetModel <noticePayConfirmpayModel> notice = new noticeMasgetModel <noticePayConfirmpayModel>();
                notice.Appid  = TQuery.GetString("Appid");
                notice.Data   = TQuery.GetString("Data");
                notice.Sign   = TQuery.GetString("Sign");
                notice.Method = TQuery.GetString("Method");

                //notice = JsonConvert.DeserializeObject<noticeMasgetModel<noticePayConfirmpayModel>>(json);
                JObject respNotice = new JObject();
                respNotice["response"] = "00";
                respNotice["message"]  = "成功";

                Logs.WriteLog($"参数序列化记录:{JsonConvert.SerializeObject(notice)}", "d:\\Log\\Masget", "backpayNotice");

                if (notice.IsSign)
                {
                    if (notice.dataExpress != null && notice.dataExpress.respcode == "2" && notice.Method == "paymentreport")
                    {
                        //支付成功
                        int requestId = Convert.ToInt32(notice.dataExpress.ordernumber);
                        var yeepayLog = yeepayLogDao.Single(requestId);

                        if (yeepayLog.State == 10)
                        {
                            Logs.WriteLog($"重复处理:requestId:{requestId},payRecord.State == 10,返回数据:{respNotice.ToString()}", "d:\\Log\\Masget", "backpayNotice");
                            return(respNotice.ToString());
                        }
                        yeepayLogParasDao.Init(requestId, JsonConvert.SerializeObject(notice), 2);
                        Logs.WriteLog($"记录日志:requestId:{requestId},notice:{JsonConvert.SerializeObject(notice)}", "d:\\Log\\Masget", "backpayNotice");

                        //更新
                        yeepayLogDao.UpdateState(requestId, notice.dataExpress.respcode, notice.dataExpress.respmsg, (notice.dataExpress.respcode == "2") ? 10 : -1);
                        Logs.WriteLog($"更新日志:requestId:{requestId},respmsg:{notice.dataExpress.respmsg}", "d:\\Log\\Masget", "backpayNotice");


                        int payRecordId = yeepayLog.KeyId;
                        var payRecord   = payRecordDao.Single(payRecordId);
                        payRecord.State      = 10;
                        payRecord.DrawState  = 10;
                        payRecord.Message    = "支付成功";
                        payRecord.HandleTime = Convert.ToDateTime(notice.dataExpress.businesstime);
                        flag = payRecordDao.Update(payRecord);
                        //更新支付记录
                        Logs.WriteLog($"更新支付记录:requestId:{requestId},payRecordId:{payRecordId},flag:{flag}", "d:\\Log\\Masget", "backpayNotice");
                        //交易成功回调
                        UsersDepository.NoticeSuccess(payRecord.ID, payRecord.UserId);
                    }
                    else
                    {
                        Logs.WriteLog($"其他错误:appid:{notice.Appid},Method:{notice.Method}", "d:\\Log\\Masget", "backpayNotice");
                        respNotice["response"] = "99";
                        respNotice["message"]  = "其他错误";
                    }
                }
                else//签名失败
                {
                    Logs.WriteLog($"签名比对失败:appid:{notice.Appid},Method:{notice.Method},sign:{notice.Sign},sysSign:{notice.sysSign}", "d:\\Log\\Masget", "backpayNotice");
                    respNotice["response"] = "99";
                    respNotice["message"]  = "签名比对失败";
                }
                Logs.WriteLog($"返回数据:{respNotice.ToString()}", "d:\\Log\\Masget", "backpayNotice");
                return(respNotice.ToString());
            }
        }