Example #1
0
        /// <summary>
        /// 网银积分冲正
        /// </summary>
        /// <param name="customerCode"></param>
        /// <param name="mechNo"></param>
        /// <param name="thirdSeqNo"></param>
        /// <param name="oriThirdSeqNo"></param>
        /// <param name="point"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public string RushTrading(string customerCode, string mechNo, string thirdSeqNo, string oriThirdSeqNo, double point, string description)
        {
            string result = string.Empty;

            //构造请求数据
            NameValueCollection postData = new NameValueCollection();

            //添加公共请求头部
            AddCommonParameter(postData);
            //冲正请求参数
            postData.Add("CLIENT_NO", customerCode);         //客户号
            postData.Add("MECH_NO", mechNo);                 //商户号
            postData.Add("THIRD_SEQ_NO", thirdSeqNo);        //第三方流水号
            postData.Add("ORI_THIRD_SEQ_NO", oriThirdSeqNo); //原第三方流水号
            postData.Add("POINT", point.ToString());         //积分
            postData.Add("DESCRIPTION", description);        //说明
            string praraStr = Partners.BuildStringFromNameValueCollection(postData);

            //发送请求
            string responseData = Partners.HttpPostRequest(Url, praraStr, "application/x-www-form-urlencoded", "UTF-8");

            //解析响应数据
            BankPointRushTradingResponse data = SerializationUtility.JsonDeserialize <BankPointRushTradingResponse>(responseData);

            result = data.SERV_SEQ_NO;//返回服务处理流水号

            return(result);
        }
Example #2
0
        public override void SetRequestParam(Entity.Passport.PartnerContext context)
        {
            //第一次request
            string requestParam = string.Format("trxCode={0}&redirect_uri={1}",
                                                context.PassportInfo.Parnter.CustomProperty1,
                                                SpecialUrlEncode(BuildActionUrl(context.PassportInfo.Base.BaseUrl, context.PassportInfo.Parnter.LoginBackUrl)));

            Logger.WriteLog(string.Format("返回地址:{0}", SpecialUrlEncode(BuildActionUrl(context.PassportInfo.Base.BaseUrl, context.PassportInfo.Parnter.LoginBackUrl))), "PassportTLYH", "GetLoginUrl");
            string url = string.Format("{0}/{1}?{2}",
                                       context.PassportInfo.Parnter.LoginUrl,
                                       context.PassportInfo.Parnter.CustomProperty2,
                                       requestParam);
            string responseData = HttpGetRequest(url, context.PassportInfo.Parnter.Encoding);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取第一次request响应数据:{0}", responseData), "PassportTLYH", "GetLoginUrl");
            }
            TLYHLoginInfo loginInfo = SerializationUtility.JsonDeserialize <TLYHLoginInfo>(responseData);

            if (loginInfo == null)
            {
                throw new BusinessException("登录失败!");
            }
            //第二次post
            context.RequestParam["uniteLoginCode"]   = loginInfo.cd.uniteLoginVerifyCode;
            context.RequestParam["authorizedSerial"] = loginInfo.cd.authorizedSerial;
            context.RequestParam["redirect_uri"]     = SpecialUrlEncode(BuildActionUrl(context.PassportInfo.Base.BaseUrl, context.PassportInfo.Parnter.LoginBackUrl));// context.ReturnUrl;
            context.PassportInfo.Parnter.LoginUrl   += loginInfo.cd.uniteLoginUri;
        }
Example #3
0
        public ActionResult AjaxRefundRequest()
        {
            var sysnoData = Request["SysNo"];
            int sysno;

            if (!int.TryParse(sysnoData, out sysno) || sysno <= 0)
            {
                throw new BusinessException(L("退换货申请单编号不正确"));
            }
            var           refundData = Request["RefundInfo"];
            RMARefundInfo refundInfo = SerializationUtility.JsonDeserialize <RMARefundInfo>(refundData);

            if (string.IsNullOrWhiteSpace(refundData) || refundInfo == null)
            {
                throw new BusinessException(L("退款信息为空"));
            }
            //退款方式为“网关直接退款”
            refundInfo.RefundPayType = RefundPayType.NetWorkRefund;

            LoginUser user = EntityConverter <UserAuthVM, LoginUser> .Convert(UserAuthHelper.GetCurrentUser());

            RMARequestInfo data = RMARequestService.Refund(sysno, refundInfo, user);

            return(Json(data));
        }
