diff --git a/B3SheepButcherManage/BL/Bill/StatPayBL/StatPayBL.cs b/B3SheepButcherManage/BL/Bill/StatPayBL/StatPayBL.cs index 551563e..e9cb850 100644 --- a/B3SheepButcherManage/BL/Bill/StatPayBL/StatPayBL.cs +++ b/B3SheepButcherManage/BL/Bill/StatPayBL/StatPayBL.cs @@ -126,6 +126,8 @@ namespace BWP.B3SheepButcherManage.BL detail.Money = detail.PriceWeight * detail.Price * ((detail.Discount ?? 100) / 100); } + + FillOtherRewardInfo(dmo); foreach (StatPay_OtherReward detail in dmo.OtherRewardDetails) { detail.Money = detail.Price * detail.Number; @@ -160,6 +162,40 @@ namespace BWP.B3SheepButcherManage.BL base.beforeSave(dmo); } + void FillOtherRewardInfo(StatPay dmo) + { + var tags = dmo.OtherRewardDetails.Where(x => x.RewardItem_ID.HasValue && x.Price == null); + if (tags.Count() == 0) + return; + var sanction = new JoinAlias(typeof(CW.SanctionSetting)); + var abnormalItem = new JoinAlias(typeof(CW.RewardItem)); + + var dom = new DQueryDom(sanction); + dom.From.AddJoin(JoinType.Left, new DQDmoSource(abnormalItem), + DQCondition.EQ(sanction, "RewardItem_ID", abnormalItem, "ID")); + dom.Columns.Add(DQSelectColumn.Field("ID", abnormalItem)); + dom.Columns.Add(DQSelectColumn.Field("Condition", sanction)); + dom.Columns.Add(DQSelectColumn.Field("BeforeScript", sanction)); + dom.Where.Conditions.Add(DQCondition.EQ(sanction, "FitBill", 奖罚设置适用单据类型.结算单)); + dom.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核)); + dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(abnormalItem, "ID"), tags.Select(x => DQExpression.Value(x)).ToArray())); + var sanctionList = dom.EExecuteList(Session); + + var runner = new Runner(); + foreach (var item in sanctionList) + { + var detail = dmo.OtherRewardDetails.First(x => x.RewardItem_ID == item.Item1); + runner.Global["单价"] = 0m; + runner.Execute(item.Item2); + var price = TypeMarshal.AsNumber(runner.Global["单价"]); + detail.Price = price; + if (price == 0) + { + detail.Price = null; + } + } + } + public void WeightCreateStayDom(StatPay dmo) { if (dmo.ValuationArea_ID == null) @@ -545,7 +581,7 @@ namespace BWP.B3SheepButcherManage.BL var bType = TypeMarshal.AsString(runner.Global["奖罚依据"]); switch (bType) { - case "屠宰单": + case "羊屠宰单": AddRewardWithButcher(dmo, runner, tuple); break; }