diff --git a/B3QingDaoWanFu.Web/B3QingDaoWanFu.Web.csproj b/B3QingDaoWanFu.Web/B3QingDaoWanFu.Web.csproj index 8218881..5180777 100644 --- a/B3QingDaoWanFu.Web/B3QingDaoWanFu.Web.csproj +++ b/B3QingDaoWanFu.Web/B3QingDaoWanFu.Web.csproj @@ -170,10 +170,21 @@ ASPXCodeBehind - + + ASPXCodeBehind + ASPXCodeBehind + + ASPXCodeBehind + + + ASPXCodeBehind + + + ASPXCodeBehind + ASPXCodeBehind diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/PayEdit_Ext.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/PayEdit_Ext.cs index cfc3903..d7a3c8f 100644 --- a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/PayEdit_Ext.cs +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/PayEdit_Ext.cs @@ -14,6 +14,8 @@ using BWP.B3ButcherManage.NamedValueTemplate; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.SqlDoms; +using TSingSoft.WebPluginFramework; +using Forks.Utils; namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays { @@ -28,10 +30,6 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays protected override void BuildBody(System.Web.UI.Control control) { base.BuildBody(control); - if (CanSave) - { - dialogButton.BeforeClientClick += " var pt=__DFContainer.getValue('PayTarget'); if (pt == '') { alert('先选择付款对象');return false;}"; - } AddFarmerDetails(control.EAdd(new TitlePanel("养殖户明细", "养殖户明细"))); } @@ -62,7 +60,12 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays protected override void AfterSelectedStatPay(IList payDetails) { _farmerGrid.GetFromUI(); - mDFContainer.GetFromUIParitially("PayTarget"); + var v = new List(); + v.AddRange(payDetails.Select(x => x.StatPay_ID??0).Distinct()); + v.AddRange(Dmo.Details.Select(x => x.StatPay_ID ?? 0).Distinct()); + var payTarget = CheckPayTargetSame(v.Distinct()); + Dmo.PayTarget = payTarget; + mDFContainer.ApplyToUIParitially("PayTarget"); if (Dmo.PayTarget != 付款对象.养殖户) return; var ids = payDetails.Select(x => x.StatPay_ID).Where(x => x.HasValue); @@ -72,6 +75,18 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays _farmerGrid.DataBind(); } + NamedValue<付款对象>? CheckPayTargetSame(IEnumerable statpayIDs) + { + var query = new DQueryDom(new JoinAlias(typeof(StatPay))); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), statpayIDs.Select(x => DQExpression.Value(x)).ToArray())); + query.Columns.Add(DQSelectColumn.Field("PayTarget")); + query.GroupBy.Expressions.Add(DQExpression.Field("PayTarget")); + var list = query.EExecuteList?>(); + if (list.Count > 1) + throw new Exception("选择的结算单 付款对象必须一致"); + return list.FirstOrDefault(); + } + void AddFarmerDetails(IEnumerable statpayIDs) { var stat = new JoinAlias(typeof(StatPay)); diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/SelectStatPayDialog_Ext.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/SelectStatPayDialog_Ext.cs new file mode 100644 index 0000000..6ff8622 --- /dev/null +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/SelectStatPayDialog_Ext.cs @@ -0,0 +1,26 @@ +using BWP.B3ButcherManage.NamedValueTemplate; +using BWP.Web.Pages.B3ButcherManage.Bills.Pay_; +using BWP.Web.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebControls2; + +namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays +{ + class SelectStatPayDialog_Ext : SelectStatPayDialog + { + protected override void AddCustomerCondition(TSingSoft.WebControls2.TableLayoutPanel tablePanel, int left, int top) + { + tablePanel.Add(left, ++left, top, top + 1, new SimpleLabel("付款对象")); + tablePanel.Add(left, ++left, top, top + 1, mQueryContainer.Add(QueryCreator.DFNameValueInput<付款对象>(mDFInfo.Fields["PayTarget"]), "PayTarget")); + } + + protected override void CreateQueryGridColumns(DFBrowseGrid grid) + { + base.CreateQueryGridColumns(grid); + grid.Columns.Add(new DFBrowseGridColumn("PayTarget")); + } + } +} diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayEdit_Ext.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayEdit_Ext.cs index e1eea3c..db2f806 100644 --- a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayEdit_Ext.cs +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayEdit_Ext.cs @@ -20,6 +20,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays var tag = config.Items.FirstOrDefault(x => x.Key == "WeightSumRate"); if (tag != null) tag.Key = "WeightSumRate2"; + config.Add("PayTarget"); } DFEditGrid _farmerGrid; diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayList_Ext.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayList_Ext.cs index 3280c84..3f9cc01 100644 --- a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayList_Ext.cs +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/StatPayList_Ext.cs @@ -9,6 +9,19 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays { class StatPayList_Ext : StatPayList { + protected override void AddCustomerCondition(Layout.LayoutManager panel, Layout.AutoLayoutConfig config) + { + base.AddCustomerCondition(panel, config); + config.Add("PayTarget"); + } + + protected override void AddDFBrowseGridColumn(DFBrowseGrid grid, string field) + { + base.AddDFBrowseGridColumn(grid, field); + if (field == "Supplier_Name") + AddDFBrowseGridColumn(grid, "PayTarget"); + } + protected override void InitToolBar(TSingSoft.WebControls2.HLayoutPanel toolbar) { base.InitToolBar(toolbar); diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/WeighBillList_Ext.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/WeighBillList_Ext.cs new file mode 100644 index 0000000..a5bf4bb --- /dev/null +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/WeighBillList_Ext.cs @@ -0,0 +1,25 @@ +using BWP.Web.Layout; +using BWP.Web.Pages.B3ButcherManage.Bills.WeighBill_; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays +{ + class WeighBillList_Ext : WeighBillList + { + protected override void AddCustomerCondition(LayoutManager panel, AutoLayoutConfig config) + { + base.AddCustomerCondition(panel, config); + config.Add("PayTarget"); + } + + protected override void AddDFBrowseGridColumn(TSingSoft.WebControls2.DFBrowseGrid grid, string field) + { + base.AddDFBrowseGridColumn(grid, field); + if (field == "Supplier_Name") + AddDFBrowseGridColumn(grid, "PayTarget"); + } + } +} diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/WeightBillEdit_Ext.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/WeightBillEdit_Ext.cs new file mode 100644 index 0000000..300d73e --- /dev/null +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Overlays/WeightBillEdit_Ext.cs @@ -0,0 +1,17 @@ +using BWP.Web.Pages.B3ButcherManage.Bills.WeighBill_; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.Web.Pages.B3QingDaoWanFu.Overlays +{ + class WeightBillEdit_Ext : WeighBillEdit + { + protected override void AddCustomerConfig(Layout.AutoLayoutConfig config) + { + base.AddCustomerConfig(config); + config.Add("PayTarget"); + } + } +} diff --git a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Reports/StatPayAnalyse.cs b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Reports/StatPayAnalyse.cs index 1b234b6..aa31388 100644 --- a/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Reports/StatPayAnalyse.cs +++ b/B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Reports/StatPayAnalyse.cs @@ -138,7 +138,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports mDisplayHelper.AddOptionItem("棚前头数", "_detail", "Number", false, true); mDisplayHelper.AddOptionItem("棚前重量", "_detail", "ExeWeight", false, true); mDisplayHelper.AddOptionItem("棚前金额", "_detail", "ExtMoney", false, true); - mDisplayHelper.AddOptionItem("付款对象", "_pay", "PayTarget", false); + mDisplayHelper.AddOptionItem("付款对象", "_bill", "PayTarget", false); AddQueryOption("选项", mDisplayHelper.GetAllDisplayNames(), mDisplayHelper.GetDefaultSelelectedDisplayNames()); base.AddQueryOptions(vPanel); @@ -151,42 +151,15 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports var root = query.From.RootSource.Alias; var weight = new JoinAlias("_weight", typeof(WeighBill)); var detail = new JoinAlias("_detail", typeof(Weigh_FarmerDetail)); - var pay = new JoinAlias("_pay", typeof(PayTemp)); - PayTemp.Register(query); query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.EQ(root, "Weigh_ID", weight, "ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(root, "Weigh_ID", detail, "Weigh_ID")); - query.From.AddJoin(JoinType.Left, new DQDmoSource(pay), DQCondition.EQ(pay, "StatPay_ID", root, "ID")); mDisplayHelper.AddAlias("_bill", root); mDisplayHelper.AddAlias("_weight", weight); mDisplayHelper.AddAlias("_detail", detail); - mDisplayHelper.AddAlias("_pay", pay); mDisplayHelper.AddSelectColumns(query, (name) => OptionIsSelected("选项", name), SumColumnNames, ColumnNames); query.Where.Conditions.Add(DQCondition.EQ(root, "Domain_ID", DomainContext.Current.ID)); return query; } - - class PayTemp - { - public long StatPay_ID { get; set; } - - public NamedValue<付款对象>? PayTarget { get; set; } - - public static void Register(DQueryDom root) - { - var payDetail = new JoinAlias(typeof(Pay_Detail)); - var pay = new JoinAlias("_pay", typeof(Pay)); - - var query = new DQueryDom(pay); - query.From.AddJoin(JoinType.Inner, new DQDmoSource(payDetail), DQCondition.EQ(payDetail, "Pay_ID", pay, "ID")); - query.Columns.Add(DQSelectColumn.Field("StatPay_ID", payDetail)); - query.Columns.Add(DQSelectColumn.Field("PayTarget")); - query.GroupBy.Expressions.Add(DQExpression.Field(payDetail, "StatPay_ID")); - query.GroupBy.Expressions.Add(DQExpression.Field("PayTarget")); - query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.EQ("Domain_ID", DomainContext.Current.ID))); - - root.RegisterQueryTable(typeof(PayTemp), new string[] { "StatPay_ID", "PayTarget" }, query); - } - } } } diff --git a/B3QingDaoWanFu.Web/PluginClass.cs b/B3QingDaoWanFu.Web/PluginClass.cs index 53e1a09..e1ae848 100644 --- a/B3QingDaoWanFu.Web/PluginClass.cs +++ b/B3QingDaoWanFu.Web/PluginClass.cs @@ -12,6 +12,7 @@ using BWP.Web.Pages.B3Sale.Bills.SaleOutStore_; using TSingSoft.WebPluginFramework; using TSingSoft.WebPluginFramework.Pages; using TSingSoft.WebPluginFramework.TimerTasks; +using BWP.Web.Pages.B3ButcherManage.Bills.WeighBill_; namespace BWP.B3QingDaoWanFu { @@ -25,6 +26,9 @@ namespace BWP.B3QingDaoWanFu WpfPageFactory.RegisterPageOverlay(typeof(StatPayList).FullName, typeof(StatPayList_Ext).FullName); WpfPageFactory.RegisterPageOverlay(typeof(BWP.Web.Pages.B3ButcherManage.Bills.Pay_.PayEdit).FullName, typeof(PayEdit_Ext).FullName); WpfPageFactory.RegisterPageOverlay(typeof(BWP.Web.Pages.B3ButcherManage.Reports.PayAnalyse).FullName, typeof(PayAnalyse_Ext).FullName); + WpfPageFactory.RegisterPageOverlay(typeof(WeighBillEdit).FullName, typeof(WeightBillEdit_Ext).FullName); + WpfPageFactory.RegisterPageOverlay(typeof(WeighBillList).FullName, typeof(WeighBillList_Ext).FullName); + WpfPageFactory.RegisterPageOverlay(typeof(BWP.Web.Pages.B3ButcherManage.Bills.Pay_.SelectStatPayDialog).FullName, typeof(SelectStatPayDialog_Ext).FullName); GlobalFlags.On(B3ButcherManageConsts.GlobalFlags.StatPayAddRewardWithButcherUseWeight); GlobalFlags.On(B3SaleConsts.Flags.MarketingActivityEnableAdjustPrice); GlobalFlags.On(B3SaleConsts.Flags.SendOutStoreNoAvailableStorage); diff --git a/B3QingDaoWanFu/B3QingDaoWanFu.csproj b/B3QingDaoWanFu/B3QingDaoWanFu.csproj index fa6f2dc..372f1c5 100644 --- a/B3QingDaoWanFu/B3QingDaoWanFu.csproj +++ b/B3QingDaoWanFu/B3QingDaoWanFu.csproj @@ -175,6 +175,7 @@ + diff --git a/B3QingDaoWanFu/TypeIOCs/PayBLTypeIoc.cs b/B3QingDaoWanFu/TypeIOCs/PayBLTypeIoc.cs index e245a98..afb003b 100644 --- a/B3QingDaoWanFu/TypeIOCs/PayBLTypeIoc.cs +++ b/B3QingDaoWanFu/TypeIOCs/PayBLTypeIoc.cs @@ -16,6 +16,8 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs { public void Invoke(IDmoContext context, Pay dmo) { + if (dmo.PayTarget == null) + throw new Exception("付款对象不能为空"); if (dmo.PayTarget != 付款对象.养殖户) return; var farmerMoney = dmo.FarmerDetails.Sum(x => x.Money.EToDecimal() ?? 0); diff --git a/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs b/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs index 988fd06..3e1c8a0 100644 --- a/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs +++ b/B3QingDaoWanFu/TypeIOCs/StatPayBLTypeIoc.cs @@ -28,63 +28,48 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs // } //} - [TypeIOC(typeof(StatPayBL), typeof(StatPayBL.BaseBLIOCs.AfterInsert))] - public class StatPayAfterInsertBLTypeIoc : StatPayBL.BaseBLIOCs.AfterInsert + [TypeIOC(typeof(StatPayBL), typeof(StatPayBL.BaseBLIOCs.BeforeInsert))] + public class StatPayAfterInsertBLTypeIoc : StatPayBL.BaseBLIOCs.BeforeInsert { public void Invoke(IDmoContext context, StatPay dmo) { if (dmo.Weigh_ID == null) return; - var details = GetFarmerDetail(context.Session, dmo.Weigh_ID.Value); - var total = details.Sum(x => x.Item2 ?? 0); + var details = GetFarmerDetails(dmo.Weigh_ID.Value); foreach (var detail in details) { - var arr = new List>(); - if (total != 0) + if ((dmo.RealNumber ?? 0) != 0) { - var v = dmo.RealWeight * detail.Item2 / total; - if (v.HasValue) + detail.ExeWeight = dmo.RealWeight * detail.Number / dmo.RealNumber; + var money = detail.Money; + if (dmo.PurchaseType_Name == "业务" && dmo.PayTarget == 付款对象.养殖户) { - v = decimal.Round(v.Value, 2); - arr.Add(new Tuple("ExeWeight", v)); + var extMoney = dmo.JingJianFee / dmo.RealNumber * detail.Number; + if (extMoney.HasValue) + extMoney = decimal.Round(extMoney.Value, 2); + money += (extMoney ?? 0); } + detail.ExtMoney = money; } - if (detail.Item3 != null) - { - arr.Add(new Tuple("ExtMoney", detail.Item3)); - } - if (arr.Any()) - UpdateProperty(detail.Item1, context.Session, arr.ToArray()); + + dmo.FarmerDetails.Add(detail); } } - List> GetFarmerDetail(IDmoSession session, long weightID) + IEnumerable GetFarmerDetails(long weightID) { - var query = new DQueryDom(new JoinAlias(typeof(Weigh_FarmerDetail))); + var query = new DmoQuery(typeof(Weigh_FarmerDetail)); query.Where.Conditions.Add(DQCondition.EQ("Weigh_ID", weightID)); - query.Columns.Add(DQSelectColumn.Field("ID")); - query.Columns.Add(DQSelectColumn.Field("Number")); - query.Columns.Add(DQSelectColumn.Field("Money")); - return query.EExecuteList(session); - } - - void UpdateProperty(long id, IDmoSession session, params Tuple[] par) - { - var update = new DQUpdateDom(typeof(Weigh_FarmerDetail)); - update.Where.Conditions.Add(DQCondition.EQ("ID", id)); - foreach (var item in par) - update.Columns.Add(new DQUpdateColumn(item.Item1, item.Item2)); - session.ExecuteNonQuery(update); + return query.EExecuteList().Cast(); } } - - [TypeIOC(typeof(StatPayBL), typeof(StatPayBL.BaseBLIOCs.AfterSave))] public class StatPayAfterSaveBLTypeIoc : StatPayBL.BaseBLIOCs.AfterSave { public void Invoke(IDmoContext context, StatPay dmo) { + CompareDetailMoney(dmo); var 死猪奖罚设置ID = 36; dmo.DeadPigRewardMoney = dmo.OtherRewardDetails.Where(x => x.Sanction_ID == 死猪奖罚设置ID).Sum(x => (x.Money ?? 0).Value); var butcherdetail = dmo.Details.FirstOrDefault(x => x.HogGrade_ID.HasValue); @@ -110,6 +95,35 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs if (dmo.ActualPrice.HasValue) dmo.ActualPrice = decimal.Round(dmo.ActualPrice.Value.Value, 2); } + + if (dmo.ID == 0) + { + foreach (var item in dmo.FarmerDetails) + context.Session.Update(item); + dmo.FarmerDetails.Clear(); + } + } + + void CompareDetailMoney(StatPay dmo) + { + if (dmo.ID == 0) + return; + foreach (var detail in dmo.FarmerDetails) + { + if ((dmo.RealNumber ?? 0) != 0) + { + detail.ExeWeight = dmo.RealWeight * detail.Number / dmo.RealNumber; + var money = detail.Money; + if (dmo.PurchaseType_Name == "业务" && dmo.PayTarget == 付款对象.养殖户) + { + var extMoney = dmo.JingJianFee / dmo.RealNumber * detail.Number; + if (extMoney.HasValue) + extMoney = decimal.Round(extMoney.Value, 2); + money += (extMoney ?? 0); + } + detail.ExtMoney = money; + } + } } } } diff --git a/B3QingDaoWanFu/TypeIOCs/WeightBillTypeIoc.cs b/B3QingDaoWanFu/TypeIOCs/WeightBillTypeIoc.cs new file mode 100644 index 0000000..e5ce36c --- /dev/null +++ b/B3QingDaoWanFu/TypeIOCs/WeightBillTypeIoc.cs @@ -0,0 +1,21 @@ +using BWP.B3ButcherManage.BL; +using BWP.B3ButcherManage.BO; +using BWP.B3Frameworks; +using Forks.EnterpriseServices.BusinessInterfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3QingDaoWanFu.TypeIOCs +{ + [TypeIOC(typeof(WeightBillBL), typeof(WeightBillBL.BillBLIOCs.BeforeCheck))] + public class WeightBillBeforeCheck : WeightBillBL.BillBLIOCs.BeforeCheck + { + public void Invoke(IDmoContext context, WeighBill dmo) + { + if (dmo.PayTarget == null) + throw new Exception("付款对象不能为空"); + } + } +}