using DS.Module.Core; using DS.Module.Core.Extensions; using DS.Module.UserModule; using DS.WMS.Core.FeeModule.Entity; using DS.WMS.Core.FeeModule.Interface; using DS.WMS.Core.WmsModule.Entity; using Mapster; using Microsoft.Extensions.DependencyInjection; using SqlSugar; namespace DS.WMS.Core.FeeModule.Method; /// /// 费用公共方法 /// public class WmsFeeComonService:IWmsFeeComonService { private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; private readonly IUser user; /// /// 构造函数 /// /// public WmsFeeComonService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); user = _serviceProvider.GetRequiredService(); } public DataResult> InitOpWmsStoreRate(Guid wmsId, List doFees, Guid? feeTypeGid) { var res = new List(); if (feeTypeGid.IsNull()) { feeTypeGid = doFees.Where(x => x.GoodsFeeTypeGID.IsNotNull()).First().GoodsFeeTypeGID; } foreach (var item in doFees) { if (item.GOODSFEETYPE.IsNullOrEmpty() || item.GoodsFeeTypeGID == feeTypeGid) { var newfeerate = item.Adapt(); newfeerate.PID = wmsId; res.Add(newfeerate); } } return DataResult>.Success(res); } public DataResult InitOpWmsPayInfo(OP_WMS_IN_DO inDo, OP_WMS wms) { var res = new OP_WMS_FEEPAYINFO(); // res.GID = Guid.NewGuid(); res.WMSID = wms.WMSID; res.WMSBASEID = wms.WMSBASEID==null?Guid.Empty: (Guid)wms.WMSBASEID; res.FEESTARTDATE = (DateTime)wms.FEESTARTDATE; res.ARCLIENTWMSOUT = wms.ARCLIENTWMSOUT; res.ARCLIENTWMSIN = wms.ARCLIENTWMSOUT; res.ARCLIENTWMS_OUTDO = wms.ARCLIENTWMSOUT; res.APCLIENTWMSOUT = inDo.APCLIENTWMSOUT; res.APCLIENTWMSIN = inDo.APCLIENTWMSOUT; res.APCLIENTWMS_OUTDO = inDo.APCLIENTWMSOUT; res.STORAGEUNITCOUNT = wms.STORAGEUNITCOUNT; res.FEERATEWMSID = wms.WMSID; res.SOURCEDOID = wms.WMSID; return DataResult.Success(res); } public DataResult> InitOpWmsFee(List doFees, List details, OP_WMS_IN_DO inDo,List codeFees) { var res = new List(); foreach (var item in doFees) { if (item.FEEMAKETYPE=="入库现结") { decimal num = 0.0m; if (item.DEFAULTUNIT == "计费单位") { foreach (var detail in details) { num += (decimal)(detail.STORAGEUNITCOUNT); } }; if (item.DEFAULTUNIT == "单票") num = 1; if (item.DEFAULTUNIT == "单柜") { //遍历入库执行明细 看看有几个箱号 var cntrnolist = new List(); foreach (var detail in details) { if (!cntrnolist.Exists(x => x == detail.CNTRNO)) { cntrnolist.Add(detail.CNTRNO); } } num = cntrnolist.Count(); }; decimal amount = num * item.FEEPRICE.ToDecimal(); if (amount != 0) { if (res.Count == 0 || !res.Any(e => e.FeeId == item.FeeId)) { var codefee = codeFees.First(x => x.GID == item.FeeId); //给列表增加一条费用 var newfee = new Fee() { GID = Guid.NewGuid().ToString(), ClientId = inDo.ClientId, FeeId = codefee.GID, SETTLEMENT = 0, ORDERAMOUNT = 0, ORDERINVOICE = 0, ORDERINVSETTLEMENT = 0, INVOICE = 0, CURRENCY = "RMB", EXCHANGERATE = 1, ENTERDATE = DateTime.Now, ENTEROPERATOR = user.GetUserGID(), FEESTATUS = 1, TAXRATE = 0, ISADVANCEDPAY = false, ISINVOICE = false, ISCRMORDERFEE = false, INPUTMODE = "月结", }; newfee.BSNO = inDo.WMSDOID.ToString().ToUpper(); //newfee.SetCreateDefaultVal(); newfee.FEENAME = item.FEENAME; newfee.UNITPRICE = item.FEEPRICE; newfee.QUANTITY = num; newfee.AMOUNT = amount; newfee.CUSTOMERNAME = inDo.CUSTOMERNAME; newfee.FEETYPE = item.FEETYPE; newfee.setTax(ref newfee); res.Add(newfee); } else { var fee = res.First(e => e.FEENAME == item.FEENAME); var index = res.IndexOf(fee); fee.QUANTITY = fee.QUANTITY + num; fee.AMOUNT = fee.AMOUNT + amount; fee.setTax(ref fee); res[index] = fee; } } } } return DataResult>.Success(res); } public DataResult> InitMoveOpWmsStoreRate(Guid wmsId, List storeRate) { var res = new List(); foreach (var item in storeRate) { var newfeerate = item.Adapt(); newfeerate.PID = wmsId; newfeerate.GID = Guid.NewGuid(); res.Add(newfeerate); } return DataResult>.Success(res); } }