Esempio n. 1
0
        /// <summary>
        /// 获取运单号
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        /// <remarks>2016-07-19 陈海裕 创建</remarks>
        public override Result GetOrderExpressno(string orderId)
        {
            Result <string> result = new Result <string>();

            result.Status     = false;
            result.StatusCode = 0;
            result.Message    = "接口调用失败";
            string url = RequestUrl + "express/create";

            try
            {
                SoOrder order = BLL.Order.SoOrderBo.Instance.GetEntity(TConvert.ToInt32(orderId));
                if (order == null)
                {
                    result.Message = "该订单不存在";
                    return(result);
                }
                LgDeliveryType          deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);
                ParaOnlinePaymentFilter filter       = new ParaOnlinePaymentFilter();
                filter.OrderSysNo = TConvert.ToInt32(orderId);
                var           onlinePayment = BLL.Finance.FinanceBo.Instance.GetOnlinePayments(filter).Rows.Where(o => o.Status == 1).FirstOrDefault();
                CBWhWarehouse warehouse     = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                string        _deliveryType = "";
                if (deliveryType.DeliveryTypeName.Contains("顺丰"))
                {
                    _deliveryType = "SF";
                    //CustomerCode = SFCustomerCode;
                    //Key = SFKey;
                    Token = SFToken;
                }
                else if (deliveryType.DeliveryTypeName.Contains("中通"))
                {
                    _deliveryType = "ZTO";
                }
                if (_deliveryType == "")
                {
                    result.Message = "友信达物流目前只有支持顺丰和中通两种快递方式";
                    return(result);
                }

                Dictionary <string, string> paramsData = new Dictionary <string, string>();
                paramsData.Add("reference_no", onlinePayment.BusinessOrderSysNo);
                paramsData.Add("warehouse_id", warehouse.LogisWarehouseCode);
                paramsData.Add("sm_code", _deliveryType);
                string responseStr = GetResponse(url, InitParams(paramsData));
                result = GetResult(JObject.Parse(responseStr), result);
                if (result.Status == true)
                {
                    // 生成出库单
                }

                return(result);
            }
            catch (Exception ex)
            {
                result.Message = "查询订单运单号报错:" + ex.StackTrace;
                return(result);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 删除仓库
        /// </summary>
        /// <param name="StockSysNo"></param>
        /// <returns></returns>
        public Extra.Erp.Model.Result ErpStockDelete(int StockSysNo)
        {
            Extra.Erp.Model.Result result = new Model.Result();
            string        actionPath      = "/base/stockDel";
            CBWhWarehouse warehouse       = IWhWarehouseDao.Instance.GetWarehouse(StockSysNo);
            string        postDataPath    = Config.root + actionPath;
            string        posData         = Hyt.Util.MyHttp.GetResponse(postDataPath, "{APP_Key:\"" + Config.APP_Key + "\",APP_scode:\"" + Config.APP_scode + "\", FNumber:\"" + warehouse.ErpRmaCode + "\"}", "utf-8");
            EasResult     easResult       = Hyt.Util.Serialization.JsonUtil.ToObject <EasResult>(posData);

            result.Status  = easResult.success;
            result.Message = easResult.message;
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加或修改仓库
        /// </summary>
        /// <param name="StockSysNo">仓库编号</param>
        /// <param name="ActionType">操作类型,0 添加,1 修改</param>
        /// <returns></returns>
        public Extra.Erp.Model.Result ErpStockAdd(int StockSysNo, int ActionType = 0)
        {
            Extra.Erp.Model.Result result = new Model.Result();
            try
            {
                string actionPath = "/base/stockAdd";
                if (ActionType == 1)
                {
                    actionPath = "/base/stockModi";
                }
                string        postDataPath = Config.root + actionPath;
                CBWhWarehouse warehouse    = IWhWarehouseDao.Instance.GetWarehouse(StockSysNo);
                EasStock      stock        = new EasStock()
                {
                    APP_Key     = Config.APP_Key,
                    APP_scode   = Config.APP_scode,
                    FAddress    = warehouse.ProvinceName + " " + warehouse.CityName + " " + warehouse.AreaName + " " + warehouse.StreetAddress,
                    fdetail     = "1",
                    FFullName   = "[" + StockSysNo + "]" + "[" + warehouse.ErpRmaCode + "]" + warehouse.BackWarehouseName,
                    FFullNumber = "[" + StockSysNo + "]" + warehouse.ErpRmaCode,

                    FName       = warehouse.BackWarehouseName,
                    FNumber     = warehouse.ErpRmaCode,
                    FPhone      = warehouse.Phone,
                    FUnderStock = "1",
                    intType     = ActionType,
                    isParent    = 0
                };
            }
            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);
        }
Esempio n. 5
0
        /// <summary>
        /// 添加交易订单
        /// </summary>
        /// <param name="orderId">销售订单系统编号</param>
        /// <returns></returns>
        /// <remarks>
        /// 2016-3-21 杨浩 创建
        /// 2016-4-19 陈海裕 重构
        /// </remarks>
        public override Result AddOrderTrade(int orderId)
        {
            var result = new Result()
            {
                Status     = false,
                StatusCode = 0,
                Message    = "向" + this.Code + "物流推送订单失败"
            };


            try
            {
                var order = Hyt.BLL.Order.SoOrderBo.Instance.GetEntity(orderId);
                if (order == null)
                {
                    result.Status     = false;
                    result.Message    = string.Format("订单号{0}不存在!", orderId);
                    result.StatusCode = -100;
                }


                #region 旧参数

                //var receiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                //if (receiveAddress == null)
                //{
                //    result.Status = false;
                //    result.Message = string.Format("订单中的收货地址编号{0}不存在!", order.ReceiveAddressSysNo);
                //    result.StatusCode = -101;
                //}
                //var area = BLL.Basic.BasicAreaBo.Instance.GetArea(receiveAddress.AreaSysNo);
                //if (area == null)
                //{
                //    result.Status = false;
                //    result.Message = string.Format("地区({0})不存在!", receiveAddress.AreaSysNo);
                //    result.StatusCode = -103;
                //}
                //var city = BLL.Basic.BasicAreaBo.Instance.GetArea(area.ParentSysNo);
                //if (city == null)
                //{
                //    result.Status = false;
                //    result.Message = string.Format("城市({0})不存在!", area.ParentSysNo);
                //    result.StatusCode = -104;
                //}
                //var province = BLL.Basic.BasicAreaBo.Instance.GetArea(city.ParentSysNo);
                //if (province == null)
                //{
                //    result.Status = false;
                //    result.Message = string.Format("省份({0})不存在!", city.ParentSysNo);
                //    result.StatusCode = -105;
                //}

                //if (!result.Status)
                //    return result;
                //var param = "{\"orderId\":\"" + order.OrderNo + "\",";
                //param += "\"addr\":\"" + receiveAddress.StreetAddress + "\",";
                //param += "\"phone\":\"" + receiveAddress.MobilePhoneNumber + "\",";
                //param += "\"freight\":" + order.FreightAmount + ",";//运费
                //param += "\"orderDate\":\"" + order.CreateDate.ToString("yyyy-MM-dd") + "\",";
                //param += "\"province\":\"" + JsonStrEscape(province.AreaName) + "\",";
                //param += "\"city\":\"" + JsonStrEscape(city.AreaName) + "\",";
                //param += "\"area\":\"" + JsonStrEscape(area.AreaName) + "\",";
                //param += "\"total\":" + order.ProductAmount + ",";//订单总金额
                //param += "\"insuredFee\":0,";  //保价费用
                //param += "\"cardType\":\"0\","; //证件类型 (默认身份证则填0)
                //param += "\"expressCode\":\"SF\","; //物流公司编码
                //param += "\"busiMode\":\"BBC\","; //所属业务模式 (BBC/备货BC/直邮BC/个人物品)
                //param += "\"whCode\":\"FLC\",";   //发货仓库代号
                //param += "\"portCode\":\"5141\","; //口岸编码
                //param += "\"platformCode\":\"IE150604146855\",";//海关企业备案号
                //param += "\"cardNo\":\"" + receiveAddress.IDCardNo + "\",";//顾客身份证
                //param += "\"name\":\"" + JsonStrEscape(receiveAddress.Name) + "\",";
                ////param += "\"senderContact\":\"测试公司\",";
                ////param += "\"senderPhone\":\"13500000000\",";
                ////param += "\"tax\":\"" + orderInfo.TaxFee + "\",";
                //param += "\"orderItemList\":{";
                //param += "\"orderItems\":[";
                //var orderItemList = Hyt.BLL.Web.SoOrderBo.Instance.GetOrderItemListByOrderSysNo(orderId);
                //string orderItem = "";
                //foreach (var item in orderItemList)
                //{
                //    if (orderItem != "")
                //        orderItem += ",";
                //    orderItem += "{";
                //    //8712400110037
                //    //orderItem += "\"qty\":" + item.Quantity + ",\"price\":" + item.SalesUnitPrice + ",\"total\":" + item.SalesAmount + ",\"productId\":\""+item.ErpCode+"\",\"productName\":\"" + JsonStrEscape(item.ProductName) + "\"";
                //    orderItem += "\"qty\":" + item.Quantity + ",\"price\":" + item.SalesUnitPrice + ",\"total\":" + item.SalesAmount + ",\"productId\":\"8712400110136\",\"productName\":\"" + JsonStrEscape(item.ProductName) + "\"";
                //    orderItem += "}";
                //}

                //param += orderItem;
                //param += "]}}";
                #endregion
                string method = "wtdex.trade.order.add";

                order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                //ParaVoucherFilter voucherFilter = new ParaVoucherFilter();
                //voucherFilter.SourceSysNo = order.SysNo;
                //CBFnReceiptVoucher recVoucher = BLL.Finance.FinanceBo.Instance.GetReceiptVouchers(voucherFilter).Rows.FirstOrDefault();
                //recVoucher.VoucherItems = BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(recVoucher.SysNo);


                var filter = new ParaOnlinePaymentFilter();
                filter.OrderSysNo = orderId;
                var onlinePayment = BLL.Finance.FinanceBo.Instance.GetOnlinePayments(filter).Rows.Where(o => o.Status == 1).FirstOrDefault();

                if (onlinePayment == null)
                {
                    result.Message = "订单不存在在线支付记录";
                    return(result);
                }
                // 收货人 区 市 省
                BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                CBWhWarehouse warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                BsArea        shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

                DsDealer dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);



                var newOrder = new WTDOrder();
                newOrder.addr             = TConvert.ToString(order.ReceiveAddress.StreetAddress).Trim();
                newOrder.area             = TConvert.ToString(receiverDistrict.AreaName).Trim();
                newOrder.busiMode         = "BC";
                newOrder.cardNo           = TConvert.ToString(order.ReceiveAddress.IDCardNo);
                newOrder.cardType         = "0";
                newOrder.city             = TConvert.ToString(receiverCity.AreaName).Trim();
                newOrder.consumerAddr     = TConvert.ToString(order.ReceiveAddress.StreetAddress).Trim();
                newOrder.consumerArea     = TConvert.ToString(receiverDistrict.AreaName).Trim();
                newOrder.consumerCity     = TConvert.ToString(receiverCity.AreaName).Trim();
                newOrder.consumerName     = TConvert.ToString(order.ReceiveAddress.Name);
                newOrder.consumerPhone    = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber) ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                newOrder.consumerProvince = TConvert.ToString(receiverProvince.AreaName).Trim();
                newOrder.destCity         = null;
                newOrder.expressCode      = "YT";// "SF";
                newOrder.expressNo        = null;
                newOrder.freight          = (double)order.FreightAmount;
                newOrder.ieFlag           = null;
                newOrder.insuredFee       = 0d;
                newOrder.invoice          = null;
                newOrder.invoiceHead      = null;
                newOrder.invoiceType      = null;
                newOrder.isgac            = 1;
                newOrder.isactpay         = "0";
                newOrder.isactlogistics   = "1";



                newOrder.mobile      = null;
                newOrder.name        = TConvert.ToString(order.ReceiveAddress.Name);
                newOrder.notes       = TConvert.ToString(order.Remarks).Trim();
                newOrder.orderDate   = order.CreateDate.ToString("yyyy-MM-dd");
                newOrder.orderId     = onlinePayment.BusinessOrderSysNo;
                newOrder.paymentCode = null;
                newOrder.phone       = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber) ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;

                newOrder.pickMode      = "0";//BC、PS情况下必填0:散货/包裹1:大货/备货,有货物在我们仓库
                newOrder.platformCode  = config.PlatformCode;
                newOrder.portCode      = config.PortCode;
                newOrder.prodFlag      = null;
                newOrder.province      = TConvert.ToString(receiverProvince.AreaName).Trim();
                newOrder.seller        = null;
                newOrder.senderContact = TConvert.ToString(dealer.ErpName);
                newOrder.senderPhone   = !string.IsNullOrWhiteSpace(dealer.MobilePhoneNumber) ? dealer.MobilePhoneNumber : dealer.PhoneNumber;
                newOrder.tax           = (double)order.TaxFee;
                newOrder.total         = (double)order.ProductAmount;
                //newOrder.total = 100d;
                newOrder.whCode                   = TConvert.ToString(warehouse.LogisWarehouseCode);
                newOrder.zipCode                  = null;
                newOrder.orderItemList            = new WTDOrderItemList();
                newOrder.orderItemList.orderItems = new List <WTDOrderItem>();
                WTDOrderItem orderItem = new WTDOrderItem();
                foreach (var item in order.OrderItemList)
                {
                    var product = BLL.Product.PdProductBo.Instance.GetProductNoCache(item.ProductSysNo);
                    orderItem.groupBarcode = null;
                    orderItem.isGroup      = null;
                    orderItem.postTax      = null;
                    orderItem.price        = (double)item.SalesUnitPrice;
                    orderItem.productId    = product.ErpCode;
                    orderItem.productName  = TConvert.ToString(item.ProductName);
                    orderItem.qty          = item.Quantity;
                    orderItem.total        = (double)item.SalesAmount;
                    newOrder.orderItemList.orderItems.Add(orderItem);
                    //orderItem.groupBarcode = null;
                    //orderItem.isGroup = null;
                    //orderItem.postTax = null;
                    //orderItem.price = 50d;
                    //orderItem.productId = "8712400110136";
                    //orderItem.productName = TConvert.ToString(item.ProductName);
                    //orderItem.qty = 2;
                    //orderItem.total = 100d;
                    //newOrder.orderItemList.orderItems.Add(orderItem);
                    //break;
                }

                string postData = Util.Serialization.JsonUtil.ToJson2(newOrder);
                postData = InitParams(method, postData);

                var _result = Hyt.Util.WebUtil.PostForm(apiUrl, postData);

                result = GetResponseResult(_result);

                if (result.Status == true)
                {
                    var soOrderSyncLogisticsLog = new SoOrderSyncLogisticsLog();

                    soOrderSyncLogisticsLog.OrderSysNo = orderId;
                    soOrderSyncLogisticsLog.Code       = (int)this.Code;

                    soOrderSyncLogisticsLog.LastUpdateDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    soOrderSyncLogisticsLog.StatusCode     = "";
                    soOrderSyncLogisticsLog.StatusMsg      = "";
                    soOrderSyncLogisticsLog.Packets        = postData;
                    soOrderSyncLogisticsLog.ReceiptContent = _result;

                    soOrderSyncLogisticsLog.LastUpdateBy     = 0;
                    soOrderSyncLogisticsLog.LogisticsOrderId = "";

                    soOrderSyncLogisticsLog.CreateDate = DateTime.Now;
                    soOrderSyncLogisticsLog.CreatedBy  = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
                    SoOrderSyncLogisticsLogBo.Instance.Insert(soOrderSyncLogisticsLog);


                    BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus(1, 3, orderId);
                }
            }
            catch (Exception ex)
            {
                result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                return(result);
            }

            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// POS系统减库存(维嘉项目)
        /// </summary>
        /// <param name="orderSysNo"></param>
        /// <param name="orderAmount"></param>
        /// <param name="db_no">单据标示</param>
        /// <remarks>2016-05-20 陈海裕 创建</remarks>
        public void ReducedPOSInventory(int orderSysNo, decimal orderAmount, string db_no = null)
        {
            Result result = new Result();

            try
            {
                SoOrder             order      = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysNo);
                IList <SoOrderItem> orderItems = BLL.Order.SoOrderBo.Instance.GetOrderItemsByOrderId(orderSysNo);
                CBWhWarehouse       warehouse  = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);

                Grand.Platform.Api.Contract.DataContract.LessProductStockRequest request = new Grand.Platform.Api.Contract.DataContract.LessProductStockRequest();

                Grand.Platform.Api.Contract.Model.SheetMaster sheetMaster = new Grand.Platform.Api.Contract.Model.SheetMaster();
                sheetMaster.trans_no  = "00";
                sheetMaster.branch_no = warehouse.ErpCode;
                sheetMaster.oper_date = DateTime.Now;
                sheetMaster.sheet_amt = orderAmount;
                sheetMaster.db_no     = db_no;
                IList <Grand.Platform.Api.Contract.Model.SheetDetail> sheetDetailList = new List <Grand.Platform.Api.Contract.Model.SheetDetail>();
                Grand.Platform.Api.Contract.Model.SheetDetail         sheetDetail     = null;
                foreach (var item in orderItems)
                {
                    sheetDetail = new Grand.Platform.Api.Contract.Model.SheetDetail();
                    var tempProduct = BLL.Product.PdProductBo.Instance.GetProduct(item.ProductSysNo);
                    sheetDetail.item_no     = tempProduct.ErpCode;
                    sheetDetail.real_qty    = item.Quantity;
                    sheetDetail.large_qty   = item.Quantity;
                    sheetDetail.valid_price = item.SalesUnitPrice;
                    sheetDetail.sale_price  = item.OriginalPrice;
                    sheetDetail.sub_amt     = item.SalesAmount;
                    sheetDetailList.Add(sheetDetail);
                }
                request.SheetMaster  = sheetMaster;
                request.SheetDetails = sheetDetailList;

                string json = Util.Serialization.JsonUtil.ToJson2(request);

                result.Status = this.LessProductStock(request);
                if (result.Status == false)
                {
                    var queObj = DataAccess.Extra.IPosServiceDao.Instance.GetEntityByOrderSysNo(orderSysNo);
                    if (queObj == null)
                    {
                        // 扣减库存失败,添加到队列表
                        ReducedPOSInventoryQueue model = new ReducedPOSInventoryQueue();
                        model.OrderSysNo = orderSysNo;
                        model.JsonData   = json;
                        this.AddToReducedPOSInventoryQueue(model);
                    }

                    BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "POS系统减库存失败:ReducedPOSInventory", new Exception());
                }
            }
            catch (Exception ex)
            {
                // 扣减库存失败,添加到队列表
                ReducedPOSInventoryQueue model = new ReducedPOSInventoryQueue();
                model.OrderSysNo = orderSysNo;
                model.Remark     = ex.ToString();
                this.AddToReducedPOSInventoryQueue(model);

                BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "POS系统减库存失败:ReducedPOSInventory", ex);
            }
        }