Example #4
0
        /// <summary>
        /// 申报商品结果处理
        /// </summary>
        /// <param name="callbackString"></param>
        /// <returns></returns>
        public bool DeclareProductCallBack(string callbackString)
        {
            List <EasiPayProductDeclareBackItemInfo> itemList = SerializationUtility.JsonDeserialize <List <EasiPayProductDeclareBackItemInfo> >(callbackString);

            foreach (var item in itemList)
            {
                if (item.status == "1")
                {
                    //商品申报成功
                    ObjectFactory <IIMBizInteract> .Instance.ProductCustomsSuccess(new ProductEntryInfo()
                    {
                        ProductID  = item.cargoCode,
                        EntryCode  = item.cargoCode,
                        TariffCode = item.cargoCodeTS,
                        TariffRate = item.cargoRate,
                        AuditNote  = item.statusMsg,
                    });
                }
                else if (item.status == "2")
                {
                    //商品申报失败
                    ObjectFactory <IIMBizInteract> .Instance.ProductCustomsFail(new ProductEntryInfo()
                    {
                        ProductID = item.cargoCode,
                        AuditNote = item.statusMsg,
                    });
                }
                else
                {
                    throw new BizException("非法审核状态");
                }
            }
            return(true);
        }
        public ActionResult GroupBuyBatchAction()
        {
            BatchActionVM batchInfo = SerializationUtility.JsonDeserialize <BatchActionVM>(Request.Form["data"]);
            var           loginUser = UserAuthHelper.GetCurrentUser();
            string        msg       = LanguageHelper.GetText("操作成功。");

            switch (batchInfo.Action)
            {
            case "Submit":
                _groupBuyService.Submit(loginUser.SellerSysNo, loginUser.UserDisplayName, batchInfo.Ids);
                msg = LanguageHelper.GetText("提交审核成功。");
                break;

            case "Void":
                _groupBuyService.Void(loginUser.SellerSysNo, loginUser.UserDisplayName, batchInfo.Ids);
                msg = LanguageHelper.GetText("作废成功。");
                break;

            case "Stop":
                _groupBuyService.Stop(loginUser.SellerSysNo, loginUser.UserDisplayName, batchInfo.Ids);
                msg = LanguageHelper.GetText("终止成功。");
                break;

            default:
                break;
            }
            return(Json(msg));
        }
Example #6
0
        /// <summary>
        /// 获取网银用户积分
        /// </summary>
        /// <returns></returns>
        public double GetBankUserPoint(string customerCode)
        {
            double result = 0;

            //构造请求数据
            NameValueCollection postData = new NameValueCollection();

            //添加公共请求头部
            AddCommonParameter(postData);

            //积分查询请求参数
            postData.Add("CLIENT_NO", customerCode);
            string praraStr = Partners.BuildStringFromNameValueCollection(postData);

            //发送请求
            string responseData = Partners.HttpPostRequest(Url, praraStr, "application/x-www-form-urlencoded", "UTF-8");

            //解析响应数据
            BankPointResponse data = SerializationUtility.JsonDeserialize <BankPointResponse>(responseData);

            result = data.POINT;


            return(result);
        }
Example #7
0
        /// <summary>
        /// 东方支付商品申报回调
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public string EasiPayDeclareProductBack(NameValueCollection collection)
        {
            try
            {
                #region 写系统Log
                ApplicationEventLog log = new ApplicationEventLog()
                {
                    Source           = "B2C site ProductDeclare",
                    EventType        = 8,
                    HostName         = "B2C",
                    EventTitle       = "ProductDeclare callback",
                    EventMessage     = Charges.BuildStringFromNameValueCollection(collection),
                    LanguageCode     = ConstValue.LanguageCode,
                    CompanyCode      = ConstValue.CompanyCode,
                    StoreCompanyCode = ConstValue.StoreCompanyCode
                };
                CommonDA.CreateApplicationEventLog(log);
                #endregion

                EasiPayProductDeclareBackInfo backResult = SerializationUtility.JsonDeserialize <EasiPayProductDeclareBackInfo>(collection["EData"]);
                var customsInfo = ShoppingOrderDA.LoadVendorCustomsInfoByProduct(backResult.cargoes.FirstOrDefault().cargoCode);

                #region 验证签名
                if (!EasiPaySODeclareBackVerifySign(collection["EData"], customsInfo.CBTProductDeclareSecretKey, collection["SignMsg"]))
                {
                    throw new Exception("商品申报回调,验证签名失败!" + Charges.BuildStringFromNameValueCollection(collection));
                }
                #endregion

                bool             bHandleResult = true;
                var              client        = new Common.RestClient.RestClient(ConstValue.ECCServiceBaseUrl, ConstValue.LanguageCode);
                RestServiceError error;
                object           obj        = new object();
                string           serviceUrl = "/SOService/SO/Job/DeclareProductCallBack";
                client.Query(serviceUrl, backResult.cargoes.ToJsonString(), out obj, out error);
                if (error != null)
                {
                    bHandleResult = false;
                    StringBuilder sb = new StringBuilder();
                    error.Faults.ForEach(e => sb.AppendLine(e.ErrorDescription));

                    if (error.Faults.All(e => e.IsBusinessException))
                    {
                        return(sb.ToString());
                    }
                    ECommerce.Utility.Logger.WriteLog(sb.ToString(), "ProductDeclareCallback", "ProductDeclareCallbackUpdateFailure");
                }
                return(BuildPaymentCallbackReturnResult(111, bHandleResult));
            }
            catch (Exception ex)
            {
                //系统异常,写日志
                ECommerce.Utility.Logger.WriteLog(string.Format("系统异常,异常信息:{0}!", ex.ToString()), "ProductDeclareCallback", "ProductDeclareBgCallbackFailure");
                return(BuildPaymentCallbackReturnResult(111, false));
            }
        }
