/// <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)); } }
/// <summary> /// 作废订单,调用ECCservice进行作废 /// </summary> /// <param name="orderSysNo">订单编号</param> /// <param name="message"></param> /// <param name="userSysNo"></param> /// <returns>如果返回的空字符串则作废成功,否则显示返回的字符串</returns> public static string VoidedOrder(int orderSysNo, string message, int userSysNo) { var orderInfo = CustomerFacade.GetCenterSODetailInfo(userSysNo, orderSysNo); if (orderInfo == null) { throw new BusinessException("订单不存在"); } if (orderInfo.HoldMark) { throw new BusinessException("订单已被锁定不能作废。如有疑问,请联系客服人员。"); } var client = new Common.RestClient.RestClient(ConstValue.ECCServiceBaseUrl, ConstValue.LanguageCode); var serviceUrl = "/SOService/SO/Abandon"; RestServiceError error; client.Update(serviceUrl, new { IsCreateAO = false, ImmediatelyReturnInventory = false, SOSysNoList = new List <int> { orderSysNo } }, out error); if (error != null) { var sb = new StringBuilder(); error.Faults.ForEach(e => sb.AppendLine(e.ErrorDescription)); if (error.Faults.All(e => e.IsBusinessException)) { return(sb.ToString()); } throw new ApplicationException(sb.ToString()); } CustomerDA.InsertSOLog(userSysNo, CommonFacade.GetIP(), orderSysNo, message, 201); //将作废的订单的SOSysNo保存到Cookies中 var values = CookieHelper.GetCookie <List <int> >(ConstValue.Cookie_Name_VoidedOrder); if (values != null) { values.Add(orderSysNo); } else { values = new List <int>(); values.Add(orderSysNo); } CookieHelper.SaveCookie <List <int> >(ConstValue.Cookie_Name_VoidedOrder, values); return(""); }
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)); } }