|
|
|
@ -0,0 +1,58 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using BWP.B3ButcherManage.Utils; |
|
|
|
using BWP.B3Frameworks; |
|
|
|
using BWP.B3Sale.BL; |
|
|
|
using BWP.B3Sale.BO; |
|
|
|
using Forks.EnterpriseServices.BusinessInterfaces; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
using Forks.Utils; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
namespace BWP.B3QingDaoWanFu.TypeIOCs |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
[TypeIOC(typeof(SaleOutStoreBL), typeof(SaleOutStoreBL.BaseBLIOCs.BeforeSave))] |
|
|
|
public class SaleOutStoreBLTypeIoc:SaleOutStoreBL.BaseBLIOCs.BeforeSave |
|
|
|
{ |
|
|
|
public void Invoke(IDmoContext context, SaleOutStore dmo) |
|
|
|
{ |
|
|
|
foreach (SaleOutStore_Detail detail in dmo.Details) |
|
|
|
{ |
|
|
|
detail.FactoryPrice = GetFactoryPrice(context, dmo, detail.SaleGoods_ID); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private Money<decimal>? GetFactoryPrice(IDmoContext context, SaleOutStore dmo, long detailSaleGoodsId) |
|
|
|
{ |
|
|
|
var detail=new JoinAlias(typeof(DynamicPrice_Detail)); |
|
|
|
var query=new DQueryDom(detail); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("SaleGoods_ID", detailSaleGoodsId)); |
|
|
|
query.Where.Conditions.Add(DQCondition.InSubQuery(DQExpression.Field("DynamicPrice_ID"),GetSubQueryDom(dmo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Price")); |
|
|
|
|
|
|
|
return query.EExecuteScalar<Money<decimal>?>(context.Session); |
|
|
|
} |
|
|
|
|
|
|
|
private DQueryDom GetSubQueryDom( SaleOutStore dmo) |
|
|
|
{ |
|
|
|
var bill=new JoinAlias("bill",typeof(DynamicPrice)); |
|
|
|
var detail=new JoinAlias("detail",typeof(DynamicPrice_AccountingUnitDetail)); |
|
|
|
var query=new DQueryDom(bill); |
|
|
|
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail),DQCondition.EQ(bill,"ID",detail, "DynamicPrice_ID") ); |
|
|
|
query.AddBillStateCondition(bill); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ(detail, "AccountingUnit_ID",dmo.AccountingUnit_ID)); |
|
|
|
query.Where.Conditions.Add(DQCondition.LessThanOrEqual(bill, "StartPriceDate", dmo.LoadTime)); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID",bill)); |
|
|
|
query.Range=SelectRange.Top(1); |
|
|
|
|
|
|
|
return query; |
|
|
|
} |
|
|
|
} |
|
|
|
} |