Example #1
0
        /// <summary>
        /// 设置支付企业代码和名称
        /// </summary>
        /// <param name="payTypeSysNo">支付系统编号</param>
        /// <param name="gAOrder">海关总署订单报文</param>
        /// <remarks>2016-12-8 杨浩 创建</remarks>
        //private GAOrder SetPayCodeAndPayName(int payTypeSysNo, GAOrder gAOrder)
        //{
        //    switch (payTypeSysNo)
        //    {
        //        case 16://钱袋宝
        //            gAOrder.OrderHead.payCode = "110896T001";
        //            gAOrder.OrderHead.payName = "北京钱袋宝支付技术有限公司";
        //            break;
        //    }
        //    return gAOrder;
        //}



        /// <summary>
        /// 上传订单至海关
        /// </summary>
        /// <param name="orderId">订单编号</param>
        /// <param name="warehouseSysNo">仓库编号</param>
        /// <param name="customsLogInfo">海关日志</param>
        /// <param name="appType">报文类型 企业报送类型。A-新增 M-变更 D-删除。默认为1。</param>
        /// <returns></returns>
        /// <remarks>2016-6-4 杨浩 创建</remarks>
        private Result Upload(int orderId, int warehouseSysNo, SoCustomsOrderLog customsLogInfo, string appType = "A")
        {
            var result = new Result()
            {
                Status = false
            };

            try
            {
                var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderId);
                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);
                order.Customer       = Hyt.BLL.CRM.CrCustomerBo.Instance.GetModel(order.CustomerSysNo);

                ///获取商品档案数据
                IList <int> proSysNos = new List <int>();
                foreach (var mod in order.OrderItemList)
                {
                    proSysNos.Add(mod.ProductSysNo);
                }
                IList <CBPdProduct> productList = Hyt.BLL.Product.PdProductBo.Instance.GetProductInfoList(proSysNos);

                IList <PdProductStock> stockList = Hyt.BLL.Warehouse.PdProductStockBo.Instance.GetAllStockList(order.DefaultWarehouseSysNo, proSysNos);

                List <Origin> orginList = Hyt.BLL.Basic.OriginBo.Instance.GetOrigin();


                var onlinePaymentFilter = new Hyt.Model.Parameter.ParaOnlinePaymentFilter()
                {
                    OrderSysNo = orderId,
                    Id         = 1
                };
                var onlinePayments = Hyt.BLL.Finance.FinanceBo.Instance.GetOnlinePayments(onlinePaymentFilter).Rows;

                if (onlinePayments == null || (onlinePayments != null && onlinePayments.Count() <= 0))
                {
                    result.Status  = false;
                    result.Message = "订单没有支付单!";
                    return(result);
                }

                string orderNo = onlinePayments[0].BusinessOrderSysNo;
                if (string.IsNullOrEmpty(orderNo))
                {
                    result.Status  = false;
                    result.Message = "报关订单编号不能为空,请检查支付单字段 BusinessOrderSysNo";
                    return(result);
                }

                // 收货人 区 市 省
                var receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                var receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                var receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                var warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(warehouseSysNo);
                var shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

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

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



                result.Status  = true;
                result.Message = "提交成功!";
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// 上传订单至海关
        /// </summary>
        /// <param name="orderId">订单编号</param>
        /// <param name="warehouseSysNo">仓库编号</param>
        /// <param name="customsLogInfo">海关日志</param>
        /// <param name="appType">报文类型 企业报送类型。1-新增 2-变更 3-删除。默认为1。</param>
        /// <returns></returns>
        /// <remarks>2016-6-4 杨浩 创建</remarks>
        private Result Upload(int orderId, int warehouseSysNo, SoCustomsOrderLog customsLogInfo, string appType = "1")
        {
            var result = new Result()
            {
                Status = false
            };

            try
            {
                var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderId);
                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 onlinePaymentFilter = new Hyt.Model.Parameter.ParaOnlinePaymentFilter()
                {
                    OrderSysNo = orderId,
                    Id         = 1
                };
                var onlinePayments = Hyt.BLL.Finance.FinanceBo.Instance.GetOnlinePayments(onlinePaymentFilter).Rows;

                if (onlinePayments == null || (onlinePayments != null && onlinePayments.Count() <= 0))
                {
                    result.Status  = false;
                    result.Message = "订单没有支付单!";
                    return(result);
                }

                string orderNo = onlinePayments[0].BusinessOrderSysNo;
                if (string.IsNullOrEmpty(orderNo))
                {
                    result.Status  = false;
                    result.Message = "报关订单编号不能为空,请检查支付单字段 BusinessOrderSysNo";
                    return(result);
                }

                // 收货人 区 市 省
                var receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                var receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                var receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                var warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(warehouseSysNo);
                var shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

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

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

                var CEBMessage = new CEB311Message();
                CEBMessage.GAOrder = new List <GAOrder>();
                CEBMessage.guid    = System.Guid.NewGuid().ToString("D").ToUpper();
                CEBMessage.version = "1.0";

                var gaOrder = new GAOrder();
                gaOrder.OrderHead                  = new OrderHead();
                gaOrder.OrderHead.acturalPaid      = order.CashPay.ToString();// (order.ProductAmount + order.ProductChangeAmount).ToString(); //recVoucher.ReceivedAmount.ToString();
                gaOrder.OrderHead.appStatus        = "2";
                gaOrder.OrderHead.appTime          = DateTime.Now.ToString("yyyyMMddHHmmss");
                gaOrder.OrderHead.appType          = appType;// "1";
                gaOrder.OrderHead.batchNumbers     = "";
                gaOrder.OrderHead.buyerIdNumber    = order.ReceiveAddress.IDCardNo;
                gaOrder.OrderHead.buyerIdType      = "1";
                gaOrder.OrderHead.buyerName        = order.ReceiveAddress.Name;
                gaOrder.OrderHead.buyerRegNo       = order.CustomerSysNo.ToString();
                gaOrder.OrderHead.consignee        = order.ReceiveAddress.Name;
                gaOrder.OrderHead.consigneeAddress = order.ReceiveAddress.StreetAddress;
                //gaOrder.OrderHead.consigneeDitrict = receiverDistrict.AreaCode;
                gaOrder.OrderHead.consigneeTelephone = order.ReceiveAddress.MobilePhoneNumber;
                gaOrder.OrderHead.currency           = "142";
                gaOrder.OrderHead.discount           = order.OrderDiscountAmount.ToString();
                gaOrder.OrderHead.ebcCode            = EbcCode; //"44306609EP";
                gaOrder.OrderHead.ebcName            = EbcCode; //"广州华迅捷通电子商务有限公司";
                gaOrder.OrderHead.ebpCode            = EbcCode;
                gaOrder.OrderHead.ebpName            = EbcName;
                gaOrder.OrderHead.freight            = order.FreightAmount.ToString();
                gaOrder.OrderHead.goodsValue         = order.ProductAmount.ToString();
                gaOrder.OrderHead.guid = System.Guid.NewGuid().ToString("D").ToUpper();
                //gaOrder.OrderHead.note = "";
                gaOrder.OrderHead.orderNo   = orderNo;// order.SysNo.ToString();
                gaOrder.OrderHead.orderType = "I";

                gaOrder = SetPayCodeAndPayName(order.PayTypeSysNo, gaOrder);

                gaOrder.OrderHead.payTransactionId = onlinePayments[0].VoucherNo; // recVoucher.VoucherItems[0].VoucherNo;
                gaOrder.OrderHead.taxTotal         = order.TaxFee.ToString();     // "0";
                gaOrder.OrderList = new List <OrderList>();
                int _gnum = 1;
                foreach (var item in order.OrderItemList)
                {
                    var orderList = new OrderList();
                    #region 条形码商品
                    var RefProductName     = item.ProductName;
                    var RefProductSysNo    = item.ProductSysNo;
                    var RefProductQuantity = item.Quantity;
                    BLL.Product.PdProductBo.Instance.RefProductQuantity(ref RefProductSysNo, ref RefProductQuantity, ref RefProductName, order.SysNo);
                    #endregion
                    //orderList.barCode = "";
                    orderList.country      = "116";
                    orderList.currency     = "142";
                    orderList.gnum         = _gnum.ToString();
                    orderList.itemDescribe = "";
                    //orderList.itemName = item.ProductName;
                    //orderList.itemNo = item.ProductSysNo.ToString();// "";
                    orderList.itemName = RefProductName;
                    orderList.itemNo   = RefProductSysNo.ToString();
                    //orderList.note = "";
                    orderList.price = item.SalesUnitPrice.ToString();
                    //orderList.qty = item.Quantity.ToString();
                    orderList.qty        = RefProductQuantity.ToString();
                    orderList.totalPrice = (item.SalesAmount + item.ChangeAmount).ToString();
                    orderList.unit       = "007";
                    gaOrder.OrderList.Add(orderList);

                    _gnum++;
                }
                CEBMessage.GAOrder.Add(gaOrder);

                CEBMessage.BaseTransfer = new BaseTransfer();
                //CEBMessage.BaseTransfer.copCode = EbcCode;
                //CEBMessage.BaseTransfer.copName = EbcName;
                CEBMessage.BaseTransfer.copCode = EbcCode;
                CEBMessage.BaseTransfer.copName = EbcName;
                // 电子口岸固定DXP
                CEBMessage.BaseTransfer.dxpId   = DxpId;// "DXPENTTEST510001";
                CEBMessage.BaseTransfer.dxpMode = "DXP";
                //CEBMessage.BaseTransfer.note = "";

                XmlSerializerNamespaces xmlNs = new XmlSerializerNamespaces();
                xmlNs.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                xmlNs.Add("nousexmlns", "http://www.chinaport.gov.cn/ceb");
                string xmlData = this.XmlSerialize <CEB311Message>(CEBMessage, xmlNs);
                xmlData = xmlData.Replace(":nousexmlns", "");
                xmlData = xmlData.Replace("encoding=\"utf-16\"", "encoding=\"UTF-8\"");

                // 上传文件
                var    ftp         = new FtpUtil(FTPUri, FTPName, FTPPassword);
                string ftpResponse = "";
                var    random      = new Random();
                string fileName    = "GZEPORT_" + FTPName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + random.Next(10000, 100000).ToString() + ".xml";



                ftp.UploadFile(FTPUri + FolderIn, fileName, Encoding.UTF8.GetBytes(xmlData), out ftpResponse);

                #region 海关推送日志
                var customsOrderLog = new SoCustomsOrderLog();

                if (customsLogInfo != null)
                {
                    customsOrderLog = customsLogInfo;
                }

                customsOrderLog.Packets    = xmlData;
                customsOrderLog.StatusCode = appType;

                if (appType == "1")//1-新增 2-变更 3-删除
                {
                    customsOrderLog.StatusMsg = "新增中";
                }
                else if (appType == "2")
                {
                    customsOrderLog.StatusMsg = "变更中";
                }
                else if (appType == "3")
                {
                    customsOrderLog.StatusMsg = "删除中";
                }



                customsOrderLog.LastUpdateBy = 0;
                if (BLL.Authentication.AdminAuthenticationBo.Instance.IsLogin)
                {
                    customsOrderLog.LastUpdateBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
                }
                customsOrderLog.LastUpdateDate = DateTime.Now;
                customsOrderLog.CreateDate     = DateTime.Now;
                customsOrderLog.CreatedBy      = customsOrderLog.LastUpdateBy;
                customsOrderLog.ReceiptContent = "";
                customsOrderLog.FileName       = fileName;
                customsOrderLog.OrderSysNo     = orderId;
                customsOrderLog.CustomsChannel = (int)this.Code;
                customsOrderLog.StatusCode     = appType;


                if (customsLogInfo == null)
                {
                    BLL.Order.SoCustomsOrderLogBo.Instance.AddCustomsOrderLog(customsOrderLog);
                }
                else
                {
                    BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog);
                }

                BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.海关报关状态.处理中, 2, orderId);
                #endregion

                result.Status  = true;
                result.Message = "提交成功!";
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }