public void OrderPaymentLogistic(OrderPaymentLogistics logistic, CBFnOnlinePayment payment, LgDeliveryType deliveryType) { logistic.logisticsName = deliveryType.DeliveryTypeName; logistic.paymentName = payment.PaymentName; logistic.paymentNo = payment.VoucherNo; logistic.paymentType = "A"; }
void BindOrderHeadData(SoOrder order, OrderHead head, CBFnOnlinePayment payment, SoReceiveAddress srenity, string buyer_idcard, string District, string City, string Province, WhWarehouse warehouseMod, BsArea wareDistrictEntity, BsArea wareCityEntity, BsArea wareProvinceEntity) { head.cbeCode = config2.CIECode; head.cbeName = config2.CIEName; head.ecpCode = config2.CIECode; head.ecpName = config2.CIEName; head.orderNo = payment.BusinessOrderSysNo; head.charge = order.OrderAmount; head.goodsValue = order.ProductAmount; head.freight = order.FreightAmount; head.other = 0; head.tax = order.TaxFee; head.currency = "142"; head.customer = srenity.Name; head.shipper = warehouseMod.Contact; head.shipperAddress = wareProvinceEntity.AreaName + " " + wareCityEntity.AreaName + " " + wareDistrictEntity.AreaName + " " + warehouseMod.StreetAddress; head.shipperTelephone = warehouseMod.Phone; head.consignee = srenity.Name; head.consigneeAddress = Province + " " + City + " " + District + " " + srenity.StreetAddress; head.consigneeTelephone = srenity.MobilePhoneNumber; head.idType = "1"; head.customerId = srenity.IDCardNo; head.accessType = "1"; head.ieType = "I"; head.modifyMark = "1"; head.appTime = DateTime.Now.ToString("yyyyMMddHHmmss"); head.appStatus = "2"; }
/// <summary> /// 绑定订单信息 /// </summary> /// <param name="order"></param> /// <param name="orderMod"></param> void BindCusOrderData(SoOrder order, Model.Icp.GZNanSha.Order.CustomOrderMod orderMod) { CBFnOnlinePayment payment = Hyt.BLL.Finance.FinanceBo.Instance.GetOnPaymentBySourceSysNo(order.SysNo); orderMod.EntInsideNo = payment.BusinessOrderSysNo;//order.SysNo.ToString();//"SO"+order.SysNo.ToString().PadLeft(8,'0'); orderMod.Ciqbcode = SLDW; orderMod.CbeComcode = ERCI; orderMod.CbepComcode = ERCI; orderMod.OrderStatus = "S"; orderMod.ReceiveName = order.ReceiveAddress.Name; orderMod.ReceiveAddr = (order as Hyt.Model.Manual.SoOrderMods).ReceiverProvince + " " + (order as Hyt.Model.Manual.SoOrderMods).ReceiverCity + " " + (order as Hyt.Model.Manual.SoOrderMods).ReceiverArea + " " + order.ReceiveAddress.StreetAddress; orderMod.ReceiveNo = order.ReceiveAddress.IDCardNo; orderMod.ReceivePhone = order.ReceiveAddress.MobilePhoneNumber; orderMod.FCY = order.ProductAmount; orderMod.Fcode = "CNY"; orderMod.Editccode = ERCI; orderMod.DrDate = order.CreateDate.ToString("yyyyMMddHHmmss"); }
/// <summary> /// 添加交易订单 /// </summary> /// <param name="orderSysno"></param> /// <returns>2016-09-07 杨浩 创建</returns> public override Result AddOrderTrade(int orderSysno) { var result = new Result <string>(); result.Status = true; result.StatusCode = 0; result.Message = "接口调用成功"; if (orderSysno <= 0) { return(result); } try { var orderInfo = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno); CBFnOnlinePayment payment = FinanceBo.Instance.GetOnPaymentBySourceSysNo(orderInfo.SysNo); CrCustomer customer = Hyt.BLL.CRM.CrCustomerBo.Instance.GetModel(orderInfo.CustomerSysNo); var order = new AddWuZhouRequest(); order.item_list = new List <Item_Lists>(); var pager = new Pager <AddWuZhouRequest>() { PageSize = 999999, CurrentPage = 1 }; //pager = Hyt.BLL.ApiLogistics.WuZhou.WuZhouBll.PdProductBo.Instance.GetWuZhouList(pager); IList <CBSoOrderItem> datao = SoOrderBo.Instance.GetCBOrderItemsByOrderId(orderInfo.SysNo); orderInfo.OrderItemList = new List <SoOrderItem>(); List <int> ProSysNo = new List <int>(); foreach (CBSoOrderItem item in datao) { ProSysNo.Add(item.ProductSysNo); orderInfo.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; } } SoReceiveAddress srenity = Hyt.BLL.Order.OutboundReturnBo.Instance.GetSoReceiveAddressBysoOrderSysNo(orderSysno); #region 订单信息 order.outer_code = orderSysno.ToString(); order.goods_total = orderInfo.OrderAmount; order.order_pay = orderInfo.OrderAmount; order.logis_pay = orderInfo.FreightAmount; order.favourable = orderInfo.CouponAmount; order.item_count = 0; order.ebp_account = customer.Account; order.buyer_name = customer.Name; order.buyer_idtype = 1; order.buyer_idnumber = customer.IDCardNo; order.buyer_tel = customer.MobilePhoneNumber; order.consignee = srenity.Name; order.consignee_postcode = srenity.ZipCode; order.consignee_tel = srenity.MobilePhoneNumber; order.consignee_province = srenity.AreaSysNo.ToString(); order.consignee_city = srenity.AreaSysNo.ToString(); order.consignee_district = srenity.AreaSysNo.ToString(); order.consignee_addr = srenity.StreetAddress; order.consignee_email = srenity.EmailAddress; order.ebc_code = ""; order.ebp_code = ""; order.pay_code = ""; order.payment_no = ""; order.is_ordermsg = 1; order.is_paymsg = 1; order.is_logismsg = 1; order.is_invtmsg = 1; order.express_name = ""; order.logis_num = ""; order.note = orderInfo.Remarks; #endregion //循环商品信息 foreach (var item in datao) { var productInfo = productList.Where(x => x.SysNo == item.ProductSysNo).FirstOrDefault(); if (productInfo == null) { result.Status = false; result.StatusCode = 1; result.Message = "产品系统编号【" + item.ProductSysNo + "】在系统中不存在"; return(result); } var orderItem = new Item_Lists(); orderItem.sku_code = item.TransactionSysNo; orderItem.chcus_sku = item.ProductSysNo.ToString(); orderItem.sku_price = item.SalesUnitPrice; orderItem.qty = item.Quantity; orderItem.total = item.SalesUnitPrice; orderItem.discount = 0; orderItem.note = orderInfo.DeliveryRemarks; order.item_list.Add(orderItem); } //Dictionary<string, string> dicKeyList = new Dictionary<string, string>(); //dicKeyList.Add("outer_code", orderSysno.ToString()); //ERP的合作者帐号 string partner = ""; //由ERP分配 string send_key = ""; //ERP的外部接口帐号 string interface_id = ""; //请求业务 string method = "neworder"; //将数组装换为json格式 var orders = Hyt.Util.Serialization.JsonUtil.EntityToJson(order); //进行md5加密 string md5 = MD5Encrypt(orders + send_key).ToLower(); //进行Base64编码 string base64 = EncodeBase64(md5); //进行url编码 string sign = UrlEncode(base64); //请求参数 string requiredParameter = "/" + method + "/?partner=" + partner + "&interface_id=" + interface_id + "&sign=" + sign + "&content=" + orders + ""; //请求地址 string requestUrl = "ht"; //完整参数 string url = requestUrl + requiredParameter; string testData = MyHttp.GetResponse(url, orders, "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 = "", SoOrderSysNo = orderSysno, } ); string express = postResult.courierCode + "_" + postResult.mailNo; BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.跨境物流推送状态.成功, 3, orderInfo.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); }
/// <summary> /// 导出excel数据 /// </summary> /// <param name="orderSysNos">订单编号</param> public override void OutPutExcelData(List <int> orderSysNos) { List <SoOrder> orderList = SoOrderBo.Instance.GetAllOrderBySysNos(string.Join(",", orderSysNos.ToArray())); List <CBSoOrderItem> items = SoOrderItemBo.Instance.GetCBOrderItemListBySysNos(string.Join(",", orderSysNos.ToArray())); List <CBFnOnlinePayment> fnPayments = Hyt.BLL.Finance.FinanceBo.Instance.GetOnlinePaymentList(string.Join(",", orderSysNos.ToArray())); List <CBSoReceiveAddress> soOrderAddressList = SoOrderBo.Instance.GetOrderReceiveAddressByList(string.Join(",", orderSysNos.ToArray())); List <OutPutOrderExcelData> dataList = new List <OutPutOrderExcelData>(); foreach (var mod in orderList) { List <CBSoOrderItem> tempOrderItems = items.FindAll(p => p.OrderSysNo == mod.SysNo); CBFnOnlinePayment tempPayment = fnPayments.Find(p => p.SourceSysNo == mod.SysNo); CBSoReceiveAddress tempAddress = soOrderAddressList.Find(p => p.SysNo == mod.ReceiveAddressSysNo); if (tempPayment != null) { CBWhWarehouse warehouse = Hyt.BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(mod.DefaultWarehouseSysNo); int indx = 0; foreach (var itemMod in tempOrderItems) { indx++; OutPutOrderExcelData tempMod = new OutPutOrderExcelData() { 订单编号 = tempPayment.BusinessOrderSysNo, 订单日期 = mod.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), 电商平台代码 = config.CusCode.Trim(), 海关电商平台名称 = config.CusName.Trim(), 电商企业代码 = config.CusCode.Trim(), 海关电商企业名称 = config.CusName.Trim(), 海关电商企业备案号 = config.CusCode.Trim(), 电商企业智检备案号 = config.ICPCode.Trim(), 电商平台企业智检备案号 = config.ICPCode.Trim(), 电商平台域名 = "http://www.gaopin999.com/", 支付企业代码 = config.PayCode, 支付企业名称 = config.PayName, 支付交易编号 = tempPayment.VoucherNo, 订单商品货款 = mod.ProductAmount.ToString("0.00"), 订单运费 = mod.FreightAmount.ToString("0.00"), 优惠减免金额 = mod.ProductChangeAmount.ToString("0.00"), 订单商品税款 = mod.TaxFee.ToString("0.00"), 实际支付金额 = mod.OrderAmount.ToString("0.00"), 币制 = "142", 订购人注册号 = "", 订购人姓名 = tempAddress.Name, 订购人证件类型 = "1", 订购人证件号码 = tempAddress.IDCardNo, 订购人电话 = tempAddress.MobilePhoneNumber, 商品批次号 = "", 其它费用 = "", 备注note = "", 物流订单号 = tempPayment.BusinessOrderSysNo, 商品序号 = indx.ToString(), 商品智检货号 = itemMod.ErpCode, 企业商品海关货号 = itemMod.ErpCode, 主要商品描述 = "http://www.gaopin999.com/Product/Details/" + itemMod.ProductSysNo, 申报数量 = itemMod.Quantity.ToString(), 单价 = ((itemMod.SalesAmount + itemMod.ChangeAmount) / itemMod.Quantity).ToString("0.00"), 总价 = (itemMod.SalesAmount + itemMod.ChangeAmount).ToString("0.00"), 销售网址 = "http://www.gaopin999.com/Product/Details/" + itemMod.ProductSysNo, 收货人名称 = tempAddress.Name, 收件人证件类型 = "1", 收件人证件号 = tempAddress.IDCardNo, 收货人电话 = tempAddress.MobilePhoneNumber, 收货人地址 = tempAddress.ProvinceName + " " + tempAddress.CityName + " " + tempAddress.CountryName + " " + tempAddress.StreetAddress, 收货人所在国 = "142", 收货人城市 = tempAddress.CityName, 收货人省市区代码 = tempAddress.AreaSysNo.ToString(), 收货人省市区名称 = tempAddress.ProvinceName + " " + tempAddress.CityName + " " + tempAddress.CountryName, 收货人行政区代码 = tempAddress.AreaSysNo.ToString(), 发货人姓名 = warehouse.Contact, 发货人电话 = warehouse.Phone, 发货人地址 = warehouse.ProvinceName + " " + warehouse.CityName + " " + warehouse.AreaName + " " + warehouse.StreetAddress, 发货人城市 = warehouse.CityName, 发货人省市区代码 = warehouse.CitySysNo.ToString(), 发货人省市区名称 = warehouse.ProvinceName + " " + warehouse.CityName + " " + warehouse.AreaName, 发货人所在国 = "142", 运单号 = "", 提运单号 = "", 运费 = mod.FreightAmount.ToString("0.00"), 保费 = "0", 毛重 = itemMod.GrosWeight.ToString("0.00"), 净重 = itemMod.NetWeight.ToString("0.00"), 件数 = itemMod.Quantity.ToString(), 货物总价 = (itemMod.ChangeAmount + itemMod.SalesAmount).ToString("0.00"), 包装种类 = "1", 备注 = "", 平台来源 = config.CusCode.Trim(), 平台编号 = "", 平台简称 = "", 电商平台下商家编码 = "", 商家简称 = "", 申报类型 = "1", 第一法定数量 = itemMod.GrosWeight.ToString("0.00"), 第二法定数量 = itemMod.Quantity.ToString() }; dataList.Add(tempMod); } } } var fileName = string.Format("销售订单({0})", DateTime.Now.ToString("yyyyMMddHHmmss")); //导出Excel,并设置表头列名 Util.ExcelUtil.ExportSoOrders <OutPutOrderExcelData>(dataList, new List <string> { "用户编号", "用户名称", "报文发送者ID", "订单类型", "订单编号", "订单日期", "电商平台代码", "海关电商平台名称", "电商企业代码", "海关电商企业名称", "海关电商企业备案号", "电商企业备案号(智检)", "电商平台企业备案号(智检)", "电商平台域名", "支付企业代码(海关备案号)", "支付企业名称", "支付交易编号", "订单商品货款", "运费", "优惠减免金额", "优惠抵扣说明", "订单商品税款", "实际支付金额", "币制", "订购人注册号", "订购人姓名", "订购人证件类型", "订购人证件号码", "订购人电话", "商品批次号", "其它费用", "备注(Notes)", "物流订单号", "商品序号(Seq)", "商品货号(智检)", "企业商品货号(海关)", "主要商品描述", "申报数量", "单价", "总价(Total)", "销售网址", "收货人名称", "收件人证件类型", "收件人证件号", "收货人电话", "收货人地址", "收货人所在国", "收货人城市", "收货人省市区代码", "收货人省市区名称", "收货人行政区代码", "发货人姓名", "发货人电话", "发货人地址", "发货人城市", "发货人省市区代码", "发货人省市区名称", "发货人所在国", "运单号", "提运单号", "运费", "保费", "毛重", "净重", "件数", "货物总价", "包装种类", "备注", "平台来源(填写平台备案号)", "平台编号", "平台简称", "电商平台下商家编码", "商家简称", "申报类型", "第一法定数量", "第二法定数量" }, fileName); SysLog.Instance.WriteLog(LogStatus.SysLogLevel.Info, LogStatus.系统日志来源.后台, "销售订单导出excel", LogStatus.系统日志目标类型.ExcelExporting, 0, null, "", 1); }
/// <summary> /// 获取快递单号 /// </summary> /// <param name="orderId"></param> /// <returns></returns> /// <remarks>2016-9-3 杨浩 创建</remarks> private Result GetExpressno(string orderId) { var config = Hyt.BLL.Config.Config.Instance.GetGaoJieConfig(); var result = new Result <SoOrderSyncLogisticsLog>(); var orderInfo = BLL.Order.SoOrderBo.Instance.GetEntity(int.Parse(orderId)); WhWarehouse warehouseMod = Hyt.BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(orderInfo.DefaultWarehouseSysNo); BsArea wareDistrictEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(warehouseMod.AreaSysNo); BsArea wareCityEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(wareDistrictEntity.ParentSysNo); SoReceiveAddress srenity = Hyt.BLL.Order.OutboundReturnBo.Instance.GetSoReceiveAddressBysoOrderSysNo(orderInfo.SysNo); string buyer_idcard = ""; if (!string.IsNullOrEmpty(srenity.IDCardNo)) { buyer_idcard = srenity.IDCardNo.Trim(); } 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(orderInfo.SysNo); IList <CBSoOrderItem> datao = SoOrderBo.Instance.GetCBOrderItemsByOrderId(orderInfo.SysNo); string goods_Names = ""; int goods_Nums = 0; decimal goods_Weight = 0; foreach (var mod in datao) { if (!string.IsNullOrEmpty(goods_Names)) { goods_Names += ","; } goods_Names += mod.ProductName; goods_Nums += mod.Quantity; goods_Weight += mod.GrosWeight; } StringBuilder strorder = new StringBuilder();//"{\"orderSn\":\"" + orderInfo.OrderNo + "\"}"; strorder.Append("{"); strorder.Append(" \"order_sn\":\"" + orderInfo.OrderNo + "\","); strorder.Append(" \"send_name\":\"" + warehouseMod.Contact + "\","); strorder.Append(" \"send_telno\":\"" + warehouseMod.Phone + "\","); strorder.Append(" \"send_cardno\":\"\","); strorder.Append(" \"send_postcode\":\"\","); strorder.Append(" \"send_code\":\"1\","); strorder.Append(" \"receive_name\":\"" + srenity.Name + "\","); strorder.Append(" \"receive_telno\":\"" + srenity.MobilePhoneNumber + "\","); strorder.Append(" \"receive_cardno\":\"" + srenity.IDCardNo + "\","); strorder.Append(" \"receive_postcode\":\"\","); strorder.Append(" \"receive_province\":\"" + Province + "\","); strorder.Append(" \"receive_city\":\"" + City + "\","); strorder.Append(" \"receive_area\":\"" + District + "\","); strorder.Append(" \"receive_address\":\"" + Province + " " + City + " " + District + " " + srenity.StreetAddress + "\","); strorder.Append(" \"goods_name\":\"" + goods_Names + "\","); strorder.Append(" \"goods_sku\":\"\","); strorder.Append(" \"goods_num\":\"" + goods_Nums + "\","); strorder.Append(" \"notes\":\"\","); strorder.Append(" \"weight\":\"" + goods_Weight + "\""); strorder.Append("}"); string enStrorder = ""; enStrorder = EncodeBase64(EncodeBase64(strorder.ToString())); string strPost = "&seller=" + EncodeBase64(config.seller) + "&api_key=" + EncodeBase64(config.api_key) + "&express=" + EncodeBase64("3") + "&order_type=" + EncodeBase64("1") + "&order=" + enStrorder; var strResult = GetResponse(expressUrl, strPost); var json = JObject.Parse(strResult); string jsons = json.ToString(); result.Message = json.ToString(); /*{ * "orderSn": "So00003784", * "state": "success", * "expressNo": "50323423506251", * "expressCode": "3", * "destinationCode": "粤-肇庆", * "nodeCode": { * "pkgCode": "广州夏良转运中心", * "billProvideSiteName": "广州新花山站", * "billProvideSiteCode": "Z04" * } * }*/ //string destinationCode = ""; //string pkgCode = ""; ; //string billProvideSiteCode = ""; //string expressNo = ""; //if (json["state"].ToString().ToLower() == "success") //{ // destinationCode = json["destinationCode"].ToString(); // pkgCode = json["nodeCode"]["pkgCode"].ToString(); // billProvideSiteCode = json["nodeCode"]["billProvideSiteCode"].ToString(); // expressNo = json["expressNo"].ToString(); //} ///订单物流信息 SoOrderSyncLogisticsLog soLogisticsLogMod = new SoOrderSyncLogisticsLog(); soLogisticsLogMod.OrderSysNo = orderInfo.SysNo; soLogisticsLogMod.Code = (int)this.Code; try { soLogisticsLogMod.LogisticsOrderId = json["express_no"].ToString(); } catch { } soLogisticsLogMod.StatusCode = json["flag"].ToString(); try { soLogisticsLogMod.StatusMsg = json["express_notes"].ToString(); } catch { try { soLogisticsLogMod.StatusMsg = json["info"].ToString(); } catch { } } soLogisticsLogMod.Packets = strorder.ToString(); soLogisticsLogMod.ReceiptContent = strResult; soLogisticsLogMod.CreateDate = DateTime.Now; soLogisticsLogMod.LastUpdateDate = DateTime.Now; SoOrderSyncLogisticsLogBo.Instance.Insert(soLogisticsLogMod); if (json["flag"].ToString().ToUpper() == "OK") { result.Status = true; result.StatusCode = 100; result.Data = soLogisticsLogMod; } else { result.Status = false; result.StatusCode = 0; result.Data = soLogisticsLogMod; } return(result); }
public override Result AddOrderTrade(int orderSysno) { //throw new NotImplementedException(); List <SoOrderSyncLogisticsLog> logList = SoOrderSyncLogisticsLogBo.Instance.GetModelList(orderSysno); List <SoOrderSyncLogisticsLog> haveLogisticsList = logList.Where(p => p.Code == (int)this.Code && p.StatusCode == "OK" && !string.IsNullOrEmpty(p.LogisticsOrderId)).ToList(); SoOrderSyncLogisticsLog nowLogistics = null; if (haveLogisticsList.Count == 0) { Result expressResult = GetExpressno(orderSysno.ToString()); nowLogistics = (expressResult as Result <SoOrderSyncLogisticsLog>).Data; if (!expressResult.Status) { return(expressResult); } } else { nowLogistics = haveLogisticsList[0]; } var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno); var config = Hyt.BLL.Config.Config.Instance.GetGaoJieConfig(); var result = new Result <string>(); 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); SoReceiveAddress srenity = Hyt.BLL.Order.OutboundReturnBo.Instance.GetSoReceiveAddressBysoOrderSysNo(order.SysNo); string buyer_idcard = ""; if (!string.IsNullOrEmpty(srenity.IDCardNo)) { buyer_idcard = srenity.IDCardNo.Trim(); } 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); IList <CBSoOrderItem> datao = SoOrderBo.Instance.GetCBOrderItemsByOrderId(order.SysNo); List <int> ProSysNo = new List <int>(); foreach (CBSoOrderItem item in datao) { ProSysNo.Add(item.ProductSysNo); } IList <CBPdProduct> productList = Hyt.BLL.Product.PdProductBo.Instance.GetProductInfoList(ProSysNo); decimal goodsGweight = 0; foreach (var mod in productList) { goodsGweight += mod.GrosWeight; } LgGaoJiePushInfo model = new LgGaoJiePushInfo(); string strorder = ""; strorder += "{\"order_sn\":\"" + order.OrderNo + "\",\"pfreight_no\":\"\",\"express_num\":\"" + nowLogistics.LogisticsOrderId + "\","; strorder += "\"sender_name\":\"" + warehouseMod.Contact + "\",\"sender_city\":\"" + wareCityEntity.AreaName + "\",\"sender_address\":\"" + warehouseMod.StreetAddress + "\","; strorder += "\"sender_phone\":\"" + warehouseMod.Phone + "\",\"sender_country_code\":\"" + wareCityEntity.AreaCode + "\","; strorder += "\"buyer_name\":\"" + srenity.Name + "\",\"buyer_idcard\":\"" + buyer_idcard + "\",\"buyer_phone\":\"" + srenity.MobilePhoneNumber + "\","; strorder += "\"province_code\":\"" + ProvinceEntity.AreaCode + "" + "\",\"buyer_address\":\"" + Province + "^^^" + City + "^^^" + District + "^^^" + srenity.StreetAddress + "\","; strorder += "\"curr\":\"502" + "\",\"pkg_gweight\":" + goodsGweight + ",\"p_name\":\"" + (payment == null ? "" : payment.PaymentName) + "\",\"p_no\":\"" + (payment == null ? "" : payment.VoucherNo) + "\","; strorder += "\"p_time\":\"" + (payment == null ? DateTime.Now.ToString("yyyy-mm-dd hh :MM") : payment.CreatedDate.ToString("yyyy-mm-dd hh :MM")) + "\",\"sh_fee\":\"" + order.FreightAmount.ToString() + "\","; strorder += "\"cus_tax\":\"" + order.TaxFee.ToString() + "\",\"pweb\":\"" + config.pweb + "\",\"web_name\":\"" + config.web_name + "\",\"re_no\":\"" + config.re_no + "\",\"re_name\":\"" + config.re_name + "\","; strorder += "\"order_goods\":"; strorder += "["; string str = ""; int i = 0; foreach (CBSoOrderItem item in datao) { //LgGaoJieGoodsInfo goodsInfo = LogisticsBo.Instance.GetLgGaoJieGoodsInfoEntityByPid(item.ProductSysNo); List <CBPdProduct> tempProductList = productList.Where(p => p.SysNo == item.ProductSysNo).ToList(); var originInfo = BLL.Basic.OriginBo.Instance.GetEntity(tempProductList[0].OriginSysNo); var brandInfo = BLL.Product.PdBrandBo.Instance.GetEntity(tempProductList[0].BrandSysNo); string ycg_code = originInfo != null ? originInfo.CusOriginNO : ""; if (i > 0) { str += ",{"; } else { str += "{"; } str += "\"goods_ptcode\":\"" + tempProductList[0].ProductDeclare; str += "\",\"goods_name\":\"" + tempProductList[0].ProductName; str += "\",\"brand\":\"" + brandInfo.Name; str += "\",\"goods_spec\":\"" + tempProductList[0].GrosWeight + "kg"; str += "\",\"goods_num\":\"" + item.Quantity.ToString(); str += "\",\"goods_price\":\"" + item.SalesUnitPrice.ToString(); str += "\",\"ycg_code\":\"" + originInfo.CusOriginNO; str += "\",\"goods_barcode\":\"" + tempProductList[0].Barcode.Trim() + "\""; str += "}"; i++; } strorder += str; strorder += "]}"; string orders = strorder; strorder = EncodeBase64(EncodeBase64(strorder)); var strPost = "&seller=" + EncodeBase64(config.seller) + "&api_key=" + EncodeBase64(config.api_key) + "&mark=" + EncodeBase64("order") + "&confirm=" + EncodeBase64("2") + "&order=" + strorder; var strResult = GetResponse(url, strPost); var json = JObject.Parse(strResult); string jsons = json.ToString(); result.Status = true; result.Data = json.ToString(); var soOrderSyncLogisticsLog = new SoOrderSyncLogisticsLog(); soOrderSyncLogisticsLog.OrderSysNo = orderSysno; soOrderSyncLogisticsLog.Code = (int)this.Code; soOrderSyncLogisticsLog.CreateDate = DateTime.Now; soOrderSyncLogisticsLog.CreatedBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo; soOrderSyncLogisticsLog.LastUpdateBy = 0; soOrderSyncLogisticsLog.LastUpdateDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; soOrderSyncLogisticsLog.Packets = orders.ToString(); soOrderSyncLogisticsLog.ReceiptContent = json.ToString(); soOrderSyncLogisticsLog.LogisticsOrderId = ""; //var model = new LgGaoJiePushInfo(); //model.OrderSysNo = orderSysno; //model.OrderInfo = orders.ToString(); ////保存订单回执信息 //model.ReturnInfo = json.ToString(); ////保存推送回执信息 //LogisticsBo.Instance.InsertLgGaoJiePushInfoEntity(model, BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base); string state = json["flag"].ToString().ToLower(); //推送成功 if (state == "ok" || json["info"].ToString() == "重复下单") { result.Status = true; result.Message = json["info"].ToString(); soOrderSyncLogisticsLog.StatusCode = ""; soOrderSyncLogisticsLog.StatusMsg = result.Message; //更新物流状态CBLogisticsSendStatus BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.跨境物流推送状态.已推送, 3, orderSysno); } else { result.Status = false; result.Message = json["info"].ToString(); soOrderSyncLogisticsLog.StatusCode = ""; soOrderSyncLogisticsLog.StatusMsg = result.Message; BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.跨境物流推送状态.失败, 3, orderSysno); } SoOrderSyncLogisticsLogBo.Instance.Insert(soOrderSyncLogisticsLog); return(result); }
public override Model.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); LgDeliveryType deliveryType = Hyt.BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo); 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; } } Order pushOrder = new Order(); pushOrder.OrderHead = new OrderHead(); pushOrder.OrderPaymentLogistics = new OrderPaymentLogistics(); pushOrder.itemList = new List <OrderList>(); BindOrderHeadData(order, pushOrder.OrderHead, payment, srenity, buyer_idcard, District, City, Province, warehouseMod, wareDistrictEntity, wareCityEntity, wareProvinceEntity); BindOrderItemListData(datao, pushOrder.itemList); OrderPaymentLogistic(pushOrder.OrderPaymentLogistics, payment, deliveryType); string str = Hyt.Util.Serialization.SerializationUtil.XmlSerialize <Order>(pushOrder); str = str.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\""); str = str.Replace("Root", "ROOT"); str = str.Replace("<itemList>", ""); str = str.Replace("</itemList>", ""); FtpUtil ftp = new FtpUtil(config2.RequestUrl, config2.Account, config2.Password); string msg = ""; string fileName = DateTime.Now.ToString("yyyyMMddhhmmssffff") + ".xml"; try { ftp.UploadFile(config2.RequestUrl, fileName, Encoding.UTF8.GetBytes(str), out msg); } catch (Exception ex) { result.Status = false; result.Message = ex.Message; } result.Message = str; } catch (Exception e) { result.Status = false; result.Message = e.Message; } return(result); }
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); }