From 29d217a14557a911d5f51034e6803568cbd086a1 Mon Sep 17 00:00:00 2001 From: luanhui <1029149336@qq.com> Date: Thu, 25 Jan 2018 18:59:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E5=AE=B0=E7=BB=93=E7=AE=97=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bills/StatPay_/StatPayEdit.cs | 1 + .../BL/Bills/StatPay/StatPayBL.cs | 7 + .../SubKillWeightBill/SubKillWeightBillBL.cs | 128 ++++++++++++++++++ B3SubstituteKill/BO/Bills/StatPay/StatPay.cs | 7 +- .../BO/Bills/StatPay/StatPay_CostDetail.cs | 3 + 5 files changed, 144 insertions(+), 2 deletions(-) diff --git a/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs b/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs index 296cf20..d2cfaf7 100644 --- a/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs +++ b/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs @@ -108,6 +108,7 @@ __DFContainer.setValue('PriceBill_ID',''); _costDetail = titlePanel.EAdd(new DFEditGrid(editor) { Width = Unit.Percentage(100) }); _costDetail.Columns.Add(new DFEditGridColumn("SubKillProductLine_Name")); _costDetail.Columns.Add(new DFEditGridColumn("GenerationCostItem_Name")); + _costDetail.Columns.Add(new DFEditGridColumn("Number")); _costDetail.Columns.Add(new DFEditGridColumn("Price")); _costDetail.Columns.EAdd(new DFEditGridColumn("Money")); var section = mPageLayoutManager.AddSection("CostDetail", "代宰费用"); diff --git a/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs b/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs index a4b0039..484dc24 100644 --- a/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs +++ b/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs @@ -16,5 +16,12 @@ namespace BWP.B3SubstituteKill.BL public class StatPayBL : DepartmentWorkFlowBillBL, IStatPayBL { + protected override void beforeSave(StatPay dmo) + { + dmo.CostMoney = dmo.CostDetails.Sum(x => (x.Money ?? 0).Value); + dmo.CallbackPayMoney = dmo.CallbackPayDetails.Sum(x => (x.Money ?? 0).Value); + dmo.ReceiveMoney = (dmo.CostMoney ?? 0) - (dmo.CallbackPayMoney ?? 0); + base.beforeSave(dmo); + } } } diff --git a/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs b/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs index 90e7a72..6ed84b8 100644 --- a/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs +++ b/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs @@ -7,6 +7,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using BWP.B3Frameworks; +using BWP.B3Frameworks.BO.NamedValueTemplate; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.SqlDoms; +using Forks.Utils; using TSingSoft.WebPluginFramework; namespace BWP.B3SubstituteKill.BL @@ -32,5 +38,127 @@ namespace BWP.B3SubstituteKill.BL dmo.Weight = dmo.Details.Sum(x => x.Weight.EToDecimal() ?? 0); base.beforeSave(dmo); } + + protected override void doUnCheck(SubKillWeightBill dmo) + { + DeleteNotCheckedStatPay(dmo); + base.doUnCheck(dmo); + } + + private void DeleteNotCheckedStatPay(SubKillWeightBill dmo) + { + var queryDom = new DQueryDom(new JoinAlias(typeof(StatPay))); + queryDom.Columns.Add(DQSelectColumn.Field("ID")); + queryDom.Where.Conditions.Add(DQCondition.EQ("Weigh_ID", dmo.ID)); + var id = (long?)Session.ExecuteScalar(queryDom); + if (id == null) + { + return; + } + var statPayBL = BIFactory.Create(Session); + var statPay = statPayBL.Load(id.Value); + if (statPay != null) + { + if (statPay.BillState != 单据状态.未审核) + { + throw new ApplicationException("结算单 No." + statPay.ID + statPay.BillState + ",不能执行此操作。"); + } + statPayBL.Delete(statPay); + AppendMessage("删除结算单No." + statPay.ID); + } + } + + protected override void doCheck(SubKillWeightBill dmo) + { + CreateStatPay(dmo); + base.doCheck(dmo); + } + + private void CreateStatPay(SubKillWeightBill dmo) + { + var statPay = new StatPay(); + statPay.AccountingUnit_ID = dmo.AccountingUnit_ID; + statPay.Domain_ID = dmo.Domain_ID; + statPay.Department_ID = dmo.Department_ID; + statPay.Employee_ID = dmo.Employee_ID; + statPay.Date = dmo.Date; + statPay.Weigh_ID = dmo.ID; + statPay.Supplier_ID = dmo.Supplier_ID; + statPay.Number = dmo.Number; + statPay.Weight = dmo.Weight; + statPay.PriceBill_ID = dmo.PriceBill_ID; + + var subKillPriceBill = GetSubKillPriceBill(dmo); + if (subKillPriceBill != null) + { + foreach (SubKillWeightBill_Detail wdetail in dmo.Details) + { + foreach (SubKillPriceBill_CostItemDetail costItemDetail in subKillPriceBill.CostItemDetails) + { + var detail = new StatPay_CostDetail(); + detail.SubKillProductLine_ID = wdetail.SubKillProductLine_ID; + detail.GenerationCostItem_ID = costItemDetail.GenerationCostItem_ID; + detail.Price = costItemDetail.Price; + detail.Number = wdetail.Number; + detail.Money = detail.Price * detail.Number; + statPay.CostDetails.Add(detail); + } + + foreach (SubKillPriceBill_CallBackDetail callBackDetail in subKillPriceBill.CallBackDetails) + { + var detail = new StatPay_CallbackPayDetail(); + detail.SubKillCallBack_ID = callBackDetail.SubKillCallBack_ID; + detail.Price = callBackDetail.Price; + detail.Money = callBackDetail.Price * wdetail.Number; + statPay.CallbackPayDetails.Add(detail); + } + } + } + else + { + foreach (SubKillWeightBill_Detail wdetail in dmo.Details) + { + var detail = new StatPay_CostDetail(); + detail.SubKillProductLine_ID = wdetail.SubKillProductLine_ID; + detail.Number = wdetail.Number; + detail.Money = detail.Price * detail.Number; + statPay.CostDetails.Add(detail); + } + } + BIFactory.Create(Session).Insert(statPay); + AppendMessage("生成代宰结算单:" + statPay.ID); + } + + private SubKillPriceBill GetSubKillPriceBill(SubKillWeightBill dmo) + { + var pricebillid = GetSubKillPriceBillID(dmo); + if (pricebillid == null) + { + return null; + } + + var pricebill = BIFactory.Create(Session).Load(pricebillid.Value); + return pricebill; + } + + private long? GetSubKillPriceBillID(SubKillWeightBill dmo) + { + var bill = new JoinAlias(typeof(SubKillPriceBill)); + var detail = new JoinAlias(typeof(SubKillPriceBill_SupplierDetail)); + var query = new DQueryDom(bill); + query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "SubKillPriceBill_ID")); + query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID)); + query.Where.Conditions.Add(DQCondition.LessThanOrEqual("Date", dmo.Date)); + query.Where.Conditions.Add(DQCondition.EQ(bill, "AccountingUnit_ID", dmo.AccountingUnit_ID)); + query.Where.Conditions.Add(DQCondition.EQ(bill, "Department_ID", dmo.Department_ID)); + query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核)); + query.Where.Conditions.Add(DQCondition.EQ(detail, "Supplier_ID", dmo.Supplier_ID)); + + query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); + query.Columns.Add(DQSelectColumn.Field("ID", bill)); + + return query.EExecuteScalar(Session); + + } } } diff --git a/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs b/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs index 1d8cfd9..59611a4 100644 --- a/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs +++ b/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs @@ -63,11 +63,11 @@ namespace BWP.B3SubstituteKill.BO [LogicName("代宰头数")] [DFExtProperty("WebControlType", DFEditControl.StaticText)] - public int Number { get; set; } + public int? Number { get; set; } [LogicName("代宰重量")] [DFExtProperty("WebControlType", DFEditControl.StaticText)] - public Money Weight { get; set; } + public Money? Weight { get; set; } [LogicName("价格单号")] [DFExtProperty("WebControlType", DFEditControl.StaticText)] @@ -91,6 +91,9 @@ namespace BWP.B3SubstituteKill.BO public DateTime? WeighTime { get; set; } + public Money<金额>? CostMoney { get; set; } + public Money<金额>? CallbackPayMoney { get; set; } + private StatPay_CostDetailCollection _mCostDetails = new StatPay_CostDetailCollection(); [OneToMany(typeof(StatPay_CostDetail), "ID")] [Join("ID", "StatPay_ID")] diff --git a/B3SubstituteKill/BO/Bills/StatPay/StatPay_CostDetail.cs b/B3SubstituteKill/BO/Bills/StatPay/StatPay_CostDetail.cs index 2141848..14bfae7 100644 --- a/B3SubstituteKill/BO/Bills/StatPay/StatPay_CostDetail.cs +++ b/B3SubstituteKill/BO/Bills/StatPay/StatPay_CostDetail.cs @@ -25,6 +25,9 @@ namespace BWP.B3SubstituteKill.BO [LogicName("单价")] public Money? Price { get; set; } + [LogicName("头数")] + public int? Number { get; set; } + [LogicName("金额")] public Money<金额>? Money { get; set; }