public override Result CancelOrderTrade(int orderSysNo, string reason = "") { Result result = new Result(); try { var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysNo); var config = Hyt.BLL.Config.Config.Instance.GetAnnaConfig(); CBFnOnlinePayment payment = FinanceBo.Instance.GetOnPaymentBySourceSysNo(order.SysNo); CancelOrder cancelOreder = new CancelOrder(); cancelOreder.storeCode = config.WhNumber; cancelOreder.orderType = "TRANS"; cancelOreder.orderCode = payment.BusinessOrderSysNo; cancelOreder.reason = reason; Dictionary <string, string> dicKeyList = new Dictionary <string, string>(); dicKeyList.Add("notifyId", DateTime.Now.ToString("yyMMddHHmmssffff")); dicKeyList.Add("notifyTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dicKeyList.Add("format", "json"); dicKeyList.Add("signMethod", "md5"); dicKeyList.Add("busiType", "alog.order.cancel"); dicKeyList.Add("partnerCode", config.OnNumber); dicKeyList.Add("ownerCode", config.OnNumber); dicKeyList.Add("content", JsonUtil.ToJson(cancelOreder));// dicKeyList["content"] = dicKeyList["content"].Replace("\"courierCode\":null,", ""); Dictionary <string, string> dic1Asc1 = (from d in dicKeyList orderby d.Key ascending select d).ToDictionary(k => k.Key, v => v.Value); string strParams = ""; foreach (string key in dic1Asc1.Keys) { if (!string.IsNullOrEmpty(strParams)) { strParams += "&"; } strParams += key + "=" + dic1Asc1[key]; } string sign = Hyt.Util.Security.UserMd5(config.secretKey + strParams.Replace("&", "").Replace("=", "") + config.secretKey).ToUpper(); strParams = "sign=" + sign + "&" + strParams; string testData = MyHttp.GetResponse(config.URLPath, strParams, "utf-8"); PosDataResult postResult = JsonUtil.ToObject <PosDataResult>(testData); if (postResult.success) { string msg = ""; //SoOrderBo.Instance.CancelSoOrder(orderSysNo, BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo, OrderStatus.销售单作废人类型.后台用户, //ref msg, reason); result.Status = postResult.success; result.Message = "取消成功"; } else { result.Status = postResult.success; result.Message = testData; } } catch (Exception e) { result.Status = false; result.Message = e.Message; } return(result); }
public override Result AddOrderTrade(int orderSysno) { Result result = new Result(); try { var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno); var config = Hyt.BLL.Config.Config.Instance.GetAnnaConfig(); CrCustomer customer = Hyt.BLL.CRM.CrCustomerBo.Instance.GetModel(order.CustomerSysNo); WhWarehouse warehouseMod = Hyt.BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo); BsArea wareDistrictEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(warehouseMod.AreaSysNo); BsArea wareCityEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(wareDistrictEntity.ParentSysNo); BsArea wareProvinceEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(wareDistrictEntity.ParentSysNo); SoReceiveAddress srenity = Hyt.BLL.Order.OutboundReturnBo.Instance.GetSoReceiveAddressBysoOrderSysNo(order.SysNo); string buyer_idcard = ""; if (!string.IsNullOrEmpty(srenity.IDCardNo)) { buyer_idcard = srenity.IDCardNo.Trim().ToUpper(); } BsArea DistrictEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(srenity.AreaSysNo); string District = DistrictEntity.AreaName.Trim(); BsArea CityEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(DistrictEntity.ParentSysNo); string City = CityEntity.AreaName.Trim(); BsArea ProvinceEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(CityEntity.ParentSysNo); string Province = ProvinceEntity.AreaName.Trim(); CBFnOnlinePayment payment = FinanceBo.Instance.GetOnPaymentBySourceSysNo(order.SysNo); payment.CusPaymentCode = config.PaymentCode; IList <CBSoOrderItem> datao = SoOrderBo.Instance.GetCBOrderItemsByOrderId(order.SysNo); order.OrderItemList = new List <SoOrderItem>(); List <int> ProSysNo = new List <int>(); foreach (CBSoOrderItem item in datao) { ProSysNo.Add(item.ProductSysNo); order.OrderItemList.Add(item); } IList <CBPdProduct> productList = Hyt.BLL.Product.PdProductBo.Instance.GetProductInfoList(ProSysNo); foreach (var mod in productList) { var tempitem = datao.First(p => p.ProductSysNo == mod.SysNo); if (tempitem != null) { tempitem.OrginCountry = Hyt.BLL.Basic.OriginBo.Instance.GetEntity(mod.OriginSysNo).Origin_Name; } } OrderShip orderShip = new OrderShip(); orderShip.storeCode = config.WhNumber; orderShip.orderCode = payment.BusinessOrderSysNo;//order.OrderNo; orderShip.orderType = "TRANS"; orderShip.createTime = order.CreateDate.ToString("yyy-MM-dd hh:mm:ss"); orderShip.checker = order.AuditorSysNo.ToString(); orderShip.checkTime = order.AuditorDate.ToString("yyy-MM-dd hh:mm:ss"); orderShip.payTime = payment.CreatedDate.ToString("yyy-MM-dd hh:mm:ss"); orderShip.sourcePlatformCode = "ZY"; orderShip.sourceOrderCode = order.SysNo.ToString(); orderShip.receiver = new Receiver() { receiverAddress = srenity.StreetAddress.Replace("\n", "").Replace("\r", ""), receiverProvince = Province.Replace("\n", "").Replace("\r", ""), receiverCity = City.Replace("\n", "").Replace("\r", ""), receiverDistrict = District.Replace("\n", "").Replace("\r", ""), receiverCountry = "中国", receiverIdNumber = buyer_idcard, receiverName = srenity.Name, receiverMobile = srenity.MobilePhoneNumber, receiverPhone = srenity.PhoneNumber }; orderShip.invoiceFlag = "N"; orderShip.codFlag = "N"; orderShip.gotAmount = order.OrderAmount; orderShip.arAmount = order.OrderAmount; orderShip.insuranceFlag = "N"; orderShip.orderTotalAmount = order.ProductAmount + order.TaxFee + order.FreightAmount + order.ProductChangeAmount; orderShip.orderActualAmount = order.OrderAmount; orderShip.totalAmount = order.OrderAmount; orderShip.orderGoodsAmount = order.ProductAmount + order.ProductChangeAmount; orderShip.feeAmount = order.FreightAmount; orderShip.orderTaxAmount = order.TaxFee; orderShip.payEntNo = payment.CusPaymentCode; orderShip.payEnterpriseName = payment.PaymentName;//"支付宝(中国)网络技术有限公司"; orderShip.recipientProvincesCode = "440000"; var deliverTypeInfo = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo); if (deliverTypeInfo != null && string.IsNullOrWhiteSpace(deliverTypeInfo.OverseaCarrier) || deliverTypeInfo == null) { orderShip.courierCode = config.CourierCode; } else { orderShip.courierCode = deliverTypeInfo.OverseaCarrier; } string importType = ""; if (warehouseMod.WarehouseType == 30) { importType = "BBC"; } else if (warehouseMod.WarehouseType == 40) { importType = "BC"; } orderShip.buyerId = customer.Account; orderShip.importType = importType; orderShip.portload = "142"; orderShip.items = new List <Items>(); int rowIndex = 0; foreach (var item in datao) { rowIndex++; item.SalesUnitPrice = ((item.SalesAmount + item.ChangeAmount) / item.Quantity); orderShip.items.Add(new Items() { actualPrice = item.SalesUnitPrice, barCode = item.BarCode, discountAmount = item.DiscountAmount, inventoryType = "ZP", itemCode = item.ErpCode, itemName = item.ProductName.Replace("+", ""), orderLineNo = rowIndex.ToString(), originCountry = item.OrginCountry, quantity = item.Quantity, retailPrice = item.OriginalPrice, subOrderCode = item.SysNo.ToString(), supplierCode = config.supplierCode, supplierName = config.supplierName, weight = Convert.ToInt32((item.NetWeight * 1000)) }); } orderShip.sender = new Sender() { senderAddress = warehouseMod.StreetAddress.Trim(), senderProvince = wareProvinceEntity.AreaName.Trim(), senderCity = wareCityEntity.AreaName.Trim(), senderDistrict = wareDistrictEntity.AreaName.Trim(), senderCountry = "中国", senderName = config.SenderUser.Trim(), senderMobile = warehouseMod.Phone, senderPhone = warehouseMod.Phone, senderIdNumbe = config.SenderIdNumber }; Dictionary <string, string> dicKeyList = new Dictionary <string, string>(); dicKeyList.Add("notifyId", DateTime.Now.ToString("yyMMddHHmmssffff")); dicKeyList.Add("notifyTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dicKeyList.Add("format", "json"); dicKeyList.Add("signMethod", "md5"); dicKeyList.Add("busiType", "alog.ordership.notify"); dicKeyList.Add("partnerCode", config.OnNumber); dicKeyList.Add("ownerCode", config.OnNumber); dicKeyList.Add("content", JsonUtil.ToJson(orderShip));// dicKeyList["content"] = dicKeyList["content"].Replace("\"courierCode\":null,", ""); Dictionary <string, string> dic1Asc1 = (from d in dicKeyList orderby d.Key ascending select d).ToDictionary(k => k.Key, v => v.Value); string strParams = ""; foreach (string key in dic1Asc1.Keys) { if (!string.IsNullOrEmpty(strParams)) { strParams += "&"; } strParams += key + "=" + dic1Asc1[key]; } string sign = Hyt.Util.Security.UserMd5(config.secretKey + strParams.Replace("&", "").Replace("=", "") + config.secretKey).ToUpper(); strParams = "sign=" + sign + "&" + strParams; string testData = MyHttp.GetResponse(config.URLPath, strParams, "utf-8"); //{"success":true,"errCode":"","errMsg":"","courierCode":"SF","mailNo":"444746031132"} PosDataResult postResult = JsonUtil.ToObject <PosDataResult>(testData); if (postResult.success) { Hyt.BLL.CrossBorderLogistics.CrossBorderLogisticsOrderBo.Instance.InsertEntity( new CrossBorderLogisticsOrder() { ExpressNo = postResult.courierCode + "_" + postResult.mailNo, LogisticsCode = 0, LogisticsOrderId = strParams, SoOrderSysNo = orderSysno, } ); string express = postResult.courierCode + "_" + postResult.mailNo; BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.跨境物流推送状态.成功, 3, order.SysNo); result.Status = postResult.success; } else { result.Status = postResult.success; result.Message = testData; } }catch (Exception e) { result.Status = false; result.Message = e.Message; } return(result); }