コード例 #1
0
        public string Notify(YeePayNotify yeePayNotify)
        {
            bool reuslt = false;

            StringBuilder sbLog = new StringBuilder();

            try
            {
                //1.记录请求日志
                //sbLog.Append("\r\n 1、请求参数:" + " notify(XML): " + yeePayNotify.notify + " \r\n sign: " + yeePayNotify.sign);

                // 1.记录请求日志(不记录签名数据,只记录XML数据)
                sbLog.Append("\r\n 1、请求参数:" + " notify(XML): " + yeePayNotify.notify);

                StringBuilder postData = new StringBuilder();
                postData.Append("req=" + dataFornat.UrlEncode(yeePayNotify.notify)); //编码
                postData.Append("&sign=" + dataFornat.UrlEncode(yeePayNotify.sign)); //编码
                string strHttpPost = yeePay.HttpPost(yeePayConfig._verifyUrl, postData.ToString());

                sbLog.Append("\r\n 2. 验证签名状态:" + strHttpPost);

                // 2. 验证签名
                if (strHttpPost.Contains("SUCCESS"))
                {
                    // 解析XML
                    XElement root        = XElement.Parse(yeePayNotify.notify);
                    string   bizType     = root.Element("bizType").Value;
                    string   code        = root.Element("code").Value;
                    notify   _baseNotify = null;

                    #region 3.业务处理

                    if (code == ((int)EnumCode.CodeTrue).ToString())
                    {
                        #region

                        if (bizType == EnumNotifyBizType.REGISTER.ToEnumDesc())          //2.1 注册( 2.6企业注册) ok
                        {
                            _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>(); //序列化 XML 转 实体
                            reuslt      = yeePayOper.ToRegister(_baseNotify.platformUserNo);
                        }
                        else if (bizType == EnumNotifyBizType.RECHARGE.ToEnumDesc())//2.2 充值 ok
                        {
                            _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>();
                            reuslt      = yeePayOper.ToRecharge(_baseNotify.platformUserNo, _baseNotify.requestNo);
                        }
                        else if (bizType == EnumNotifyBizType.WITHDRAW.ToEnumDesc()) // 2.3 提现 ok
                        {
                            MoneyCarCar.Models.YeePay.NotifyModel.toWithdraw.notify _notify = yeePayNotify.notify.XmlDeserialize <MoneyCarCar.Models.YeePay.NotifyModel.toWithdraw.notify>();
                            reuslt = yeePayOper.ToWithdraw(_baseNotify.platformUserNo, _baseNotify.requestNo);
                        }
                        else if (bizType == EnumNotifyBizType.BIND_BANK_CARD.ToEnumDesc())// 2.4 绑卡 ok
                        {
                            MoneyCarCar.Models.YeePay.NotifyModel.toBindBankCard.notify _notify = yeePayNotify.notify.XmlDeserialize <MoneyCarCar.Models.YeePay.NotifyModel.toBindBankCard.notify>();
                            string BankName = _notify.bank.ToEnum <EnumBank>().ToEnumDesc();
                            reuslt = yeePayOper.ToBindBank(_notify.cardNo, BankName, _notify.platformUserNo, _notify.requestNo);
                        }
                        else if (bizType == EnumNotifyBizType.UNBIND_BANK_CARD.ToEnumDesc())
                        {
                            //2.5 同步处理
                        }
                        else if (bizType == EnumNotifyBizType.TRANSACTION.ToEnumDesc())
                        {
                            //2.7 转账、投标、还款、债权转让
                            _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>();
                            if (_baseNotify.status == EnumNotifyStatus.PREAUTH.ToEnumDesc())
                            {
                                BaseHelper baseHelper = new BaseHelper();
                                // 调用存储过程 :业务处理
                                string errorMsg = "";
                                reuslt = yeePayOper.ToCpTransaction(_baseNotify.requestNo, out errorMsg);

                                if (reuslt)
                                {
                                    #region 自动调用转账确认

                                    MoneyCarCar.Models.YeePay.RequestModel.Complete_Transaction complete_Transaction = new MoneyCarCar.Models.YeePay.RequestModel.Complete_Transaction();

                                    complete_Transaction.platformUserNo = _baseNotify.platformUserNo;
                                    complete_Transaction.requestNo      = _baseNotify.requestNo;
                                    complete_Transaction.mode           = EnumModeCOMPLETETRANSACTION.CONFIRM.ToString();

                                    BaseResultDto <MoneyCarCar.Models.YeePay.Response.COMPLETE_TRANSACTION.response> baseResultDtoResponse = new BaseResultDto <MoneyCarCar.Models.YeePay.Response.COMPLETE_TRANSACTION.response>();
                                    YeePay yeepay = new YeePay();
                                    baseResultDtoResponse = yeepay.COMPLETE_TRANSACTION(complete_Transaction);
                                    string str = baseResultDtoResponse.ErrorMsg;//XML 数据

                                    #endregion
                                }
                                else
                                {
                                    sbLog.Append("\r\n  (2.7 转账、投标、还款、债权转让)业务处理失败,不自动调用<转账确认>接口");
                                }
                            }
                            else if (_baseNotify.status == EnumNotifyStatus.DIRECT.ToEnumDesc())
                            {
                                // 3.4 直接转账(平台转款)、
                                _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>();
                                YeePayOper yeep = new YeePayOper();
                                reuslt = yeep.Direct_Transaction(_baseNotify.requestNo);
                            }
                            else if (_baseNotify.status == EnumNotifyStatus.CONFIRM.ToEnumDesc())
                            {
                                // 3.5 自动转账(自动还款)单独调用, 与 3.7 无关
                                _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>();
                                YeePayOper yeep = new YeePayOper();
                                reuslt = yeep.Direct_Transaction(_baseNotify.requestNo);

                                if (reuslt)
                                {
                                    #region 自动调用转账确认

                                    MoneyCarCar.Models.YeePay.RequestModel.Complete_Transaction complete_Transaction = new MoneyCarCar.Models.YeePay.RequestModel.Complete_Transaction();

                                    complete_Transaction.platformUserNo = _baseNotify.platformUserNo;
                                    complete_Transaction.requestNo      = _baseNotify.requestNo;
                                    complete_Transaction.mode           = EnumModeCOMPLETETRANSACTION.CONFIRM.ToString();

                                    BaseResultDto <MoneyCarCar.Models.YeePay.Response.COMPLETE_TRANSACTION.response> baseResultDtoResponse = new BaseResultDto <MoneyCarCar.Models.YeePay.Response.COMPLETE_TRANSACTION.response>();
                                    YeePay yeepay = new YeePay();
                                    baseResultDtoResponse = yeepay.COMPLETE_TRANSACTION(complete_Transaction);
                                    string str = baseResultDtoResponse.ErrorMsg;//XML 数据

                                    #endregion
                                }
                                else
                                {
                                    sbLog.Append("\r\n  (3.5 自动转账)业务处理失败,不自动调用<转账确认>接口");
                                }
                            }
                            else
                            {
                                sbLog.Append("\r\n  验证状态(status)失败:不处理");
                            }
                        }
                        else if (bizType == EnumNotifyBizType.AUTHORIZE_AUTO_TRANSFER.ToEnumDesc())
                        {
                            //2.8 转账授权
                            _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>();
                            // 调用存储过程 :业务处理
                        }
                        else if (bizType == EnumNotifyBizType.AUTHORIZE_AUTO_REPAYMENT.ToEnumDesc())
                        {
                            //2.9. 自动还款授权
                            _baseNotify = yeePayNotify.notify.XmlDeserialize <notify>();
                            // 调用存储过程 :业务处理
                        }
                        else
                        {
                            sbLog.Append("\r\n 验证状态(bizType)失败:不处理");
                        }
                        #endregion
                    }
                    else
                    {
                        sbLog.Append("\r\n 验证状态(code)失败:不处理");
                    }
                    #endregion
                }
            }
            catch (Exception e)
            {
                sbLog.Append("\r\n 业务处理异常(catch):" + e.ToString());
            }
            finally
            {
                sbLog.Append("\r\n 返回状态:" + (reuslt == true ? "SUCCESS" : "FALE"));
                Log.RecordLog("YeePayNotifyController", sbLog.ToString(), false);
            }

            if (reuslt == true)
            {
                return("SUCCESS"); //成功
            }
            else
            {
                return("FALE"); //失败
            }
        }