Example #8
0
        public ActionResult SetSecondDomain()
        {
            SecondDomainInfo secondDomain = SerializationUtility.JsonDeserialize <SecondDomainInfo>(Request.Form["data"]);

            secondDomain.SecondDomainStatus = SecondDomainStatus.ToAudit;
            secondDomain.SysNo = UserAuthHelper.GetCurrentUser().SellerSysNo;
            var success = UserService.SetSecondDomain(secondDomain);

            return(Json(new { Success = success, Msg = success ? LanguageHelper.GetText("操作成功") : LanguageHelper.GetText("操作失败,请稍候再试") }));
        }
Example #9
0
        public JsonResult AjaxRefundBatchConfirm()
        {
            var        sysnoListData = Request["SysNoList"];
            List <int> sysNoList     = SerializationUtility.JsonDeserialize <List <int> >(sysnoListData);
            LoginUser  user          = EntityConverter <UserAuthVM, LoginUser> .Convert(UserAuthHelper.GetCurrentUser());

            var data = DoBatchAction(sysNoList, user, RMARefundService.Confirm);

            return(Json(data));
        }
Example #10
0
        public override void GetResponseUserInfo(PartnerBackContext context)
        {
            //第一步,获取AccessToken
            NameValueCollection postData = new NameValueCollection();

            postData.Add("client_id", context.PassportInfo.Parnter.AppID);
            postData.Add("client_secret", context.PassportInfo.Parnter.AppSecret);
            postData.Add("grant_type", "authorization_code");
            postData.Add("code", context.ResponseParam["code"]);
            postData.Add("redirect_uri", SpecialUrlEncode(BuildActionUrl(context.PassportInfo.Base.BaseUrl, context.PassportInfo.Parnter.LoginBackUrl)));
            string responseData = HttpPostRequest(context.PassportInfo.Parnter.AccessTokenUrl
                                                  , BuildStringFromNameValueCollection(postData)
                                                  , "application/x-www-form-urlencoded"
                                                  , context.PassportInfo.Parnter.Encoding);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取AccessToken响应数据:{0}", responseData), "PassportSinaWeibo", "GetAccessToken");
            }

            SinaWeiboAccessToken returnData = SerializationUtility.JsonDeserialize <SinaWeiboAccessToken>(responseData);

            if (returnData == null)
            {
                throw new BusinessException("登录失败!");
            }

            //第二步,获取用户信息
            string requestParam = string.Format("access_token={0}&uid={1}",
                                                returnData.access_token,
                                                returnData.uid
                                                );

            responseData = HttpGetRequest(string.Format("{0}?{1}", context.PassportInfo.Parnter.GetUserInfoUrl, requestParam)
                                          , context.PassportInfo.Parnter.Encoding);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取User响应数据:{0}", responseData), "PassportSinaWeibo", "GetUserInfo");
            }
            SinaWeiboUserInfo userInfo = SerializationUtility.JsonDeserialize <SinaWeiboUserInfo>(responseData);

            context.CustomerID    = string.Format("SinaWeibo_{0}", userInfo.id);
            context.CustomerName  = userInfo.screen_name;
            context.CustomerSouce = Enums.CustomerSourceType.Sina;
        }
        public ActionResult ComboSubmit()
        {
            ComboInfo info      = SerializationUtility.JsonDeserialize <ComboInfo>(Request.Form["data"]);
            var       loginUser = UserAuthHelper.GetCurrentUser();

            info.Status        = ComboStatus.WaitingAudit;
            info.SellerSysNo   = loginUser.SellerSysNo;
            info.InUserSysNo   = loginUser.UserSysNo;
            info.InUserName    = loginUser.UserDisplayName;
            info.EditUserSysNo = loginUser.UserSysNo;
            info.EditUserName  = loginUser.UserDisplayName;
            if (info.SysNo > 0)
            {
                _comboService.Update(info);
            }
            else
            {
                _comboService.Create(info);
            }
            return(JsonSuccess(info.SysNo, LanguageHelper.GetText("提交审核成功。")));
        }
