Exemplo n.º 1
0
        public string a()
        {
            WithDrawBLL wi    = new WithDrawBLL();
            WithDraw    model = wi.Single(100004);

            model.UTime = DateTime.Now;
            bool flag = wi.Update(model);

            return(flag.ToString());
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            WithDrawBLL wi    = new WithDrawBLL();
            WithDraw    model = wi.Single(100004);

            model.UTime = DateTime.Now;
            bool flag = wi.Update(model);

            MessageBox.Show(flag.ToString());
        }
Exemplo n.º 3
0
        public string withDrawApiNotice()
        {
            bool   flag   = false;
            string result = "fail";
            noticeWithDrawApiModel model = new noticeWithDrawApiModel();

            model.externalNo         = "100000030";
            model.serialNo           = "2342423423";
            model.transferStatus     = "SUCCESSED";
            model.requestTime        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            model.handleTime         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            model.transferWay        = "1";
            model.receiver           = "陈鑫";
            model.receiverBankCardNo = "6222020200083410239";
            model.receiverBank       = "工商银行";
            model.amount             = "100";
            model.fee          = "2";
            model.basicFee     = "3";
            model.exTargetFee  = "4";
            model.actualAmount = "91";
            model.failReason   = "成功";


            //返回后日志记录
            Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Yeepay", "WithDrawApi");
            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);

            if (draw.State == 10)
            {
                result = "SUCCESS";
                return(result);
            }


            //修改订单信息
            draw.UTime   = DateTime.Now;
            draw.State   = state;
            draw.Message = model.failReason;
            if (state == 10)
            {
                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);
                flag = withDrawDao.Update(draw);
            }
            //添加支付银行卡
            int ubkCnt = withDrawDao.Count(" UserId=@UserId and TypeId=0 and State=1 and  BankCard=@BankCard ", new { draw.UserId, draw.ReceiverBankCardNo });

            if (ubkCnt == 0)
            {
                UserBankCard ubk = new UserBankCard();
                ubk.BankCard = model.receiverBankCardNo;
                ubk.TypeId   = 0;
                ubk.State    = 1;
                ubk.UserId   = draw.UserId;
                //ubk.Mobile = model.payerPhone;
                ubk.IP       = ITOrm.Utility.Client.Ip.GetClientIp();
                ubk.Platform = 1;
                //ubk.BankCode = model.bankCode;
                userBankCardDao.Insert(ubk);
            }

            if (flag)
            {
                result = "SUCCESS";
            }

            return(result);
        }
Exemplo n.º 4
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);
            }
        }