コード例 #2
0
        public BaseResultDto <string> HandExec(RQHandExecDto Exec)
        {
            SystemRequestRecord    model  = Exec.RequestRecord;
            BaseResultDto <string> result = new BaseResultDto <string>();

            YeePay     yeepay     = new YeePay();
            YeePayOper yeePayOper = new YeePayOper();
            string     strResult  = "未处理";

            try
            {
                if (helper.IsExists <SystemRequestRecord>(string.Format(" Id={0} and RequestOperStatus=1", model.Id)))
                {
                    switch (model.RequestType)
                    {
                    case 1:    //注册
                    {
                    }
                    break;

                    case 2:    //充值
                    {
                        MoneyCarCar.Models.YeePay.RequestModel.Query query = new MoneyCarCar.Models.YeePay.RequestModel.Query();

                        query.mode           = EnumMode.RECHARGE_RECORD.ToEnumDesc(); // 转款记录
                        query.platformUserNo = model.UserId.ToString();
                        query.requestNo      = model.Id.ToString();

                        BaseResultDto <MoneyCarCar.Models.YeePay.Response.QUERY.response> baseResultDtoResponse = new BaseResultDto <MoneyCarCar.Models.YeePay.Response.QUERY.response>();
                        baseResultDtoResponse = yeepay.QUERY <MoneyCarCar.Models.YeePay.Response.QUERY.response>(query);

                        string str = baseResultDtoResponse.ErrorMsg;        //XML 数据
                        // 反序列化
                        MoneyCarCar.Models.YeePay.Response.QUERY.RECHARGE_RECORD.response _response = baseResultDtoResponse.ErrorMsg.XmlDeserialize <MoneyCarCar.Models.YeePay.Response.QUERY.RECHARGE_RECORD.response>();

                        if (_response.status == EnumNotifyStatus.SUCCESS.ToEnumDesc())
                        {
                            bool b_reuslt = yeePayOper.ToRecharge(model.UserId.ToString(), model.Id.ToString());
                            if (b_reuslt)
                            {
                                strResult = "充值成功";
                            }
                            else
                            {
                                strResult = "未充值成功";
                            }
                        }
                        else
                        {
                            // 未充值成功
                            strResult = "未充值成功";
                        }
                    }
                    break;

                    case 3:    // 投资
                    {
                    }
                    break;

                    case 4:    //提现
                    {
                    }
                    break;

                    case 5:    //查询
                    {
                    }
                    break;

                    case 6:    //绑卡
                    {
                    }
                    break;

                    case 7:    //解绑
                    {
                    }
                    break;

                    case 8:    //结息
                    {
                        MoneyCarCar.Models.YeePay.RequestModel.Query query = new MoneyCarCar.Models.YeePay.RequestModel.Query();

                        query.mode           = EnumMode.CP_TRANSACTION.ToEnumDesc(); // 转款记录
                        query.platformUserNo = model.UserId.ToString();
                        query.requestNo      = model.Id.ToString();

                        BaseResultDto <MoneyCarCar.Models.YeePay.Response.QUERY.response> baseResultDtoResponse = new BaseResultDto <MoneyCarCar.Models.YeePay.Response.QUERY.response>();
                        baseResultDtoResponse = yeepay.QUERY <MoneyCarCar.Models.YeePay.Response.QUERY.response>(query);

                        string str = baseResultDtoResponse.ErrorMsg;        //XML 数据
                        // 反序列化
                        MoneyCarCar.Models.YeePay.Response.QUERY.CP_TRANSACTION.response _response = baseResultDtoResponse.ErrorMsg.XmlDeserialize <MoneyCarCar.Models.YeePay.Response.QUERY.CP_TRANSACTION.response>();

                        if (_response.status == EnumNotifyStatus.DIRECT.ToEnumDesc())
                        {
                            bool b_reuslt = yeePayOper.Direct_Transaction(model.Id.ToString());
                            if (b_reuslt)
                            {
                                strResult = "结息成功";
                            }
                            else
                            {
                                strResult = "结息未成功";
                            }
                        }
                        else
                        {
                            //结息未成功
                            strResult = "结息未成功";
                        }
                    }
                    break;

                    default:
                        break;
                    }

                    result.IsSeccess = true;
                    result.ErrorCode = 1;
                    result.ErrorMsg  = strResult;
                }
                else
                {
                    result.IsSeccess = true;
                    result.ErrorCode = 1;
                    result.ErrorMsg  = "状态已处理";
                }
                SystemLog log = new SystemLog();
                log.OperatorUserId   = Exec.OperatorUserId;
                log.OperatorUserName = Exec.OperatorUserName;
                log.OperatorType     = 4;
                log.BusinessType     = "手动同步数据";
                log.OperatorTime     = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                log.OperatorContent  = Exec.OperatorContent + " " + strResult;
                log.OperatorIP       = Exec.IP;
                //添加日志
                helper.Add <SystemLog>(log);
            }
            catch (Exception ex)
            {
                result.ErrorMsg  = ex.Message;
                result.ErrorCode = -1;
            }
            return(result);
        }