/// <summary> /// 更新海关订单日志 /// </summary> /// <param name="model">海关订单日志实体类</param> /// <returns></returns> public override int UpdateCustomsOrderLog(SoCustomsOrderLog model) { return(Context.Update("SoCustomsOrderLog", model) .AutoMap(x => x.SysNo, x => x.CreatedBy, x => x.CustomsChannel, x => x.CreateDate, x => x.OrderSysNo) .Where("sysNo", model.SysNo) .Execute()); }
/// <summary> /// 更新海关订单日志 /// </summary> /// <param name="model">海关订单日志实体类</param> /// <returns></returns> public int UpdateCustomsOrderLog(SoCustomsOrderLog model) { return(Hyt.DataAccess.Order.ISoCustomsOrderLogDao.Instance.UpdateCustomsOrderLog(model)); }
/// <summary> /// 上传订单至海关 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="warehouseSysNo">仓库编号</param> /// <param name="customsLogInfo">海关日志</param> /// <param name="orderStatus">订单状态 S-订单新增,C-订单取消</param> /// <returns></returns> /// <remarks>2016-3-23 杨浩 创建</remarks> private Result Upload(int orderId, int warehouseSysNo, SoCustomsOrderLog customsLogInfo, string orderStatus = "S") { var result = new Result() { Status = false }; //xml文件名 string fileName = ""; //获取当前时间 int Year = DateTime.Now.Year; int Month = DateTime.Now.Month; int Day = DateTime.Now.Day; int Hour = DateTime.Now.Hour; int Minute = DateTime.Now.Minute; int Second = DateTime.Now.Second; string SendTime = Year.ToString() + (Month < 10 ? "0" + Month.ToString() : Month.ToString()) + (Day < 10 ? "0" + Day.ToString() : Day.ToString()); SendTime += (Hour < 10 ? "0" + Hour.ToString() : Hour.ToString()) + (Minute < 10 ? "0" + Minute.ToString() : Minute.ToString()) + (Second < 10 ? "0" + Second.ToString() : Second.ToString()); //if (customsLogInfo == null) //{ string MessageIDNo = BLL.Basic.ReceiptNumberBo.Instance.GetCustomsOrderNo(); fileName = MessageType + SendTime + MessageIDNo; //} //else //{ // fileName = customsLogInfo.FileName; //} var orderInfo = BLL.Order.SoOrderBo.Instance.GetEntityNoCache(orderId); var receiveInfo = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(orderInfo.ReceiveAddressSysNo); #region 载数据 string OrderId = orderId.ToString(); string IEFlag = "I"; //进出口标识 I:进口;E:出口 string OrderStatus = orderStatus; // "S";//订单状态 S-订单新增,C-订单取消 string EntRecordNo = XinYinSenderID; //电商平台企业备案号(代码) //string EntRecordName = "深圳信营贸易有限公司";// "深圳市信营国际电子商务有限公司";//电商平台企业名称 string EntRecordName = config.EntRecordName; // "深圳市信营国际电子商务有限公司";//电商平台企业名称 string OrderName = receiveInfo.Name; //订单人姓名 string OrderDocType = "01"; //订单人证件类型01:身份证、02:护照、03:其他 string OrderDocId = receiveInfo.IDCardNo; string OrderPhone = receiveInfo.MobilePhoneNumber; string OrderGoodTotal = (orderInfo.ProductAmount + orderInfo.ProductChangeAmount).ToString("F2"); string OrderGoodTotalCurr = "142"; //订单商品总额币制,人民币(CNY/142) string Freight = orderInfo.FreightAmount.ToString("F2"); //运费 string FreightCurr = "142"; //运费币制 string Tax = orderInfo.TaxFee.ToString("F2"); //行邮税 string TaxCurr = "142"; string Note = ""; //备注 string OrderDate = orderInfo.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"); //订单日期,精确到秒 YYYY-MM-DD:HH:MM:SS 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 = "订单编号异常!"; return(result); } string strxml = ""; strxml += "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; strxml += "<Manifest>"; strxml += "<Head>"; strxml += "<MessageID>" + fileName + "</MessageID>"; strxml += "<MessageType>" + MessageType + "</MessageType>"; strxml += "<SenderID>" + XinYinSenderID + "</SenderID>"; strxml += "<SendTime>" + SendTime + "</SendTime>"; strxml += "<Version>" + Version + "</Version>"; strxml += "</Head>"; strxml += "<Declaration>"; strxml += "<EOrder>"; strxml += "<OrderId>" + orderNo + "</OrderId>"; strxml += "<IEFlag>" + IEFlag + "</IEFlag>"; strxml += "<OrderStatus>" + OrderStatus + "</OrderStatus>"; strxml += "<EntRecordNo>" + EntRecordNo + "</EntRecordNo>"; strxml += "<EntRecordName>" + EntRecordName + "</EntRecordName>"; strxml += "<OrderName>" + OrderName + "</OrderName>"; strxml += "<OrderDocType>" + OrderDocType + "</OrderDocType>"; strxml += "<OrderDocId>" + OrderDocId + "</OrderDocId>"; strxml += "<OrderPhone>" + OrderPhone + "</OrderPhone>"; strxml += "<OrderGoodTotal>" + OrderGoodTotal + "</OrderGoodTotal>"; strxml += "<OrderGoodTotalCurr>" + OrderGoodTotalCurr + "</OrderGoodTotalCurr>"; strxml += "<Freight>" + Freight + "</Freight>"; strxml += "<FreightCurr>" + FreightCurr + "</FreightCurr>"; strxml += "<Tax>" + Tax + "</Tax>"; strxml += "<TaxCurr>" + TaxCurr + "</TaxCurr>"; strxml += "<Note>" + Note + "</Note>"; strxml += "<OrderDate>" + OrderDate + "</OrderDate>"; strxml += "</EOrder>"; strxml += "<EOrderGoods>"; var orderItemList = BLL.Order.SoOrderBo.Instance.GetOrderItemsByOrderId(orderId); foreach (var item in orderItemList) { var warehouseProductInfo = Hyt.BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(warehouseSysNo, item.ProductSysNo); if (warehouseProductInfo == null) { result.Message = "订单中有产品(系统编号:" + item.ProductSysNo + ")在仓库中不存在!"; return(result); } string customsNo = warehouseProductInfo.CustomsNo; if (customsNo == "") { result.Message = "订单中有产品(系统编号:" + item.ProductSysNo + ")无海关备案号!"; return(result); } strxml += "<EOrderGood>"; strxml += "<GNo>" + item.SysNo + "</GNo>"; strxml += "<ChildOrderNo></ChildOrderNo>"; strxml += "<StoreRecordNo>" + EntRecordNo + "</StoreRecordNo>"; strxml += "<StoreRecordName>" + EntRecordName + "</StoreRecordName>"; strxml += "<CopGNo>" + item.ProductSysNo + "</CopGNo>"; strxml += "<CustomsListNO>" + warehouseProductInfo.CustomsNo + "</CustomsListNO>"; //商品海关备案号 strxml += "<DecPrice>" + item.SalesUnitPrice + "</DecPrice>"; strxml += "<Unit>001</Unit>"; //计量单位(件/011) strxml += "<GQty>" + item.Quantity + "</GQty>"; //商品数量 strxml += "<DeclTotal>" + (item.SalesAmount + item.ChangeAmount).ToString("F2") + "</DeclTotal>"; strxml += "<Notes></Notes>"; strxml += "</EOrderGood>"; } strxml += "</EOrderGoods>"; strxml += "</Declaration>"; strxml += "</Manifest>"; #endregion var customsOrderLog = new SoCustomsOrderLog(); if (customsLogInfo != null) { customsOrderLog = customsLogInfo; } customsOrderLog.Packets = strxml; strxml = Encrypt(strxml); //上传xml文件 MemoryStream stream = new MemoryStream(); byte[] buffer = Encoding.Default.GetBytes(strxml); string msg = ""; string _ftpImageServer = FtpUrl + "UPLOAD/"; customsOrderLog.StatusCode = ""; 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; FtpUtil ftp = new FtpUtil(_ftpImageServer, FtpUserName, FtpPassword); //上传xml文件 ftp.UploadFile(_ftpImageServer, customsOrderLog.FileName + ".xml", buffer, out msg); //if (customsLogInfo != null) //{ // customsOrderLog.CreateDate = customsLogInfo.CreateDate; // customsOrderLog.CreatedBy = customsLogInfo.CreatedBy; // customsOrderLog.SysNo = customsLogInfo.SysNo; // BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog); //} if (customsLogInfo == null) { BLL.Order.SoCustomsOrderLogBo.Instance.AddCustomsOrderLog(customsOrderLog); } else { BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog); } if (orderStatus == "S") { BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.海关报关状态.处理中, 2, orderId); } else { BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.海关报关状态.作废, 2, orderId); } result.Status = true; result.Message = "提交成功!"; return(result); }
/// <summary> /// 查询海关订单 /// </summary> /// <param name="orderId">订单编号</param> /// <returns></returns> /// <remarks>2015-12-29 杨浩 创建</remarks> public override Result SearchCustomsOrder(int orderId) { lock (lockSearch) { var result = new Result() { Status = false }; try { OrderStatus.海关报关状态 status = OrderStatus.海关报关状态.成功; var customsLogInfo = BLL.Order.SoCustomsOrderLogBo.Instance.GetCustomsOrderLogInfo(orderId, (int)Code); if (customsLogInfo == null) { result.Message = "还未提交订单至海关!"; return(result); } //原始文件(海关回执后缀为.txt的文件) string oldFile = customsLogInfo.FileName + ".txt"; //失败回执文件名 string failureFileName = "0_" + oldFile; //成功回执文件名 string successFileName = "1_" + oldFile; string _ftpImageServer = FtpUrl + "DOWNLOAD/"; FtpUtil ftp = new FtpUtil(_ftpImageServer, FtpUserName, FtpPassword); string msg = ""; //首先读取成功的文件 Stream stream = ftp.FileStream(_ftpImageServer + successFileName, ref msg); if (msg == "get file success!") { result.Status = true; status = OrderStatus.海关报关状态.成功; } else { msg = ""; //成功回执文件不存在则读取失败文件名称 stream = ftp.FileStream(_ftpImageServer + failureFileName, ref msg); if (msg != "get file success!") { result.Status = false; result.Message = "暂时海关没有生成回执文件,请稍后再试!"; return(result); } status = OrderStatus.海关报关状态.失败; } //设置当前流的位置为流的开始,防止读取位置错误造成无法读取完整流的内容 stream.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(stream)) { string xml = Decrypt(reader.ReadToEnd()); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlNode xmlNode = xmlDoc.SelectSingleNode("//ResponseMessage//ResponseBodyList//ResponseBody"); var customsOrderLog = new SoCustomsOrderLog(); customsOrderLog.StatusCode = xmlNode.SelectSingleNode("ReturnCode").InnerText; customsOrderLog.StatusMsg = xmlNode.SelectSingleNode("ReturnInfo").InnerText; //switch (code) //{ // case "A01": customsOrderLog.StatusMsg = "-缺少接入企业备案号"; break; // case "A02": customsOrderLog.StatusMsg = "-电商接入企业未备案或失效"; break; // case "A10": customsOrderLog.StatusMsg = "-缺少电商企业备案号"; break; // case "A11": customsOrderLog.StatusMsg = "-电商企业未备案或失效"; break; // case "A14": customsOrderLog.StatusMsg = "-退回修改"; break; // case "B10": customsOrderLog.StatusMsg = "-报文类型不正确"; break; // case "B11": customsOrderLog.StatusMsg = "-业务字段异常"; break; // case "B12": customsOrderLog.StatusMsg = "-重复报文"; break; // case "B13": customsOrderLog.StatusMsg = "-重复记录"; break; // case "C01": customsOrderLog.StatusMsg = "-入库成功"; break; // default: break; //} if (customsOrderLog.StatusMsg == "订单编号已经存在,不可重复插入。") { status = OrderStatus.海关报关状态.成功; } else if (customsOrderLog.StatusCode != "C01") { status = OrderStatus.海关报关状态.失败; } customsOrderLog.LastUpdateBy = 0; if (BLL.Authentication.AdminAuthenticationBo.Instance.IsLogin) { customsOrderLog.LastUpdateBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo; } customsOrderLog.LastUpdateDate = DateTime.Now; customsOrderLog.ReceiptContent = xml; customsOrderLog.SysNo = customsLogInfo.SysNo; customsOrderLog.FileName = customsLogInfo.FileName; customsOrderLog.Packets = customsLogInfo.Packets; BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)status, 2, orderId); BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog); result.Message = customsOrderLog.StatusMsg; } } catch (Exception ex) { result.Message = "系统异常!"; result.Status = false; BLL.Log.LocalLogBo.Instance.Write(ex, "GZSearchCustomsOrder"); } return(result); } }
/// <summary> /// 新增海关订单日志 /// </summary> /// <param name="model">海关订单日志实体类</param> /// <returns></returns> public override int AddCustomsOrderLog(SoCustomsOrderLog model) { return(Context.Insert("SoCustomsOrderLog", model) .AutoMap(x => x.SysNo) .ExecuteReturnLastId <int>()); }
/// <summary> /// 查询海关订单 /// </summary> /// <param name="orderId">订单编号</param> /// <returns></returns> /// <remarks>2016-8-18 杨浩 重构</remarks> public override Result SearchCustomsOrder(int orderId) { var result = new Result() { Status = true }; try { var resultDic = new Dictionary <int, string>(); var ftp = new FtpUtil(FTPUri, FTPName, FTPPassword); string ftpResponse = ""; #region /* * <?xml version="1.0" encoding="UTF-8"?> * <DocRec> * <Head> * <MessageID><![CDATA[KJDOCREC_KJGGPT2016110315520669308]]></MessageID> * <MessageType><![CDATA[KJDOCREC]]></MessageType> * <Sender><![CDATA[KJGGPT]]></Sender> * <Receiver><![CDATA[GZXINRAO]]></Receiver> * <SendTime><![CDATA[20161103155206]]></SendTime> * <FunctionCode><![CDATA[]]></FunctionCode> * <SignerInfo><![CDATA[]]></SignerInfo> * <Version><![CDATA[2.0]]></Version> * </Head> * <Declaration> * <OrgMessageID><![CDATA[F9F53112-3A28-4912-92EC-BD3085085FC8]]></OrgMessageID> * <OrgMessageType><![CDATA[CEB311Message]]></OrgMessageType> * <OrgSenderID><![CDATA[GZXINRAO]]></OrgSenderID> * <OrgReceiverID><![CDATA[KJCUSTOM]]></OrgReceiverID> * <OrgRecTime><![CDATA[20161103155206]]></OrgRecTime> * <RespondBy>01</RespondBy> * <RespondStatus><![CDATA[F]]></RespondStatus> * <RespondNotes><![CDATA[1.4.2.业务验证失败: * 1.广州海关单号【501_20161029101958】重复申报... * ]]></RespondNotes> * <Status>F</Status> * <Notes><![CDATA[1.4.2.业务验证失败: * 1.广州海关单号【501_20161029101958】重复申报... * ]]></Notes> * </Declaration> * </DocRec> * */ #endregion // 获取文件列表 //string[] fileList = ftp.GetFileList(FTPUri + "cebout/"); string[] fileList = ftp.GetFileList(FTPUri + FolderOut); if (fileList != null && fileList.Length > 0) { foreach (string fileName in fileList) { //Stream stream = ftp.FileStream(FTPUri + "cebout/" + fileName, ref ftpResponse); var stream = ftp.FileStream(FTPUri + FolderOut + fileName, ref ftpResponse); #region 更新订单海关推送状态 string xmlData = ""; stream.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(stream)) { xmlData = reader.ReadToEnd(); } if (!string.IsNullOrEmpty(xmlData)) { int id = 0; var customsOrderLog = new SoCustomsOrderLog(); var xml = new XmlDocumentExtender(); xml.LoadXml(xmlData); var _xml = xml["CEB312Message"]; if (_xml != null) { var orderReturn = _xml["OrderReturn"]; //订单编号 if (!int.TryParse(orderReturn["orderNo"].InnerText.Split('_')[0], out id)) { continue; } var customsLogInfo = BLL.Order.SoCustomsOrderLogBo.Instance.GetCustomsOrderLogInfo(id, (int)Code); int status = -999; switch (orderReturn["returnStatus"].InnerText) { case "": // 电子口岸申报中 result.Message = "电子口岸申报中!"; status = (int)OrderStatus.海关报关状态.处理中; break; case "2": // 发送海关成功 status = (int)OrderStatus.海关报关状态.处理中; result.Message = orderReturn["returnInfo"].InnerText; if (customsLogInfo.StatusCode == "3") { status = (int)OrderStatus.海关报关状态.作废; result.Message = orderReturn["returnInfo"].InnerText; } break; case "4": // 发送海关失败 case "100": // 海关退单 status = (int)OrderStatus.海关报关状态.失败; result.Message = "海关退单!"; break; case "120": // 海关入库 status = (int)OrderStatus.海关报关状态.成功; result.Message = "海关入库成功!"; break; default: status = (int)OrderStatus.海关报关状态.失败; result.Message = "海关推送失败!"; break; } customsOrderLog.StatusCode = ""; //customsOrderLog.StatusCode = orderReturn["returnStatus"].InnerText; customsOrderLog.StatusMsg = orderReturn["returnInfo"].InnerText; if (resultDic.ContainsKey(orderId)) { resultDic[orderId] = customsOrderLog.StatusMsg; } else { resultDic.Add(orderId, customsOrderLog.StatusMsg); } BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)status, 2, id); if (customsLogInfo != null) { customsOrderLog.LastUpdateBy = 0; if (BLL.Authentication.AdminAuthenticationBo.Instance.IsLogin) { customsOrderLog.LastUpdateBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo; } customsOrderLog.LastUpdateDate = DateTime.Now; customsOrderLog.ReceiptContent = xmlData; customsOrderLog.SysNo = customsLogInfo.SysNo; customsOrderLog.FileName = customsLogInfo.FileName; customsOrderLog.Packets = customsLogInfo.Packets; BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog); } } else { _xml = xml["DocRec"]; if (_xml != null) { var status = _xml["Declaration"]["Status"].InnerText; } } } ftp.DeleteFile(FTPUri + FolderOut + fileName);//删除回执文件 #endregion } if (resultDic.ContainsKey(orderId)) { result.Message = resultDic[orderId]; } else { result.Message = "暂无回执"; } } else { var customsLogInfo = BLL.Order.SoCustomsOrderLogBo.Instance.GetCustomsOrderLogInfo(orderId, (int)Code); result.Status = false; result.Message = customsLogInfo != null?customsLogInfo.StatusMsg:"没有找到回执文件,请稍后重试!"; } } catch (Exception ex) { result.Status = false; result.Message = ex.Message; } return(result); }
/// <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); }
/// <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); }
/// <summary> /// 更新海关订单日志 /// </summary> /// <param name="model">海关订单日志实体类</param> /// <returns></returns> public abstract int UpdateCustomsOrderLog(SoCustomsOrderLog model);
/// <summary> /// 新增海关订单日志 /// </summary> /// <param name="model">海关订单日志实体类</param> /// <returns></returns> public abstract int AddCustomsOrderLog(SoCustomsOrderLog model);