Example #12
0
        public override void GetResponseUserInfo(PartnerBackContext context)
        {
            int    rdm = (new Random()).Next(100000);
            string kuajingtongUserID = context.ResponseParam["kjt_user_id"];

            NameValueCollection param = new NameValueCollection();

            param["method"]       = HttpUtility.UrlEncode("user.getInfo");
            param["version"]      = HttpUtility.UrlEncode("1.0");
            param["appId"]        = HttpUtility.UrlEncode(context.PassportInfo.Parnter.AppID);
            param["timestamp"]    = GetNowTime2Timestamp();
            param["nonce"]        = rdm.ToString();
            param["kjt_user_id"]  = kuajingtongUserID;
            context.ResponseParam = param;

            string requestParam = string.Format("method={0}&version={1}&appId={2}&timestamp={3}&nonce={4}&kjt_user_id={5}&sign={6}",
                                                HttpUtility.UrlEncode("user.getInfo"), HttpUtility.UrlEncode("1.0"),
                                                HttpUtility.UrlEncode(context.PassportInfo.Parnter.AppID),
                                                GetNowTime2Timestamp(), rdm,
                                                kuajingtongUserID, SignData(context));
            string requestUrl            = string.Format("{0}?{1}", context.PassportInfo.Parnter.GetUserInfoUrl, requestParam);
            string responseData          = HttpGetRequest(requestUrl, context.PassportInfo.Parnter.Encoding);
            KuajingtongReturnData entity = SerializationUtility.JsonDeserialize <KuajingtongReturnData>(responseData);

            if (entity == null || entity.err_code.Equals("1") || !entity.err_code.Equals("0"))
            {
                Logger.WriteLog(string.Format("获取跨境通用户信息失败,原始数据:{0}", responseData), "PassportKuajingtong", "GetUserInfo");
                throw new BusinessException("用户不存在!");
            }

            context.CustomerID    = string.Format("Kuajingtong_{0}", entity.id);
            context.CustomerName  = entity.username;
            context.Email         = entity.email;
            context.IsAuth        = entity.is_real_auth;
            context.CustomerSouce = Enums.CustomerSourceType.Kuajingtong;
        }
Example #13
0
        /// <summary>
        /// 申报商品
        /// </summary>
        /// <param name="decalreList">待申报商品列表,必须是同一个商家,不能超过10个商品</param>
        /// <returns></returns>
        public DeclareProductResult DeclareProduct(List <WaitDeclareProduct> decalreList)
        {
            DeclareProductResult result = new DeclareProductResult();

            //检查是否有数据
            if (decalreList == null || decalreList.Count <= 0)
            {
                return(result);
            }
            var group = decalreList.GroupBy(d => d.MerchantSysNo);

            //检查数据是否满足要求
            if (group.Count() > 1 || decalreList.Count > 10)
            {
                throw new BizException("待申报商品列表,必须是同一个商家,不能超过10个商品");
            }
            //获取商家取关务对接相关信息
            VendorCustomsInfo customsInfo = SODA.LoadVendorCustomsInfoByMerchant(decalreList.FirstOrDefault().MerchantSysNo);
            //获取待申报商品详细信息
            List <ProductDeclare> dataList = ObjectFactory <IIMBizInteract> .Instance.DeclareGetProduct(decalreList);

            #region 构造请求参数
            EasiPayRequestDeclareProduct requestInfo = new EasiPayRequestDeclareProduct();
            requestInfo.version      = AppSettingManager.GetSetting("SO", "EasiPayDeclareProductConfigVersion");
            requestInfo.commitTime   = DateTime.Now.ToString("yyyyMMddHHmmss");
            requestInfo.coName       = customsInfo.CBTMerchantName;
            requestInfo.coCode       = customsInfo.CBTSRC_NCode;
            requestInfo.serialNumber = this.CreateSerialNumber(requestInfo.coCode);
            requestInfo.Cargoes      = EntityConverter <ProductDeclare, EasiPayRequestDeclareProductDetail> .Convert(dataList, (s, t) =>
            {
                t.cargoCode        = s.ProductID;
                t.cargoBrand       = s.BrandName;
                t.cargoNameCh      = s.ProductName;
                t.cargoNameEh      = s.ProductNameEN;
                t.cargoModel       = s.ProductMode;
                t.cargoSpec        = s.Specifications;
                t.cargoPlace       = s.CountryName;
                t.cargoFunction    = s.Functions;
                t.cargoPurpose     = s.Purpose;
                t.cargoIngredient  = s.Component;
                t.cargoFactoryDate = s.ManufactureDate.ToString("yyyyMMdd");
                t.cargoUnit        = s.TaxUnit;
                t.cargoUnitNum     = s.TaxQty.ToString();
                t.cargoPrice       = s.CurrentPrice.ToString("F2");
                t.cargoGrossWT     = s.GrossWeight;
                t.cargoNetWT       = s.SuttleWeight;
                t.serverType       = s.BizType == TradeType.FTA ? "S02" : "S01";
                t.customsCode      = s.CustomsCode;
                t.copGNo           = s.ProductSKUNO;
                t.materialID       = s.SuppliesSerialNo;
                t.beianUnit        = s.ApplyUnit;
                t.beianQty         = s.ApplyQty.ToString();
            });

            requestInfo.operationCode = "1";
            requestInfo.spt           = "";
            #endregion
            #region 3.处理请求,解析请求结果
            string reqContent       = BuildPostReqData(requestInfo, customsInfo.CBTProductDeclareSecretKey);
            string note             = string.Empty;
            string strRequestResult = HttpPostRequest(AppSettingManager.GetSetting("SO", "EasiPayDeclareProductConfigRequestUrl"), reqContent);
            strRequestResult = CommonUtility.HttpUrlDecode(strRequestResult);
            EasiPayRequestResult requestResult = SerializationUtility.JsonDeserialize <EasiPayRequestResult>(strRequestResult);
            if (requestResult.status.ToLower().Equals("success"))
            {
                result.Success = true;
                try
                {
                    ObjectFactory <IIMBizInteract> .Instance.ProductBatchEntry(decalreList.Select(t => t.ProductSysNo).ToList(), "", ProductEntryStatus.Entry, ProductEntryStatusEx.Customs);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                }
                note = "商品报关申请成功";
            }
            else
            {
                result.Message = requestResult.msg;
                note           = "商品报关申请失败:" + requestResult.msg;
            }
            #region 写系统Log
            ApplicationEventLog log = new ApplicationEventLog()
            {
                Source           = "JOB ProductDeclare",
                ReferenceIP      = ServiceContext.Current.ClientIP,
                EventType        = 8,
                HostName         = "JOB",
                EventTitle       = "ProductDeclare Request",
                EventMessage     = reqContent,
                LanguageCode     = "zh-CN",
                CompanyCode      = "8601",
                StoreCompanyCode = "8601",
                EventDetail      = note
            };
            ObjectFactory <ICommonBizInteract> .Instance.CreateApplicationEventLog(log);

            #endregion
            #endregion
            return(result);
        }
Example #14
0
        /// <summary>
        /// 申报订单
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool DeclareSO(WaitDeclareSO entity)
        {
            bool result = false;

            #region 0.先进行支付申报,申报成功再执行订单申报
            if (!this.DeclarePayment(entity))
            {
                return(result);
            }
            #endregion

            #region 1.单笔值计算
            DeclareOrderInfo  declareOrderInfo = SODA.DeclareGetOrderInfoBySOSysNo(entity.SOSysNo);
            VendorCustomsInfo customsInfo      = SODA.LoadVendorCustomsInfo(entity.SOSysNo);
            PayType           payType          = ObjectFactory <ICommonBizInteract> .Instance.GetPayTypeByID(declareOrderInfo.PayTypeID);

            if (declareOrderInfo == null || declareOrderInfo.SOItemList == null || declareOrderInfo.SOItemList.Count == 0)
            {
                return(result);
            }
            decimal allCargoTotalPrice = 0m;
            string  cargoDescript      = "";
            decimal totalTariffAmount  = 0m;
            decimal otherPrice         = Math.Abs(declareOrderInfo.Amount.PrepayAmt) * -1;
            List <EasiPayRequestDeclareOrderCargoes> cargoesList = new List <EasiPayRequestDeclareOrderCargoes>();

            foreach (var item in declareOrderInfo.SOItemList)
            {
                cargoDescript     += (string.IsNullOrEmpty(cargoDescript) ? "" : ";") + (item.ProductName.Replace("#", "").Replace("%", "").Replace("&", "").Replace("+", "") + "描述");
                totalTariffAmount += item.TariffAmt * item.Quantity;
                item.ProductName   = item.ProductName.Replace("#", "").Replace("%", "").Replace("&", "").Replace("+", "");
                //折扣除不尽时,把多余的作为OtherPrice上送
                decimal currOtherPrice = Math.Abs(item.DiscountAmt) % item.Quantity;
                otherPrice += currOtherPrice * -1;
                //Item上是商品本身的价格,需要排除折扣
                decimal unitPrice = item.OriginalPrice - ((Math.Abs(item.DiscountAmt) - currOtherPrice) / item.Quantity);
                unitPrice           = decimal.Parse(unitPrice.ToString("F2"));
                otherPrice         += Math.Abs(item.PromotionDiscount * item.Quantity) * -1;
                allCargoTotalPrice += unitPrice * item.Quantity;
                cargoesList.Add(new EasiPayRequestDeclareOrderCargoes()
                {
                    cargoName       = item.ProductName,
                    cargoCode       = item.EntryCode,
                    cargoNum        = item.Quantity,
                    cargoUnitPrice  = decimal.Parse(unitPrice.ToString("F2")),
                    cargoTotalPrice = decimal.Parse((unitPrice * item.Quantity).ToString("F2")),
                    cargoTotalTax   = decimal.Parse((item.TariffAmt * item.Quantity).ToString("F2"))
                });
            }
            //积分支付作为其他金额报关
            otherPrice += Math.Abs(declareOrderInfo.Amount.PointPay * 1.00m / 100.00m) * -1;
            #endregion

            #region 2.构造请求业务数据
            int serialNumber = SODA.CreateSODeclareRecordsSysNo();
            EasiPayRequestDeclareOrder requestInfo = new EasiPayRequestDeclareOrder();
            requestInfo.version           = AppSettingManager.GetSetting("SO", "EasiPayDeclareOrderConfigVersion");
            requestInfo.commitTime        = DateTime.Now.ToString("yyyyMMddHHmmss");
            requestInfo.coName            = customsInfo.CBTMerchantName;
            requestInfo.coCode            = customsInfo.CBTSRC_NCode;
            requestInfo.MerchantSecretKey = customsInfo.CBTSODeclareSecretKey;
            requestInfo.serialNumber      = serialNumber.ToString();
            requestInfo.merchantOrderId   = entity.SOSysNo.ToString();
            requestInfo.assBillNo         = entity.TrackingNumber;
            requestInfo.orderCommitTime   = declareOrderInfo.OrderDate.ToString("yyyyMMddHHmmss");
            //发件信息,从Appsetting配置中取(改为从仓库表中读取 by cavin 2014-12-02)
            //仓库编号
            //string warehouseNumber = declareOrderInfo.SOItemList[0].WarehouseNumber.Trim();
            requestInfo.senderName        = declareOrderInfo.senderName;        //AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderName", warehouseNumber));
            requestInfo.senderTel         = declareOrderInfo.senderTel;         // AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderTel", warehouseNumber));
            requestInfo.senderCompanyName = declareOrderInfo.senderCompanyName; // AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderCompanyName", warehouseNumber));
            requestInfo.senderAddr        = declareOrderInfo.senderAddr;        // AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderAddr", warehouseNumber));
            requestInfo.senderZip         = declareOrderInfo.senderZip;         // AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderZip", warehouseNumber));
            requestInfo.senderCity        = declareOrderInfo.senderCity;        // AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderCity", warehouseNumber));
            requestInfo.senderProvince    = declareOrderInfo.senderProvince;    // AppSettingManager.GetSetting("SO", string.Format("EasiPayDeclareOrderConfig_Sender_{0}_SenderProvince", warehouseNumber));
            //发件地国家,需要适配三位国家代码
            requestInfo.senderCountry      = declareOrderInfo.SOItemList.FirstOrDefault().CountryCode;
            requestInfo.cargoDescript      = string.IsNullOrEmpty(cargoDescript) ? "无商品信息简述" : cargoDescript;
            requestInfo.allCargoTotalPrice = decimal.Parse(allCargoTotalPrice.ToString("F2"));
            requestInfo.allCargoTotalTax   = decimal.Parse(totalTariffAmount.ToString("F2"));
            requestInfo.expressPrice       = decimal.Parse(declareOrderInfo.Amount.ShipPrice.ToString("F2"));
            requestInfo.otherPrice         = decimal.Parse(otherPrice.ToString("F2"));
            requestInfo.recPerson          = string.IsNullOrWhiteSpace(declareOrderInfo.ReceiveName) ? "无" : declareOrderInfo.ReceiveName;
            requestInfo.recPhone           = string.IsNullOrWhiteSpace(declareOrderInfo.ReceiveCellPhone) ? "无" : declareOrderInfo.ReceiveCellPhone;
            requestInfo.recCountry         = "中国";
            requestInfo.recProvince        = string.IsNullOrWhiteSpace(declareOrderInfo.ReceiveProvinceName) ? "无" : declareOrderInfo.ReceiveProvinceName;
            requestInfo.recCity            = string.IsNullOrWhiteSpace(declareOrderInfo.ReceiveCityName) ? "无" : declareOrderInfo.ReceiveCityName;
            requestInfo.recAddress         = string.IsNullOrWhiteSpace(declareOrderInfo.ReceiveAddress) ? "无" : declareOrderInfo.ReceiveAddress;
            //为空
            requestInfo.recZip        = "";
            requestInfo.serverType    = declareOrderInfo.StockType == BizEntity.Common.TradeType.FTA ? "S02" : "S01";
            requestInfo.custCode      = declareOrderInfo.CustomsCode;
            requestInfo.operationCode = AppSettingManager.GetSetting("SO", "EasiPayDeclareOrderConfigOperationCode");
            //为空
            requestInfo.spt             = "";
            requestInfo.cargoes         = cargoesList;
            requestInfo.payMethod       = AppSettingManager.GetSetting("SO", "EasiPayDeclareOrderConfigPayMethod");
            requestInfo.payMerchantName = payType.CBTMerchantName;
            requestInfo.payMerchantCode = payType.CBTMerchantCode;
            //支付总金额=全部商品合计总价+税费+物流运费+其他金额(其他金额为负数)-余额支付金额
            requestInfo.payAmount = decimal.Parse((allCargoTotalPrice + totalTariffAmount + declareOrderInfo.Amount.ShipPrice + otherPrice).ToString("F2"));
            requestInfo.payCUR    = customsInfo.PayCurrencyCode;
            requestInfo.payID     = string.IsNullOrWhiteSpace(declareOrderInfo.PayInfo.SerialNumber) ? "" : declareOrderInfo.PayInfo.SerialNumber.Substring(1).Trim();//因为支付有个前缀P
            requestInfo.payTime   = declareOrderInfo.PayInfo.PayProcessTime.Trim();
            #endregion

            #region 3.处理请求,解析请求结果
            SOLogInfo soLogInfo = new SOLogInfo()
            {
                UserSysNo     = 3025,
                IP            = "Delcare SO Job",
                OperationType = ECCentral.BizEntity.Common.BizLogType.Sale_SO_Update,
                SOSysNo       = entity.SOSysNo,
                Note          = "",
                CompanyCode   = "8601"
            };
            string reqContent       = BuildPostReqData(requestInfo, requestInfo.MerchantSecretKey);
            string strRequestResult = HttpPostRequest(AppSettingManager.GetSetting("SO", "EasiPayDeclareOrderConfigRequestUrl"), reqContent);
            strRequestResult = CommonUtility.HttpUrlDecode(strRequestResult);
            EasiPayRequestResult requestResult = SerializationUtility.JsonDeserialize <EasiPayRequestResult>(strRequestResult);
            if (requestResult.status.ToLower().Equals("success"))
            {
                result         = true;
                soLogInfo.Note = "订单报关申报提交成功";
            }
            else
            {
                soLogInfo.Note = string.Format("订单报关申报提交失败:{0}", requestResult.errorMsg);
            }
            ObjectFactory <ISOLogDA> .Instance.InsertSOLog(soLogInfo);

            #region 写系统Log
            ApplicationEventLog log = new ApplicationEventLog()
            {
                Source           = "JOB SODeclare",
                ReferenceIP      = ServiceContext.Current.ClientIP,
                EventType        = 8,
                HostName         = "JOB",
                EventTitle       = "SODeclare Request",
                EventMessage     = reqContent,
                LanguageCode     = "zh-CN",
                CompanyCode      = "8601",
                StoreCompanyCode = "8601",
                EventDetail      = soLogInfo.Note,
            };
            ObjectFactory <ICommonBizInteract> .Instance.CreateApplicationEventLog(log);

            #endregion
            #endregion

            #region 4.提交申报申请成功,创建申报记录
            if (result)
            {
                SODeclareRecords declareRecord = new SODeclareRecords()
                {
                    SysNo          = serialNumber,
                    SOSysNo        = entity.SOSysNo,
                    TrackingNumber = entity.TrackingNumber
                };
                SODA.CreateSODeclareRecords(declareRecord);
            }
            #endregion

            return(result);
        }