Esempio n. 7
0
        public override Result AddOrderTrade(int orderSysno)
        {
            Result result = new Result();

            try
            {
                SoOrder order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno);
                if (order == null)
                {
                    result.Message = "该订单不存在";
                    return(result);
                }
                order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                ParaVoucherFilter voucherFilter = new ParaVoucherFilter();
                voucherFilter.SourceSysNo = order.SysNo;
                CBFnReceiptVoucher recVoucher = BLL.Finance.FinanceBo.Instance.GetReceiptVouchers(voucherFilter).Rows.FirstOrDefault();
                recVoucher.VoucherItems = BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(recVoucher.SysNo);
                // 收货人 区 市 省
                BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                CBWhWarehouse warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                BsArea        shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

                DsDealer dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                EasycrossOrder newOrder = new EasycrossOrder();
                newOrder.OrderHead             = new OrderHead();
                newOrder.OrderList             = new List <OrderList>();
                newOrder.OrderPaymentLogistics = new OrderPaymentLogistics();

                newOrder.OrderHead.accessType         = "1";
                newOrder.OrderHead.agentCode          = "4404580006";
                newOrder.OrderHead.agentName          = "珠海易跨境电子商务服务有限公司";
                newOrder.OrderHead.appStatus          = "2";
                newOrder.OrderHead.appTime            = DateTime.Now.ToString("yyyyMMddHHmmss");
                newOrder.OrderHead.appUid             = "1105910159";
                newOrder.OrderHead.appUname           = "东方口岸";
                newOrder.OrderHead.batchNumbers       = "";
                newOrder.OrderHead.cbeCode            = "D00236";
                newOrder.OrderHead.cbeName            = "珠海爱勤电子科技有限公司";
                newOrder.OrderHead.charge             = order.OrderAmount.ToString();
                newOrder.OrderHead.consignee          = order.ReceiveAddress.Name;
                newOrder.OrderHead.consigneeAddress   = order.ReceiveAddress.StreetAddress;
                newOrder.OrderHead.consigneeCountry   = "";
                newOrder.OrderHead.consigneeTelephone = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber)
                    ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                newOrder.OrderHead.currency         = "142";
                newOrder.OrderHead.customer         = order.ReceiveAddress.Name;
                newOrder.OrderHead.customerId       = order.ReceiveAddress.IDCardNo;
                newOrder.OrderHead.ecpCode          = "W0098";
                newOrder.OrderHead.ecpName          = "珠海爱勤电子科技有限公司";
                newOrder.OrderHead.freight          = order.FreightAmount.ToString();
                newOrder.OrderHead.goodsValue       = order.ProductAmount.ToString();
                newOrder.OrderHead.idType           = "1";
                newOrder.OrderHead.ieType           = "I";
                newOrder.OrderHead.modifyMark       = "1";
                newOrder.OrderHead.note             = "";
                newOrder.OrderHead.orderNo          = order.SysNo.ToString();
                newOrder.OrderHead.other            = "";
                newOrder.OrderHead.shipper          = BLL.Stores.StoresBo.Instance.GetStoreById(0).ErpName;
                newOrder.OrderHead.shipperAddress   = "";
                newOrder.OrderHead.shipperCountry   = "142";
                newOrder.OrderHead.shipperTelephone = "";
                newOrder.OrderHead.tax = order.TaxFee.ToString();
                newOrder.OrderHead.totalLogisticsNo = "";
                newOrder.OrderHead.tradeCountry     = "";
                newOrder.OrderHead.wrapType         = "";
                foreach (SoOrderItem item in order.OrderItemList)
                {
                    PdProduct      product      = BLL.Product.PdProductBo.Instance.GetProduct(item.SysNo);
                    PdProductStock productStock = BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(order.DefaultWarehouseSysNo, item.ProductSysNo);

                    string  brandName = "无";
                    PdBrand brand     = BLL.Product.PdBrandBo.Instance.GetEntity(product.BrandSysNo);
                    if (brand != null)
                    {
                        brandName = brand.Name;
                    }

                    OrderList orderList = new OrderList();
                    orderList.barCode        = "";
                    orderList.brand          = brandName;
                    orderList.codeTs         = "";
                    orderList.country        = "";
                    orderList.currency       = "142";
                    orderList.describe       = "";
                    orderList.discount       = "";
                    orderList.giftFlag       = "";
                    orderList.goodsModel     = "";
                    orderList.goodsName      = item.ProductName;
                    orderList.goodsNo        = productStock.ProductSku;
                    orderList.itemNo         = "";
                    orderList.note           = "";
                    orderList.packNum        = "";
                    orderList.price          = item.SalesUnitPrice.ToString();
                    orderList.priceTotal     = item.SalesAmount.ToString();
                    orderList.purposeCode    = "";
                    orderList.quantity       = item.Quantity.ToString();
                    orderList.shelfGoodsName = item.ProductName;
                    orderList.taxCode        = "";
                    orderList.unit           = "007";
                    orderList.wasteMaterials = "1";
                    orderList.wrapType       = "";
                    newOrder.OrderList.Add(orderList);
                }
                //newOrder.OrderPaymentLogistics.logisticsCode = "";
                newOrder.OrderPaymentLogistics.logisticsName = deliveryType.DeliveryTypeName;
                //newOrder.OrderPaymentLogistics.logisticsNo = "";
                //newOrder.OrderPaymentLogistics.paymentCode = "";
                //newOrder.OrderPaymentLogistics.paymentName = "";
                //newOrder.OrderPaymentLogistics.paymentNo = "";
                //newOrder.OrderPaymentLogistics.paymentType = "";
                //newOrder.OrderPaymentLogistics.trackNo = "";

                XmlSerializerNamespaces xmlNs = new XmlSerializerNamespaces();
                xmlNs.Add("nousexmlns", "http://www.chinaport.gov.cn/ecss");
                string xmlData = this.XmlSerialize <EasycrossOrder>(newOrder, xmlNs);
                xmlData = xmlData.Replace(":nousexmlns", "");
                xmlData = xmlData.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");

                // 上传文件
                FtpUtil ftp         = new FtpUtil(FTPUri, FTPName, FTPPassword);
                string  ftpResponse = "";
                ftp.UploadFile(FTPUri, "Testfilename.xml", Encoding.UTF8.GetBytes(xmlData), out ftpResponse);
            }
            catch (Exception ex)
            {
                result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                return(result);
            }

            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 添加交易订单
        /// </summary>
        /// <param name="orderSysno"></param>
        /// <returns>2016-04-09 陈海裕 创建</returns>
        public override Result AddOrderTrade(int orderSysno)
        {
            // 订单id,用于日志记录
            _orderSysNo = orderSysno;

            Result result = new Result();

            result.Status     = false;
            result.StatusCode = 0;
            result.Message    = "接口调用失败";

            if (orderSysno <= 0)
            {
                return(result);
            }

            lock (lockHelper)
            {
                try
                {
                    SoOrder order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno);
                    if (order == null)
                    {
                        result.Message = "该订单不存在";
                        return(result);
                    }
                    if (order.CBLogisticsSendStatus == 1)
                    {
                        result.Message = "该订单已推送,不能重复操作";
                        return(result);
                    }
                    order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                    order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                    ParaVoucherFilter voucherFilter = new ParaVoucherFilter();
                    voucherFilter.SourceSysNo = order.SysNo;
                    CBFnReceiptVoucher recVoucher = BLL.Finance.FinanceBo.Instance.GetReceiptVouchers(voucherFilter).Rows.FirstOrDefault();
                    recVoucher.VoucherItems = BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(recVoucher.SysNo);
                    // 收货人 区 市 省
                    BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                    BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                    BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                    // 发货人 市
                    CBWhWarehouse warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                    BsArea        shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

                    DsDealer dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                    LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                    EDTOrder newOrder = new EDTOrder();
                    newOrder.Address1 = order.ReceiveAddress.StreetAddress;
                    //newOrder.Base_ChannelInfoID = "1";
                    newOrder.Base_ChannelInfoID = "HKKJ";
                    newOrder.City           = receiverCity.AreaName;
                    newOrder.ConsigneeName  = order.ReceiveAddress.Name;
                    newOrder.Contact        = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber) ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                    newOrder.Country        = "CN";
                    newOrder.CusRemark      = order.Remarks;
                    newOrder.GFF_CustomerID = CoustomerID;
                    newOrder.OrderStatus    = "3";
                    newOrder.State          = receiverProvince.AreaName;
                    newOrder.Style          = "1";
                    //newOrder.ShippingService = "GZBC";
                    List <EDTOrderProduct> productList = new List <EDTOrderProduct>();
                    EDTOrderProduct        product     = null;
                    foreach (var item in order.OrderItemList)
                    {
                        PdProductStock productStock = BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(order.DefaultWarehouseSysNo, item.ProductSysNo);
                        product               = new EDTOrderProduct();
                        product.CnName        = item.ProductName;
                        product.EnName        = "";
                        product.MaterialRefNo = TConvert.ToString(productStock.ProductSku);
                        product.Price         = item.SalesUnitPrice.ToString();
                        product.Quantity      = item.Quantity.ToString();
                        product.Weight        = "";
                        product.WarehouseID   = warehouse.LogisWarehouseCode;
                        productList.Add(product);
                    }

                    if (product == null)
                    {
                        result.Message = "订单明细不存在";
                        return(result);
                    }

                    StringBuilder strorderinfo = new StringBuilder();
                    strorderinfo.Append("Style:" + newOrder.Style + ";");
                    strorderinfo.Append("GFF_CustomerID:" + newOrder.GFF_CustomerID + ";");
                    strorderinfo.Append("GFF_ReceiveSendAddressID:;");
                    strorderinfo.Append("ConsigneeName:" + newOrder.ConsigneeName + ";");
                    strorderinfo.Append("Country:" + newOrder.Country + ";");
                    strorderinfo.Append("Base_ChannelInfoID:" + newOrder.Base_ChannelInfoID + ";");
                    strorderinfo.Append("State:" + newOrder.State + ";");
                    strorderinfo.Append("City:" + newOrder.City + ";");
                    strorderinfo.Append("OrderStatus:" + newOrder.OrderStatus + ";");
                    strorderinfo.Append("Address1:" + newOrder.Address1 + ";");
                    strorderinfo.Append("Address2:;");
                    strorderinfo.Append("CsRefNo:;");
                    strorderinfo.Append("Zipcode:;");
                    strorderinfo.Append("Contact:" + newOrder.Contact + ";");
                    strorderinfo.Append("CusRemark:" + newOrder.CusRemark + ";");
                    strorderinfo.Append("TrackingNo:;");
                    //strorderinfo.Append("ShippingService:" + newOrder.ShippingService + ";");
                    StringBuilder strorderproduct = new StringBuilder();
                    for (int i = 0; i < productList.Count; i++)
                    {
                        strorderproduct.Append("MaterialRefNo:" + productList[i].MaterialRefNo + ",");
                        //strorderproduct.Append("MaterialRefNo:123456,");
                        strorderproduct.Append("Quantity:" + productList[i].Quantity + ",");
                        strorderproduct.Append("Price:" + productList[i].Price + ",");
                        strorderproduct.Append("Weight:" + productList[i].Weight + ",");
                        strorderproduct.Append("EnName:" + productList[i].EnName + ",");
                        strorderproduct.Append("WarehouseID:" + productList[i].WarehouseID + ",");
                        strorderproduct.Append("ProducingArea:,");
                        productList[i].CnName = Regex.Replace(productList[i].CnName, @"[/\(\)(),]", "");
                        strorderproduct.Append("CnName:" + productList[i].CnName + ",;");
                    }

                    ServiceRefEightDT.APIWebServiceSoapClient newService = new ServiceRefEightDT.APIWebServiceSoapClient();

                    string strResult = newService.InsertUpdateOrder(strorderinfo.ToString(), strorderproduct.ToString(), "", Secretkey);
                    if (strResult.Contains("成功"))
                    {
                        try
                        {
                            CrossBorderLogisticsOrder cbOrder = BLL.CrossBorderLogistics.CrossBorderLogisticsOrderBo.Instance.GetEntityByOrderSysNo(orderSysno);
                            if (cbOrder == null)
                            {
                                Model.CrossBorderLogisticsOrder logisticsOrder = new Model.CrossBorderLogisticsOrder();
                                logisticsOrder.SoOrderSysNo     = orderSysno;
                                logisticsOrder.LogisticsOrderId = Regex.Match(strResult, "[a-zA-Z0-9]+").ToString();
                                logisticsOrder.LogisticsCode    = (int)this.Code;
                                BLL.CrossBorderLogistics.CrossBorderLogisticsOrderBo.Instance.InsertEntity(logisticsOrder);
                            }
                            // 更新订单状态
                            BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus(1, 3, orderSysno);
                        }
                        catch (Exception ex)
                        {
                            BLL.Log.SysLog.Instance.Error(LogStatus.系统日志来源.后台, "订单" + orderSysno + "保存跨境物流返回的单号失败。", ex);
                        }

                        result.Status = true;
                    }

                    result.Message = strResult;
                }
                catch (Exception ex)
                {
                    result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                    return(result);
                }
            }

            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// 添加交易订单
        /// </summary>
        /// <param name="orderId">销售订单系统编号</param>
        /// <returns></returns>
        /// <remarks></remarks>
        ///  <remarks>2016-3-8 杨浩 创建</remarks>
        ///  <remarks>2016-09-22 周 重构</remarks>
        public override Result AddOrderTrade(int orderId)
        {
            var result = new Result()
            {
                Status     = false,
                StatusCode = 0,
                Message    = "向" + this.Code + "物流推送订单失败"
            };

            #region
            try
            {
                var order = Hyt.BLL.Order.SoOrderBo.Instance.GetEntity(orderId);
                if (order == null)
                {
                    result.Status     = false;
                    result.Message    = string.Format("订单号{0}不存在!", orderId);
                    result.StatusCode = -100;
                }

                order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                var filter = new ParaOnlinePaymentFilter();
                filter.OrderSysNo = orderId;
                var onlinePayment = BLL.Finance.FinanceBo.Instance.GetOnlinePayments(filter).Rows.Where(o => o.Status == 1).FirstOrDefault();

                if (onlinePayment == null)
                {
                    result.Message = "订单不存在在线支付记录";
                    return(result);
                }
                // 收货人 区 市 省
                BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                CBWhWarehouse  warehouse    = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                BsArea         shipperCity  = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);
                DsDealer       dealer       = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);
                LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                var newOrder = new CreatedOrderApiRequest();
                newOrder.OutOrderNo                     = order.SysNo.ToString();
                newOrder.DeliveryCode                   = "3";//暂时默认1(后期此参数作废)
                newOrder.ReceiverName                   = TConvert.ToString(order.ReceiveAddress.Name);
                newOrder.ReceiverMobile                 = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber) ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                newOrder.ReceiverProvince               = TConvert.ToString(receiverProvince.AreaName).Trim();
                newOrder.ReceiverCity                   = TConvert.ToString(receiverCity.AreaName).Trim();
                newOrder.ReceiverDistrict               = TConvert.ToString(receiverDistrict.AreaName).Trim();
                newOrder.ReceiverAddress                = TConvert.ToString(order.ReceiveAddress.StreetAddress).Trim();
                newOrder.ReceiverIdCard                 = TConvert.ToString(order.ReceiveAddress.IDCardNo);
                newOrder.ReceiverFrontIdCardImageUrl    = HttpContext.Current.Request.Url.Host + TConvert.ToString(order.ReceiveAddress.IDCardImgs);
                newOrder.ReceiverOppositeIdCardImageUrl = HttpContext.Current.Request.Url.Host + TConvert.ToString(order.ReceiveAddress.IDCardImgs);
                newOrder.UserRemark                     = order.Remarks;

                newOrder.ThirdPlatformPaymentName = Enum.GetName(typeof(Hyt.Model.CommonEnum.PayCode), order.PayTypeSysNo);
                var    payment       = Hyt.BLL.Finance.FinanceBo.Instance.GetOnlinePaymentBySourceSysNo(orderId);
                string PaymentNumber = "";
                if (payment != null)
                {
                    PaymentNumber = payment.VoucherNo;
                }
                newOrder.ThirdPlatformPaymentNumber = PaymentNumber;

                newOrder.Items = new List <CreatedOrderItemRequest>();
                CreatedOrderItemRequest orderItem = new CreatedOrderItemRequest();

                foreach (var item in order.OrderItemList)
                {
                    var product = BLL.Product.PdProductBo.Instance.GetProductNoCache(item.ProductSysNo);
                    orderItem.SkuId    = product.ErpCode;
                    orderItem.Quantity = item.Quantity;
                    newOrder.Items.Add(orderItem);
                }
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(newOrder);
                //推送订单
                var _result = CreatedOrder(newOrder);
                if (_result.ResultCode == 200)
                {
                    var soOrderSyncLogisticsLog = new SoOrderSyncLogisticsLog();

                    soOrderSyncLogisticsLog.OrderSysNo = orderId;
                    soOrderSyncLogisticsLog.Code       = (int)this.Code;

                    soOrderSyncLogisticsLog.LastUpdateDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    soOrderSyncLogisticsLog.StatusCode     = "";
                    soOrderSyncLogisticsLog.StatusMsg      = "";
                    soOrderSyncLogisticsLog.Packets        = json;
                    soOrderSyncLogisticsLog.ReceiptContent = _result.Tag.ToString();

                    soOrderSyncLogisticsLog.LastUpdateBy     = 0;
                    soOrderSyncLogisticsLog.LogisticsOrderId = "";

                    soOrderSyncLogisticsLog.CreateDate = DateTime.Now;
                    soOrderSyncLogisticsLog.CreatedBy  = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
                    SoOrderSyncLogisticsLogBo.Instance.Insert(soOrderSyncLogisticsLog);
                    BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus(1, 3, orderId);
                    result.Message = "向" + this.Code + "物流推送订单成功:回执单号:" + _result.Tag.ToString();
                }
                else
                {
                    result.Message = _result.Message;
                }
            }
            catch (Exception ex)
            {
                result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                return(result);
            }
            #endregion

            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// 添加交易订单
        /// </summary>
        /// <param name="orderSysno"></param>
        /// <returns>
        /// 2016-04-09 陈海裕 创建
        /// 2016-08-20 杨浩   重构
        /// </returns>
        public override Result AddOrderTrade(int orderSysno)
        {
            LogisticsLogin();

            var result = new Result <string>();

            result.Status     = false;
            result.StatusCode = 0;
            result.Message    = "接口调用失败";
            string url = RequestUrl + "Express/uploadOrders";

            if (orderSysno <= 0)
            {
                return(result);
            }

            try
            {
                var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno);
                if (order == null)
                {
                    result.Message = "该订单不存在";
                    return(result);
                }

                order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                var voucherFilter = new ParaVoucherFilter();
                voucherFilter.SourceSysNo = order.SysNo;
                var recVoucher = BLL.Finance.FinanceBo.Instance.GetReceiptVouchers(voucherFilter).Rows.FirstOrDefault();
                recVoucher.VoucherItems = BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(recVoucher.SysNo);
                // 收货人 区 市 省
                BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                CBWhWarehouse warehouse       = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                BsArea        shipperDistrict = BLL.Basic.BasicAreaBo.Instance.GetAreaList(warehouse.CitySysNo).FirstOrDefault();
                BsArea        shipperCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);
                BsArea        shipperProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.ProvinceSysNo);

                DsDealer dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                ParaOnlinePaymentFilter filter = new ParaOnlinePaymentFilter();
                filter.OrderSysNo = orderSysno;
                var   onlinePayment = BLL.Finance.FinanceBo.Instance.GetOnlinePayments(filter).Rows.Where(o => o.Status == 1).FirstOrDefault();
                Regex regex         = new Regex("\t|\n|\r");

                OrderList newOrderList = new OrderList();
                newOrderList.PrintType = "@1,@2";
                newOrderList.list      = new List <LGOrder>();
                LGOrder newOrder = new LGOrder();
                newOrder.Addr          = "中国," + receiverProvince.AreaName + "," + receiverCity.AreaName + "," + receiverDistrict.AreaName + "," + order.ReceiveAddress.StreetAddress;
                newOrder.Addr          = regex.Replace(newOrder.Addr, "");
                newOrder.CardNo        = order.ReceiveAddress.IDCardNo;
                newOrder.Create_Addr   = "中国," + shipperProvince.AreaName + "," + shipperCity.AreaName + "," + shipperDistrict.AreaName + ",";
                newOrder.Create_Addr   = regex.Replace(newOrder.Create_Addr, "");
                newOrder.Create_CardNo = "";
                newOrder.Create_Name   = "澳门爱勤";
                newOrder.Create_Phone  = !string.IsNullOrWhiteSpace(dealer.MobilePhoneNumber) ? dealer.MobilePhoneNumber : dealer.PhoneNumber;
                newOrder.id            = order.SysNo.ToString();
                newOrder.Name          = order.ReceiveAddress.Name;
                newOrder.OrderType     = "A";
                newOrder.PayCardNo     = order.ReceiveAddress.IDCardNo;
                newOrder.PayCurrency   = "CNY";
                newOrder.PayName       = order.ReceiveAddress.Name;
                newOrder.PayNo         = recVoucher.VoucherItems[0].VoucherNo;
                newOrder.PayPhone      = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber) ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                newOrder.PayRemark     = "";
                newOrder.PayTime       = order.CreateDate.ToString();
                newOrder.PayType       = GetPayType(order.PayTypeSysNo);// "alipay";
                newOrder.PayUser       = order.CustomerSysNo.ToString();
                newOrder.Phone         = newOrder.PayPhone;
                newOrder.Price         = order.OrderAmount;
                newOrder.Remark        = order.DeliveryRemarks;
                newOrder.TaxFee        = order.TaxFee;
                newOrder.TranFee       = order.FreightAmount;
                newOrder.Content       = "";
                foreach (var item in order.OrderItemList)
                {
                    var productStock = BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(order.DefaultWarehouseSysNo, item.ProductSysNo);
                    newOrder.Content += productStock.Barcode + "," + item.Quantity + "," + item.SalesUnitPrice + "|";
                }
                if (!string.IsNullOrWhiteSpace(newOrder.Content))
                {
                    newOrder.Content = newOrder.Content.Substring(0, newOrder.Content.Length - 1);
                }
                newOrderList.list.Add(newOrder);

                Dictionary <string, string> paramsData = new Dictionary <string, string>();
                paramsData.Add("token", IdentifyPass);
                paramsData.Add("postdata", Util.Serialization.JsonUtil.ToJson(newOrderList));
                string postData    = InitParams(paramsData);
                string responseStr = GetResponse(url, postData);


                var jObject = JObject.Parse(responseStr);


                var soOrderSyncLogisticsLog = new SoOrderSyncLogisticsLog();

                soOrderSyncLogisticsLog.OrderSysNo = orderSysno;
                soOrderSyncLogisticsLog.Code       = (int)this.Code;

                soOrderSyncLogisticsLog.LastUpdateDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                soOrderSyncLogisticsLog.StatusCode     = "";
                soOrderSyncLogisticsLog.StatusMsg      = "";
                soOrderSyncLogisticsLog.Packets        = postData;
                soOrderSyncLogisticsLog.ReceiptContent = responseStr;

                string status = jObject["status"].ToString();

                if (status == "-1")
                {
                    result.Status  = false;
                    result.Message = "未登录,请重试!";
                    IdentifyPass   = string.Empty;//清空身份凭证
                }
                else if (status == "1")
                {
                    for (int i = 0; i < jObject["data"].Count(); i++)
                    {
                        if (jObject["data"][i]["status"].ToString() == "1")
                        {
                            soOrderSyncLogisticsLog.LastUpdateBy     = 0;
                            soOrderSyncLogisticsLog.LogisticsOrderId = jObject["data"][i]["id"].ToString();
                            soOrderSyncLogisticsLog.CreateDate       = DateTime.Now;
                            soOrderSyncLogisticsLog.CreatedBy        = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
                            SoOrderSyncLogisticsLogBo.Instance.Insert(soOrderSyncLogisticsLog);
                            BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.跨境物流推送状态.已推送, 3, orderSysno);
                            result.Status  = true;
                            result.Message = "推单成功";
                        }
                        else
                        {
                            soOrderSyncLogisticsLog.CreateDate = DateTime.Now;
                            SoOrderSyncLogisticsLogBo.Instance.Insert(soOrderSyncLogisticsLog);
                            result.Status  = false;
                            result.Message = jObject["data"][i]["message"].ToString();
                        }
                    }
                }
                else
                {
                    try
                    {
                        SoOrderSyncLogisticsLogBo.Instance.Insert(soOrderSyncLogisticsLog);
                    }
                    catch { }

                    result.Status  = false;
                    result.Message = jObject["message"].ToString();
                }
            }
            catch (Exception ex)
            {
                result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                return(result);
            }

            return(result);
        }