using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Runtime.Remoting.Messaging; using System.Web; using System.Web.Configuration; using System.Web.UI.WebControls; using DSWeb.Areas.CommMng.Controllers; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.MvcShipping.DB; using DSWeb.Areas.MvcShipping.Models.Message.VGM; using DSWeb.Common.DB; using DSWeb.MvcContainer.DAL.MsOpCtnApply; using DSWeb.MvcShipping.DAL.DsSendmail; using DSWeb.MvcShipping.DAL.MsChFeeDAL; using DSWeb.MvcShipping.DAL.MsOpSeaeDAL; using DSWeb.MvcShipping.DAL.MsSysParamSet; //using DSWeb.Dispatch.DAL; using HcUtility.Comm; using javax.management.loading; using Newtonsoft.Json; using NPOI.SS.Formula.Functions; using User = DSWeb.Common.DB.User; namespace DSWeb.Areas.CommMng.Models { #region TSYSENUMVALUE /// /// This object represents the properties and methods of a TSYSENUMVALUE. /// /// [JsonObject] public class SysEnumValue { private decimal _langId; private decimal _enumTypeId; private string _enumValueId = String.Empty; private string _enumValueName = String.Empty; private string _enumValueName_2 = String.Empty; private string _isDefault = String.Empty; private decimal _dispIndex; private string _verNo = String.Empty; private string _enumValueAndName = String.Empty; #region Public Properties public decimal LangId { get { return _langId; } set { _langId = value; } } public decimal EnumTypeId { get { return _enumTypeId; } set { _enumTypeId = value; } } public string EnumValueId { get { return _enumValueId; } set { _enumValueId = value; } } public string EnumValueName { get { return _enumValueName; } set { _enumValueName = value; } } public string EnumValueName_2 { get { return _enumValueName_2; } set { _enumValueName_2 = value; } } public string IsDefault { get { return _isDefault; } set { _isDefault = value; } } public decimal DispIndex { get { return _dispIndex; } set { _dispIndex = value; } } public string VerNo { get { return _verNo; } set { _verNo = value; } } public string EnumValueAndName { get { return _enumValueAndName; } set { _enumValueAndName = value; } } #endregion } #endregion #region 全泰 账单解析类 public class Bill_detailsItem { /// /// 单证费 /// public string cost_name { get; set; } /// /// /// public string cost_unit { get; set; } /// /// /// public string cost_price { get; set; } /// /// /// public string cost_count { get; set; } /// /// /// public string cost_currency { get; set; } /// /// /// public string cost_amount { get; set; } } public class Bill_Head { /// /// 提单号 /// public string bill_no { get; set; } /// /// /// public string bill_date { get; set; } /// /// 正本提单 /// public string bill_type { get; set; } /// /// 已出单 /// public string bill_status { get; set; } /// /// /// public string bill_vessel { get; set; } /// /// /// public string bill_voyage { get; set; } /// /// /// public string bill_amount_usa { get; set; } /// /// /// public string bill_amount_rmb { get; set; } /// /// /// public string bill_container_type { get; set; } /// /// /// public string bill_container_count { get; set; } /// /// /// public string bill_remark { get; set; } /// /// /// public List bill_details { get; set; } } public class DealBillHelper { public DealBillHelper() { } public Bill_Head BillHead { get; set; } public opseae_md head { get; set; } public List ctnList { get; set; } public Int32 CtnNum { get; set; } public List NewFeeList { get; set; } private void addfee(ch_fee_md fee) { if (NewFeeList == null) NewFeeList = new List(); fee.CUSTOMERTYPE = "订舱代理"; fee.INPUTMODE = INPUTMODE; if (fee.AMOUNT != 0) { NewFeeList.Add(fee); } } private void addfee(List feeList) { if (feeList != null) { foreach (var fee in feeList) { addfee(fee); } } } public CommonDataContext cdc { get; set; } public User OP { get; set; } public DBResult CanMake { get; set; } const string INPUTMODE = "船公司费用自动导入"; public decimal UsdExchange { get; set; } = 1; private List 拆分费用参数 { get; set; } private List 账单费用名称配置 { get; set; } private List 台湾价格港口 { get; set; } private decimal GetPrice(string BILLFeeName) { if (拆分费用参数.Exists(x => x.EnumValueID == BILLFeeName)) { return Convert.ToDecimal(拆分费用参数.First(x => x.EnumValueID == BILLFeeName).EnumValueName); } return 0; } private bool ContainsPrice(string BILLFeeName) { if (拆分费用参数.Exists(x => x.EnumValueID == BILLFeeName)) { return true; } return false; } private List GetPriceList(string BILLFeeName) { var result = new List(); if (拆分费用参数.Exists(x => x.EnumValueID == BILLFeeName)) { var feestrList=拆分费用参数.First(x => x.EnumValueID == BILLFeeName).EnumValueName.Split(',').ToList(); foreach (var item in feestrList) { result.Add(Convert.ToDecimal(item)); } } return result; } private string GetFeeName(string BILLFeeName) { if (拆分费用参数.Exists(x => x.EnumValueID == BILLFeeName)) { return 拆分费用参数.First(x => x.EnumValueID == BILLFeeName).EnumValueName_2; } return ""; } private List GetBillFeeName(string LogicFeeName) { //其中 枚举类型.EnumValueName 对应 逻辑上的拆分模块 //EnumValueName_2 对应东胜的费用名称 //EnumValueID 对应报文中的文件名 if (账单费用名称配置.Exists(x => x.EnumValueName == LogicFeeName)) { return 账单费用名称配置.Where(x => x.EnumValueName == LogicFeeName).Select(s=>s.EnumValueID).ToList(); } return new List(); } private void SetUsd(ref ch_fee_md newfee) { newfee.CURRENCY = "USD"; newfee.EXCHANGERATE = UsdExchange; } public DealBillHelper(string str) { BillHead=JsonConvert.DeserializeObject(str); cdc=new CommonDataContext(); CanMake = new DBResult(); var opseaeList = cdc.OP_SEAE.Where(x => x.MBLNO == BillHead.bill_no).ToList(); if (opseaeList == null || opseaeList.Count == 0) { CanMake.SetErrorInfo("没有找到业务;"); } if (opseaeList != null && opseaeList.Count > 0) { CanMake.OK(); if (opseaeList.Count == 1) { head = opseaeList[0]; } else { if (opseaeList.Exists(x => x.MASTERNO == x.BSNO)) { head = opseaeList.First(x => x.MASTERNO == x.BSNO); } else { CanMake.SetErrorInfo("没有找到主业务;"); } } } if (CanMake.Success) { ctnList = cdc.OP_CTN.Where(x => x.BSNO == head.BSNO).ToList(); CtnNum = 0; if (ctnList != null && ctnList.Count > 0) { CtnNum = ctnList.Sum(x=>x.CTNNUM==null?0:(Int32)x.CTNNUM); } var bsdatestr = ((DateTime)head.BSDATE).ToString("yyyy-MM-dd"); UsdExchange = MsOpCtnApplyDAL.GetUsdExrate(bsdatestr, "USD"); } //20240528 判断解析业务的先决条件 //必须有 航线 卸货港 箱信息内必须要有 箱型箱量 if (string.IsNullOrWhiteSpace(head.LANE)) { CanMake.SetErrorInfo("业务没有录入航线;"); } if (string.IsNullOrWhiteSpace(head.PORTDISCHARGE)) { CanMake.SetErrorInfo("业务没有录入卸货港;"); } if (ctnList.Exists(x=>string.IsNullOrWhiteSpace(x.CTNALL) || x.CTNNUM==null||x.CTNNUM==0)) { CanMake.SetErrorInfo("存在缺少箱型箱量的集装箱信息;"); } OP = cdc.User.FirstOrDefault(x => x.SHOWNAME == head.OP); if (OP == null) { OP=cdc.User.FirstOrDefault(x => x.SHOWNAME == "系统管理员"); } 拆分费用参数 = cdc.tSysEnumValue.Where(x => x.EnumTypeID==45).ToList(); 账单费用名称配置 = cdc.tSysEnumValue.Where(x => x.EnumTypeID == 46).ToList(); 台湾价格港口 = cdc.tSysEnumValue.Where(x => x.EnumTypeID == 47).ToList(); var currfee = cdc.ch_fee.Where(x => x.BSNO == head.BSNO).ToList(); var nofeeCustList = new List { "青岛港国际物流","中外运","中创物流" }; if (currfee.Exists(x => nofeeCustList.Contains(x.CUSTOMERNAME) && x.FEETYPE == 2)) { CanMake.SetErrorInfo("业务已存在相关结算对象的费用;"); } } public DBResult GetFee() { var result = new DBResult(); result = Make_单证费(); result = Make_码头操作费(); result = Make_海运费(); result = Make_出口码头操作费(); if (CanMake.Success) { cdc.ch_fee.AddRange(NewFeeList); cdc.SaveChanges(); DoSendSuccessMail(); } else { if (!CanMake.Success) { //发出提醒邮件 DoSendErrorMail(); return CanMake; } } return result; } public DBResult Make_单证费() { var result = new DBResult(); result.OK(); /* * 【单证费】按单票 ,且不区分大小柜子及多少 , 450/票 【铅封费】按照柜,且不区分大小柜子,30/柜子 (24年3月份更改此需求从原33改为30,从中拆分出信息费用) 【信息费】按照柜,且不区分大小柜子,3/柜子 (24年3月份新增此需求) 【改单费】按票 400/票 (24年3月份新增此需求) 【船证费】按票 50/票或者 100/票 (24年3月份新增此需求) 规则: 先判断航线;东南亚航线无单证费,其他航线有单证费 在按柜子拆分出【铅封费】和【信息费】之后剩余的费用 若剩余金额等于0则表示没有【改单费】或者【船证费】, 若剩余金额等于400 则为【改单费】, 若剩余金额为 50或者100 则为【船证费】, 若剩余金额不等于0或者400或者50 或者100则按票回写(注:直接按票回写单证费就行,不要在拆分 铅封费和信息费等费用了) */ var 此模块需要对应的账单报文中费用名称List = GetBillFeeName("码头操作费"); if (!BillHead.bill_details.Exists(x => 此模块需要对应的账单报文中费用名称List.Contains( x.cost_name))) { return result; } var 单证费 = 0M; var 单证费原值 = 单证费; if (BillHead.bill_details.Exists(x => x.cost_name == "单证费")) { 单证费=Convert.ToDecimal(BillHead.bill_details.FirstOrDefault(x => x.cost_name == "单证费").cost_amount); 单证费原值 = 单证费; } else if (BillHead.bill_details.Exists(x => x.cost_name == "出口码头操作费--THC")) { 单证费=Convert.ToDecimal(BillHead.bill_details.FirstOrDefault(x => x.cost_name == "出口码头操作费--THC").cost_amount); 单证费原值 = 单证费; } else if (BillHead.bill_details.Exists(x => x.cost_name == "出口码头操作费")) { 单证费=Convert.ToDecimal(BillHead.bill_details.FirstOrDefault(x => x.cost_name == "出口码头操作费").cost_amount); 单证费原值 = 单证费; } var 单证费List = new List(); void add单证费(ch_fee_md newfee,op_ctn_md ctn) { if (单证费List.Exists(x => x.UNIT == ctn.CTNALL && x.FEENAME==newfee.FEENAME)) { 单证费List.First(x => x.UNIT == ctn.CTNALL).QUANTITY += 1; 单证费List.First(x => x.UNIT == ctn.CTNALL).AMOUNT += newfee.AMOUNT; 单证费List.First(x => x.UNIT == ctn.CTNALL).REMARK += ";" + ctn.CNTRNO; } else { 单证费List.Add(newfee); } 单证费 -= (decimal)newfee.AMOUNT; } if (ctnList != null && CtnNum > 0) { var 铅封费price = GetPrice("铅封费"); var 信息费price = GetPrice("信息费"); if (单证费 < CtnNum * (铅封费price + 信息费price)) { foreach (var ctn in ctnList) { //var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "海运费", 单价 * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); var 铅封费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "铅封费", 铅封费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); //var 信息费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "信息费", 信息费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); //SetUsd(ref 铅封费); //SetUsd(ref 信息费); add单证费(铅封费, ctn); //add单证费(信息费, ctn); } } else { foreach (var ctn in ctnList) { //var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "海运费", 单价 * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); var 铅封费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "铅封费", 铅封费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); var 信息费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "信息费", 信息费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); //SetUsd(ref 铅封费); //SetUsd(ref 信息费); add单证费(铅封费, ctn); add单证费(信息费, ctn); } } addfee(单证费List); if (单证费 > 0) { if (head.LANE != "DNY东南亚航线" && head.LANE != "东南亚航线") { var price = GetPrice("单证费"); var feename = GetFeeName("单证费"); var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, feename, price, "单票", 1); addfee(newfee); 单证费 -= (decimal)newfee.AMOUNT; } var 船证费List = GetPriceList("船证费"); var 改单费 = GetPrice("改单费"); if (船证费List.Contains(单证费)) { var 船证费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "船证费", 单证费, "单票", 1); addfee(船证费); } else if (单证费 == 改单费) { var _改单费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "改单费", 单证费, "单票", 1); addfee(_改单费); } else if (单证费 > 0) { var _单证费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "单证费", 单证费, "单票", 1); addfee(_单证费); } } else if (单证费 < 0) { CanMake.SetErrorInfo($"单证费原值{单证费原值},不足以按规则拆分成相应费用;"); } } return result; } public DBResult Make_码头操作费() { var result = new DBResult(); result.OK(); /* 2:THC/码头操作费:对应东胜系统【码头操作费】 【THC/码头操作费】按柜子,且区分大小柜子 "规则:判断卸货港录入的是不是:KAOHSIUNG (“台湾高雄”) " 《1》卸货港录入的是:KAOHSIUNG "规则:20尺的按照661RMB;40尺的按照992RMB;大冻柜1023RMB(40RH),小冻柜682RMB(20RH) 箱型有:(20OT/20FR/20TK/20HT/40HQ/40OT/40OH/40FR/40TK/40HT) " 《2》卸货港录入的不是:KAOHSIUNG 的 "规则:20尺的按照620RMB;40尺按照930RMB 箱型有:(20OT/20FR/20TK/20HT/40HQ/40OT/40OH/40FR/40TK/40HT)" */ var 此模块需要对应的账单报文中费用名称List = GetBillFeeName("码头操作费"); if (!BillHead.bill_details.Exists(x => 此模块需要对应的账单报文中费用名称List.Contains( x.cost_name)) || !(ctnList != null && ctnList.Count > 0)) { return result; } var 码头操作费Amount = Convert.ToDecimal(BillHead.bill_details.Where(x => 此模块需要对应的账单报文中费用名称List.Contains(x.cost_name)).Sum(c=>Convert.ToDecimal(c.cost_amount))); var _码头操作费原值 = 码头操作费Amount; var 码头操作费List = new List(); void 码头操作费Add(op_ctn_md ctn,decimal price) { var ctnnum = ctn.CTNNUM == null ? 0 : (Int32)ctn.CTNNUM; var amount = price * ctnnum; if (码头操作费Amount >= price) { if (码头操作费List.Exists(x => x.UNIT == ctn.CTNALL && x.UNITPRICE==price)) { 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price).QUANTITY += ctnnum; 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price).AMOUNT += amount; 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price).REMARK += ";"+ ctn.CNTRNO; 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price).setTax(); } else { var 码头操作费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "码头操作费", amount, ctn.CTNALL, ctnnum, "",ctn.CNTRNO); 码头操作费List.Add(码头操作费); } 码头操作费Amount -= amount; } else { CanMake.SetErrorInfo($"码头操作费原值{_码头操作费原值},不足以按规则拆分成相应费用;"); } } if (ctnList != null && CtnNum > 0) { //var 高雄20 = GetPrice("高雄20"); //var 高雄40 = GetPrice("高雄40"); //var 高雄20RH = GetPrice("高雄20RH"); //var 高雄40RH = GetPrice("高雄40RH"); //var ctn20 = GetPrice("20"); //var ctn40 = GetPrice("40"); //var All40RH = GetPrice("40RH"); var price = 0M; if (台湾价格港口.Exists(x=>x.EnumValueName== head.PORTDISCHARGE) ) { foreach (var ctn in ctnList) { //if (ctn.CTNALL == "20RH") { // 码头操作费Add(ctn, 高雄20RH); //}else if (ContainsPrice("高雄" + ctn.CTNALL) ) { price= GetPrice("高雄" + ctn.CTNALL); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "40") { price=GetPrice("高雄40"); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "20") { price = GetPrice("高雄20"); 码头操作费Add(ctn, price); } } } else { foreach (var ctn in ctnList) { if (ContainsPrice( ctn.CTNALL)) { price = GetPrice( ctn.CTNALL); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "40") { price= GetPrice("40"); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "20") { price = GetPrice("20"); 码头操作费Add(ctn, price); } } } if (码头操作费Amount > 0) { 码头操作费List.Clear(); //按规则无法拆分 改为一条 var _码头操作费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "码头操作费", _码头操作费原值, "单票", 1); //SetUsd(ref _码头操作费); addfee(_码头操作费); } else { addfee(码头操作费List); } } return result; } public DBResult Make_海运费() { var result = new DBResult(); result.OK(); /* 《1》:【海运费 】 按柜子回写,且选先判断下航线 欧洲航线和地中海航线有 ENS申报费(按票) 30美金 美加航线:AMS=美国舱单费(按票) 30美金 除以上3个航线外其他航线 无 (AMS或 ENS申报费) 如: 欧洲航线 ,海运费 2030 则:先拆分出: ENS申报费(按票) 30美金,之后 【海运费】(按柜子)均分剩余金额 《2》:若整除不开或者不符合规则此票按 按票回写 《3》:是否区分大小柜?此类属于不符合规则,则按票回写" */ var 此模块需要对应的账单报文中费用名称List = GetBillFeeName("海运费"); if (!BillHead.bill_details.Exists(x => 此模块需要对应的账单报文中费用名称List.Contains( x.cost_name ) || !(ctnList != null && ctnList.Count > 0))) { return result; } var 总Amount = Convert.ToDecimal(BillHead.bill_details.Where(x => 此模块需要对应的账单报文中费用名称List.Contains(x.cost_name)).Sum(c => Convert.ToDecimal(c.cost_amount))); var Amount原值 = 总Amount; var 海运费List = new List(); void 海运费Add(ch_fee_md newfee,op_ctn_md ctn=null) { if (总Amount >= newfee.AMOUNT) { if (ctn != null) { if (海运费List.Exists(x => x.UNIT == ctn.CTNALL && x.UNITPRICE==newfee.UNITPRICE)) { 海运费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == newfee.UNITPRICE).QUANTITY += newfee.QUANTITY; 海运费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == newfee.UNITPRICE).AMOUNT += newfee.AMOUNT; 海运费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == newfee.UNITPRICE).REMARK += ";" + ctn.CNTRNO; 海运费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == newfee.UNITPRICE).setTax(); } else { 海运费List.Add(newfee); } } else { 海运费List.Add(newfee); } 总Amount -= (decimal)newfee.AMOUNT; } else { CanMake.SetErrorInfo($"海运费原值{Amount原值},不足以按规则拆分成相应费用;"); } } if (ctnList != null && CtnNum > 0) { //1: 欧洲航线和地中海航线有 ENS申报费(按票) 30美金 //美加航线:AMS = 美国舱单费(按票) 30美金 //除以上3个航线外其他航线 无(AMS或 ENS申报费) var companyname = ConfigurationManager.AppSettings["COMPANYNAME"]; if (companyname == "全泰") { var 欧洲申报费 = GetPrice("海运费欧洲航线申报"); var 欧洲申报费FeeName = GetFeeName("海运费欧洲航线申报"); var 地中海申报费 = GetPrice("海运费地中海航线申报"); var 地中海申报费FeeName = GetFeeName("海运费地中海航线申报"); var 美加申报费 = GetPrice("海运费美加航线申报"); var 美加申报费FeeName = GetFeeName("海运费美加航线申报"); if (head.LANE == "欧洲航线") { var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, 欧洲申报费FeeName, 欧洲申报费, "单票", 1); SetUsd(ref newfee); 海运费Add(newfee); } if (head.LANE == "地中海(含北非)") { var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, 地中海申报费FeeName, 地中海申报费, "单票", 1); SetUsd(ref newfee); 海运费Add(newfee); } if (head.LANE == "美加航线") { var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, 美加申报费FeeName, 美加申报费, "单票", 1); SetUsd(ref newfee); 海运费Add(newfee); } } var 需拆分单价 = true; var 单价 = Math.Round(总Amount/ CtnNum, 2); if (单价 * CtnNum != 总Amount) { 需拆分单价 = false; } foreach (var ctn in ctnList) { if (ctnList.Exists(x => x.SIZE!=ctn.SIZE)) { 需拆分单价 = false; } } if (需拆分单价) { foreach (var ctn in ctnList) { var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "海运费", 单价*(decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); SetUsd(ref newfee); 海运费Add(newfee,ctn); } } if (!需拆分单价) { var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "海运费", 总Amount, "单票", 1); SetUsd(ref newfee); 海运费Add(newfee); } } addfee(海运费List); return result; } public DBResult Make_出口码头操作费() { var result = new DBResult(); result.OK(); /* 《1》:【海运费 】 按柜子回写,且选先判断下航线 欧洲航线和地中海航线有 ENS申报费(按票) 30美金 美加航线:AMS=美国舱单费(按票) 30美金 除以上3个航线外其他航线 无 (AMS或 ENS申报费) 如: 欧洲航线 ,海运费 2030 则:先拆分出: ENS申报费(按票) 30美金,之后 【海运费】(按柜子)均分剩余金额 《2》:若整除不开或者不符合规则此票按 按票回写 《3》:是否区分大小柜?此类属于不符合规则,则按票回写" */ //2024-718 东南亚航线 没有单证费 没有码头操作费 只有出口码头操作费 var 此模块需要对应的账单报文中费用名称List = GetBillFeeName("出口码头操作费"); if (!BillHead.bill_details.Exists(x => 此模块需要对应的账单报文中费用名称List.Contains( x.cost_name )) || !(ctnList != null && ctnList.Count > 0)) { return result; } var 总Amount = Convert.ToDecimal(BillHead.bill_details.Where(x => 此模块需要对应的账单报文中费用名称List.Contains(x.cost_name) ).Sum(c => Convert.ToDecimal(c.cost_amount))); var Amount原值 = 总Amount; var 码头操作费List = new List(); void 码头操作费Add(op_ctn_md ctn, decimal price,string FEENAME= "码头操作费") { var ctnnum = ctn.CTNNUM == null ? 0 : (Int32)ctn.CTNNUM; var amount = price * ctnnum; if (总Amount >= price) { if (码头操作费List.Exists(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price && x.FEENAME== FEENAME)) { 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price && x.FEENAME == FEENAME).QUANTITY += ctnnum; 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price && x.FEENAME == FEENAME).AMOUNT += amount; 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price && x.FEENAME == FEENAME).REMARK += ";" + ctn.CNTRNO; 码头操作费List.First(x => x.UNIT == ctn.CTNALL && x.UNITPRICE == price && x.FEENAME == FEENAME).setTax(); } else { //var 码头操作费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "码头操作费", price, ctn.CTNALL, 1, "", ctn.CNTRNO); var 码头操作费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, FEENAME, amount, ctn.CTNALL, ctnnum, "", ctn.CNTRNO); 码头操作费List.Add(码头操作费); } 总Amount -= amount; } else { CanMake.SetErrorInfo($"出口码头操作费原值{Amount原值},不足以按规则拆分成相应费用;"); } } void 出口码头操作费Add(ch_fee_md newfee) { if (总Amount >= newfee.AMOUNT) { 码头操作费List.Add(newfee); 总Amount -= (decimal)newfee.AMOUNT; } else { CanMake.SetErrorInfo($"出口码头操作费原值{Amount原值},不足以按规则拆分成相应费用;"); } } if (ctnList != null && CtnNum > 0) { //4:出口码头操作费--THC:对应东胜系统【码头操作费】 // 目前 船代上的[出口码头操作费--THC]是包含【单证费】和【铅封费】以及【码头操作费】,自动回写到系统需要自动分开 //( 注:此规则用于外运网站上的 出口码头操作费--THC) //【单证费】按单票 ,且不区分大小柜子及多少 , 450 / 票 //【铅封费】按照柜,且不区分大小柜子,33 / 柜子 //【码头操作费】按照柜,且不区分大小柜子 //规则:先根据航线判断-- - 是否减掉单证费(按票),东南亚航线无单证费;在判断卸货港是不是“台湾高雄”的 //《1》卸货港录入的是:KAOHSIUNG //"规则:20尺的按照661RMB;40尺的按照992RMB;大冻柜1023RMB(40RH),小冻柜682RMB(20RH) //箱型有:(20OT / 20FR / 20TK / 20HT / 40HQ / 40OT / 40OH / 40FR / 40TK / 40HT) //" //《2》卸货港录入的不是:KAOHSIUNG 的 //"规则:20尺的按照620RMB;40尺按照930RMB //箱型有:(20OT / 20FR / 20TK / 20HT / 40HQ / 40OT / 40OH / 40FR / 40TK / 40HT)" //"例如:船代上 【出口码头操作费--THC】显示为1413RMB的,不是东南亚航线,则拆成单证费450RMB(按票), //铅封费33RMB,码头操作费930;" if (head.LANE != "DNY东南亚航线" && head.LANE != "东南亚航线") { var 单证费price = GetPrice("单证费"); var feename = GetFeeName("单证费"); var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, feename, 单证费price, "单票", 1); 出口码头操作费Add(newfee); } var price = 0M; if (台湾价格港口.Exists(x => x.EnumValueName == head.PORTDISCHARGE)) { foreach (var ctn in ctnList) { //if (ctn.CTNALL == "20RH") { // 码头操作费Add(ctn, 高雄20RH); //}else if (ContainsPrice("高雄" + ctn.CTNALL)) { price = GetPrice("高雄" + ctn.CTNALL); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "40") { price = GetPrice("高雄40"); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "20") { price = GetPrice("高雄20"); 码头操作费Add(ctn, price); } } } else { foreach (var ctn in ctnList) { if (ContainsPrice(ctn.CTNALL)) { price = GetPrice(ctn.CTNALL); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "40") { price = GetPrice("40"); 码头操作费Add(ctn, price); } else if (ctn.SIZE == "20") { price = GetPrice("20"); 码头操作费Add(ctn, price); } } } } if (总Amount > 0) { //代表存在剩余尾数 先尝试处理铅封费信息费 var 铅封费price = GetPrice("铅封费"); var 信息费price = GetPrice("信息费"); if (总Amount < CtnNum * (铅封费price + 信息费price)) { foreach (var ctn in ctnList) { //var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "海运费", 单价 * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); var 铅封费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "铅封费", 铅封费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); //var 信息费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "信息费", 信息费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); //SetUsd(ref 铅封费); //SetUsd(ref 信息费); 码头操作费Add( ctn, 铅封费price, "铅封费"); //add单证费(信息费, ctn); } } else { foreach (var ctn in ctnList) { //var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "海运费", 单价 * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); var 铅封费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "铅封费", 铅封费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); var 信息费 = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "信息费", 信息费price * (decimal)ctn.CTNNUM, ctn.CTNALL, (decimal)ctn.CTNNUM); //SetUsd(ref 铅封费); //SetUsd(ref 信息费); 码头操作费Add(ctn, 铅封费price, "铅封费"); 码头操作费Add(ctn, 信息费price, "信息费"); } } } if (总Amount > 0) { //var feename = GetFeeName("码头操作费"); var newfee = MsChFeeDAL.getChFee(OP.GID, head.BSNO, head.FORWARDER, 2, "码头操作费", 总Amount, "单票", 1); 出口码头操作费Add(newfee); } addfee(码头操作费List); return result; } public void DoSendErrorMail() { //首先判断该业务的 op_logicinfo.propname= 账单解析错误 bsno=head.bsno的值是否存在 //如不存在设置为1 如存在判断其是否大于等于3,如大于等于3则不执行 var 已发次数 = BasicDataRefDAL.GetLogicValue_Str("账单解析错误", head.BSNO); if (string.IsNullOrWhiteSpace(已发次数)) { 已发次数 = "1"; BasicDataRefDAL.SaveLogicInfo_Str(head.BSNO, "账单解析错误", 已发次数); } else { var 已发次数int = Convert.ToInt32(已发次数); if (已发次数int >= 3) return; 已发次数int++; BasicDataRefDAL.SaveLogicInfo_Str(head.BSNO, "账单解析错误", 已发次数int.ToString()); } //向OP的邮箱发提醒邮件 var user_op = cdc.VW_user.FirstOrDefault(x => x.USERID == OP.GID); if (user_op == null) return; var OPEmail = cdc.VW_user.FirstOrDefault(x => x.USERID == OP.GID).EMAIL1; var email = OPEmail; var mailbody = $"提单号【{head.MBLNO}】,账单解析写入错误:
"; var bodystr = CanMake.Message.Replace(";,", "
"); //string toNames = "frank,lee"; mailbody += bodystr; var mailtopic = $"账单解析出错【{head.MBLNO}】"; var MAILTONAME = "admin@dongshengsoft.com"; var PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTONAME'"); if (PARAMVALUE.PARAMVALUE != "") MAILTONAME = PARAMVALUE.PARAMVALUE; var MAILTOPASSWORD = "ds!@#)(*"; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPASSWORD'"); if (PARAMVALUE.PARAMVALUE != "") MAILTOPASSWORD = PARAMVALUE.PARAMVALUE; var MAILTOSERVER = "smtpcom.263xmail.com"; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOSERVER'"); if (PARAMVALUE.PARAMVALUE != "") MAILTOSERVER = PARAMVALUE.PARAMVALUE; var MAILTOPORT = "465"; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPORT'"); if (PARAMVALUE.PARAMVALUE != "") MAILTOPORT = PARAMVALUE.PARAMVALUE; var MAILISSSL = false; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILISSSL'"); if (PARAMVALUE.PARAMVALUE == "1") MAILISSSL = true; SendEmail se = new SendEmail(email, MAILTONAME, "", "", mailtopic, mailbody, true); // SendEmail se = new SendEmail("dev001@dongshengsoft.com", "admin@dongshengsoft.com", "", "", mailtopic, mailbody, false); //string filePath = filename; //se.Attachments(filePath); try { se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法 // } catch (Exception e) { se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法 // } } public void DoSendSuccessMail() { //向OP的邮箱发提醒邮件 var user_op = cdc.VW_user.FirstOrDefault(x => x.USERID == OP.GID); if (user_op == null) return; var OPEmail = cdc.VW_user.FirstOrDefault(x => x.USERID == OP.GID).EMAIL1; var email = OPEmail; var mailbody = $"尊敬的{OP.SHOWNAME},您好:
船名:{head.VESSEL},航次:{head.VOYNO},提单号【{head.MBLNO}】的账单解析成功"; var bodystr = CanMake.Message.Replace(";,", "
"); //string toNames = "frank,lee"; mailbody += bodystr; var mailtopic = $"【账单解析成功】:船名:{head.VESSEL},航次:{head.VOYNO},提单号 {head.MBLNO} 账单下载成功"; var MAILTONAME = "admin@dongshengsoft.com"; var PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTONAME'"); if (PARAMVALUE.PARAMVALUE != "") MAILTONAME = PARAMVALUE.PARAMVALUE; var MAILTOPASSWORD = "ds!@#)(*"; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPASSWORD'"); if (PARAMVALUE.PARAMVALUE != "") MAILTOPASSWORD = PARAMVALUE.PARAMVALUE; var MAILTOSERVER = "smtpcom.263xmail.com"; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOSERVER'"); if (PARAMVALUE.PARAMVALUE != "") MAILTOSERVER = PARAMVALUE.PARAMVALUE; var MAILTOPORT = "465"; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPORT'"); if (PARAMVALUE.PARAMVALUE != "") MAILTOPORT = PARAMVALUE.PARAMVALUE; var MAILISSSL = false; PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILISSSL'"); if (PARAMVALUE.PARAMVALUE == "1") MAILISSSL = true; SendEmail se = new SendEmail(email, MAILTONAME, "", "", mailtopic, mailbody, true); // SendEmail se = new SendEmail("dev001@dongshengsoft.com", "admin@dongshengsoft.com", "", "", mailtopic, mailbody, false); //string filePath = filename; //se.Attachments(filePath); try { se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法 // } catch (Exception e) { se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法 // } } } #endregion }