Example #15
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);
        }
Example #16
0
        /// <summary>
        /// 获取第三方登录回调用户信息
        /// </summary>
        /// <param name="context">第三方登录回调上下文</param>
        /// <exception cref="ECommerce.Utility.BusinessException">
        /// 登录失败!
        /// or
        /// </exception>
        public override void GetResponseUserInfo(PartnerBackContext context)
        {
            //第一步,获取AccessToken
            NameValueCollection data = new NameValueCollection();

            data.Add("client_id", context.PassportInfo.Parnter.AppID);
            data.Add("client_secret", context.PassportInfo.Parnter.AppSecret);
            data.Add("grant_type", "authorization_code");
            data.Add("code", context.ResponseParam["code"]);
            data.Add("redirect_uri", SpecialUrlEncode(BuildActionUrl(context.PassportInfo.Base.BaseUrl, context.PassportInfo.Parnter.LoginBackUrl)));

            string tokenResult = string.Empty;
            string tokenURL    = string.Format("{0}?{1}", context.PassportInfo.Parnter.AccessTokenUrl, BuildStringFromNameValueCollection(data));

            HttpHelper.Get(tokenURL, out tokenResult);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取AccessToken响应数据:{0}", tokenResult), "PassportTencentQQ", "AccessToken");
            }

            //"access_token=7A16EECB7F4904A1D7ACF851E4B283C7&expires_in=7776000&refresh_token=BC5FC164D418609ED26DDE16F8DA5EFF"
            NameValueCollection nvc = HttpUtility.ParseQueryString(tokenResult);

            context.ResponseParam["access_token"] = nvc["access_token"];

            //第二步,用AccessToken获取OpenID

            string returnData = string.Empty;
            string opidURL    = string.Format("{0}?access_token={1}", context.PassportInfo.Parnter.OpenIDUrl, context.ResponseParam["access_token"]);

            HttpHelper.Get(opidURL, out returnData);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取OpenID响应数据:{0}", returnData), "PassportTencentQQ", "GetOpenID");
            }

            //PC网站接入时,获取到用户OpenID,返回包如下:
            //callback( {"client_id":"YOUR_APPID","openid":"YOUR_OPENID"} );
            string pattern   = "callback\\(\\s*{\\s*\"client_id\"\\s*:\\s*\"(?<client_id>\\w+)\"\\s*,\\s*\"openid\"\\s*:\\s*\"(?<openid>\\w+)\"\\s*}\\s*\\)";
            var    match     = Regex.Match(returnData, pattern);
            string client_id = string.Empty;
            string openid    = string.Empty;

            if (match != null)
            {
                client_id = match.Groups["client_id"].Value;
                openid    = match.Groups["openid"].Value;
            }
            else
            {
                Logger.WriteLog(string.Format("获取OpenID失败,{0}", returnData), "PassportTencentQQ", "GetOpenID");
                throw new BusinessException("登录失败!");
            }

            //第三步,获取用户信息
            string requestParam = string.Format("access_token={0}&oauth_consumer_key={1}&openid={2}",
                                                context.ResponseParam["access_token"],
                                                context.PassportInfo.Parnter.AppID,
                                                openid
                                                );

            string userInfoURL  = string.Format("{0}?{1}", context.PassportInfo.Parnter.GetUserInfoUrl, requestParam);
            string responseData = string.Empty;

            HttpHelper.Get(userInfoURL, out responseData);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取User响应数据:{0}", responseData), "PassportTencentQQ", "GetUserInfo");
            }

            TencentQQUserInfo userInfo = SerializationUtility.JsonDeserialize <TencentQQUserInfo>(responseData);

            if (userInfo.ret != 0)
            {
                throw new BusinessException(string.Format("登录失败! {0}", userInfo.msg));
            }

            context.CustomerID    = string.Format("TencentQQ_{0}", openid);
            context.CustomerName  = userInfo.nickname;
            context.CustomerSouce = CustomerSourceType.TencentQQ;
        }
