Пример #1
0
        /// <summary>
        /// 支付申报
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>true申报成功,false申报失败</returns>
        public bool DeclarePayment(WaitDeclareSO entity)
        {
            bool result = false;

            #region 获取支付信息
            SOPaymentDeclare data = SODA.DeclareGetPaymentInfoBySOSysNo(entity.SOSysNo);
            #endregion
            //检查是否需要进行支付申报,东方支付不需要进行支付申报
            if (data.PayTypeID == s_EasiPayID)
            {
                //东方支付不需要传,直接更新支付申报状态为申报成功
                SODA.DeclareUpdatePaymentDeclareInfo(entity.SOSysNo, null, 1);
                data = SODA.DeclareGetPaymentInfoBySOSysNo(entity.SOSysNo);
            }
            if (data.DeclareStatus.HasValue && data.DeclareStatus.Value == 1)
            {
                result = true;
            }
            else
            {
                #region 构造请求参数
                VendorCustomsInfo customsInfo = SODA.LoadVendorCustomsInfo(entity.SOSysNo);
                PayType           payType     = ObjectFactory <ICommonBizInteract> .Instance.GetPayType(data.PayTypeSysNo);

                EasiPayRequestDeclarePayment declarePayment = EntityConverter <SOPaymentDeclare, EasiPayRequestDeclarePayment> .Convert(data);

                declarePayment.Version      = "v1.0";
                declarePayment.CommitTime   = DateTime.Now.ToString("yyyyMMddhhmmss");
                declarePayment.CoCode       = payType.CBTMerchantCode;
                declarePayment.CoName       = payType.CBTMerchantName;
                declarePayment.MerchantCode = customsInfo.CBTMerchantCode;
                declarePayment.MerchantName = customsInfo.CBTMerchantName;
                declarePayment.SerialNumber = this.CreateSerialNumber(declarePayment.CoCode);
                declarePayment.IdentifyType = data.IDCardType == 0 ? "30" : "";//固定值30 身份证
                declarePayment.Birthday     = data.Birthday.ToString("yyyyMMdd");
                declarePayment.Sex          = data.Gender == 0 ? "F" : data.Gender == 1 ? "M" : "";
                declarePayment.PayID        = data.PayTransNumber.Substring(1).Trim();//因为支付有个前缀P
                #endregion
                #region 处理请求,解析请求结果
                string note             = string.Empty;
                string reqContent       = BuildPostReqData(declarePayment, payType.CBTSODeclarePaymentSecretKey);
                string strRequestResult = HttpPostRequest(AppSettingManager.GetSetting("SO", "EasiPayDeclarePaymentConfigRequestUrl"), reqContent);
                strRequestResult = CommonUtility.HttpUrlDecode(strRequestResult);
                EasiPayRequestResult requestResult = SerializationUtility.JsonDeserialize <EasiPayRequestResult>(strRequestResult);
                if (requestResult.status.ToLower().Equals("success"))
                {
                    result = true;
                    note   = "支付报关申请成功";
                }
                else
                {
                    note = "支付报关申请失败:" + requestResult.msg;
                }
                #region 写系统Log
                ApplicationEventLog log = new ApplicationEventLog()
                {
                    Source           = "JOB SODeclarePayment",
                    ReferenceIP      = ServiceContext.Current.ClientIP,
                    EventType        = 9,
                    HostName         = "JOB",
                    EventTitle       = "SODeclarePayment Request",
                    EventMessage     = reqContent,
                    LanguageCode     = "zh-CN",
                    CompanyCode      = "8601",
                    StoreCompanyCode = "8601",
                    EventDetail      = note,
                };
                ObjectFactory <ICommonBizInteract> .Instance.CreateApplicationEventLog(log);

                #endregion
                #endregion
                #region 更新支付状态
                SODA.DeclareUpdatePaymentDeclareInfo(entity.SOSysNo, declarePayment.SerialNumber, result ? 1 : 0);
                #endregion
            }
            return(result);
        }