Example #17
0
        public string EasiPaySODeclareBack(NameValueCollection collection)
        {
            try
            {
                #region 写系统Log
                ApplicationEventLog log = new ApplicationEventLog()
                {
                    Source           = "B2C site SODeclare",
                    EventType        = 8,
                    HostName         = "B2C",
                    EventTitle       = "SODeclare callback",
                    EventMessage     = Charges.BuildStringFromNameValueCollection(collection),
                    LanguageCode     = ConstValue.LanguageCode,
                    CompanyCode      = ConstValue.CompanyCode,
                    StoreCompanyCode = ConstValue.StoreCompanyCode
                };
                CommonDA.CreateApplicationEventLog(log);
                #endregion

                EasiPaySODeclareBackInfo backResult = SerializationUtility.JsonDeserialize <EasiPaySODeclareBackInfo>(collection["EData"]);
                int SOSysNo     = int.Parse(backResult.merchantOrderId);
                int status      = 0;
                var customsInfo = ShoppingOrderDA.LoadVendorCustomsInfo(SOSysNo);

                #region 验证签名
                if (!EasiPaySODeclareBackVerifySign(collection["EData"], customsInfo.CBTSODeclareSecretKey, collection["SignMsg"]))
                {
                    throw new Exception("订单申报回调,验证签名失败!" + Charges.BuildStringFromNameValueCollection(collection));
                }
                #endregion

                bool bHandleResult = true;
                var  client        = new Common.RestClient.RestClient(ConstValue.ECCServiceBaseUrl, ConstValue.LanguageCode);
                ECommerce.Facade.Common.RestClient.RestServiceError error;
                string serviceUrl = "";

                if (backResult.status.Equals("1"))
                {
                    //成功
                    status     = 10;
                    serviceUrl = "/SOService/SO/UpdateSOStatusToReported";
                    client.Update(serviceUrl, backResult.merchantOrderId, out error);
                    if (error != null)
                    {
                        bHandleResult = false;
                        StringBuilder sb = new StringBuilder();
                        error.Faults.ForEach(e => sb.AppendLine(e.ErrorDescription));

                        if (error.Faults.All(e => e.IsBusinessException))
                        {
                            return(sb.ToString());
                        }
                        ECommerce.Utility.Logger.WriteLog(sb.ToString(), "SODeclareCallback", "SODeclareBgCallbackUpdateFailure");
                    }
                    if (ShoppingOrderDA.GetOrderTradeType(int.Parse(backResult.merchantOrderId)) == TradeType.DirectMail)
                    {
                        //如果是直邮订单,直接完成通关操作
                        serviceUrl = "/SOService/SO/BatchOperationUpdateSOStatusToCustomsPass";
                        client.Update(serviceUrl, new List <int> {
                            int.Parse(backResult.merchantOrderId)
                        }, out error);
                        if (error != null)
                        {
                            bHandleResult = false;
                            StringBuilder sb = new StringBuilder();
                            error.Faults.ForEach(e => sb.AppendLine(e.ErrorDescription));

                            if (error.Faults.All(e => e.IsBusinessException))
                            {
                                return(sb.ToString());
                            }
                            ECommerce.Utility.Logger.WriteLog(sb.ToString(), "SODeclareCallback", "SODeclareBgCallbackUpdateFailure");
                        }
                    }
                }
                else
                {
                    //失败
                    status = -10;
                    object obj = new object();
                    serviceUrl = "/SOService/SO/UpdateSOStatusToReject";
                    client.Update(serviceUrl, backResult.merchantOrderId, out obj, out error);
                    if (error != null)
                    {
                        bHandleResult = false;
                        StringBuilder sb = new StringBuilder();
                        error.Faults.ForEach(e => sb.AppendLine(e.ErrorDescription));

                        if (error.Faults.All(e => e.IsBusinessException))
                        {
                            return(sb.ToString());
                        }
                        ECommerce.Utility.Logger.WriteLog(sb.ToString(), "SODeclareCallback", "SODeclareBgCallbackUpdateFailure");
                    }
                }
                if (bHandleResult)
                {
                    ShoppingOrderDA.UpdateDeclareRecordsStatus(SOSysNo, status);
                }

                return(BuildPaymentCallbackReturnResult(111, bHandleResult));
            }
            catch (Exception ex)
            {
                //系统异常,写日志
                ECommerce.Utility.Logger.WriteLog(string.Format("系统异常,异常信息:{0}!", ex.ToString()), "SODeclareCallback", "SODeclareBgCallbackFailure");
                return(BuildPaymentCallbackReturnResult(111, false));
            }
        }