using BWP.B3_YunKen.BO;
|
|
using BWP.B3Frameworks.BL;
|
|
using BWP.B3Frameworks.Utils;
|
|
using BWP.B3Sale.BO;
|
|
using BWP.B3UnitedInfos.BO;
|
|
using Forks.EnterpriseServices;
|
|
using Forks.EnterpriseServices.BusinessInterfaces;
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
using Forks.EnterpriseServices.SqlDoms;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using TSingSoft.WebPluginFramework;
|
|
|
|
namespace BWP.B3_YunKen.BL
|
|
{
|
|
[BusinessInterface(typeof(Goods_PackageBL))]
|
|
[LogicName("包装物")]
|
|
public interface IGoods_PackageBL : IBaseInfoBL<Goods_Package>
|
|
{
|
|
void UpdateGoodsPackage(long goodsID, long? packageID, long classID, long accID, int smallPackNum);
|
|
}
|
|
|
|
public class Goods_PackageBL : BaseInfoBL<Goods_Package>, IGoods_PackageBL
|
|
{
|
|
|
|
private int _cludeClassId = 5; //5 固定写死
|
|
|
|
public void UpdateGoodsPackage(long goodsID, long? packageID, long classID, long accID, int smallPackNum)
|
|
{
|
|
long? cid;
|
|
if (packageID != null)
|
|
{
|
|
//cid = BLUtil.GetDmoProperty<Wrappage, long?>(packageID.Value, "PackageClass_TreeDeep1ID", Session);
|
|
cid = InnerBLUtil.GetDmoPropertyByID<Wrappage, long?>(Session, "WrappageKind_TreeDeep1ID", packageID.Value);
|
|
}
|
|
else
|
|
{
|
|
cid = classID;
|
|
}
|
|
|
|
var query = new DmoQuery(typeof(Goods_Package));
|
|
query.Where.Conditions.Add(DQCondition.EQ("Goods_ID", goodsID));
|
|
query.Where.Conditions.Add(DQCondition.EQ("PackageClass_TreeDeep1ID", cid));
|
|
query.Where.Conditions.Add(DQCondition.EQ("Package_AccountingUnit_ID", accID));
|
|
var dmo = (Goods_Package)Session.ExecuteScalar(query);
|
|
|
|
if (packageID == null)
|
|
{
|
|
if (dmo != null)
|
|
Session.Delete(dmo);
|
|
}
|
|
else
|
|
{
|
|
//var price = BLUtil.GetDmoProperty<Wrappage, decimal?>(packageID.Value, "Price", Session);
|
|
var price = InnerBLUtil.GetDmoPropertyByID<Wrappage, decimal?>(Session, "Price", packageID.Value);
|
|
// var packClassId = BLUtil.GetDmoProperty<Package, long?>(packageID.Value, "PackageClass_ID", Session);
|
|
int packClassId = GetTreeDeep1(packageID.Value, Session);
|
|
|
|
|
|
if (dmo == null)
|
|
{
|
|
dmo = new Goods_Package { Goods_ID = goodsID, Package_ID = packageID, Price = price };
|
|
if (packClassId == _cludeClassId)
|
|
{
|
|
dmo.SmallPackNum = smallPackNum;
|
|
}
|
|
else
|
|
{
|
|
dmo.SmallPackNum = 1;
|
|
}
|
|
Session.Insert(dmo);
|
|
}
|
|
|
|
else if (dmo.Package_ID != packageID || (packClassId == _cludeClassId && dmo.SmallPackNum != smallPackNum))
|
|
{
|
|
dmo.Package_ID = packageID;
|
|
|
|
if (packClassId == _cludeClassId)
|
|
{
|
|
dmo.SmallPackNum = smallPackNum;
|
|
}
|
|
else
|
|
{
|
|
dmo.SmallPackNum = 1;
|
|
}
|
|
dmo.Date = BLContext.Today;
|
|
dmo.Price = price;
|
|
Session.Update(dmo);
|
|
}
|
|
}
|
|
}
|
|
|
|
private int GetTreeDeep1(long value, IDmoSession session)
|
|
{
|
|
//select pack.PackageClass_ID,cla.* from SaleYunKen_Package pack left join SaleYunKen_PackageClass cla on pack.PackageClass_ID=cla.ID where pack.ID=487
|
|
var pack = new JoinAlias(typeof(Wrappage));
|
|
var packClass = new JoinAlias(typeof(WrappageKind));
|
|
var dom = new DQueryDom(pack);
|
|
dom.From.AddJoin(JoinType.Left, new DQDmoSource(packClass), DQCondition.EQ(pack, "WrappageKind_ID", packClass, "ID"));
|
|
dom.Columns.Add(DQSelectColumn.Field("TreeDeep1ID", packClass));
|
|
dom.Where.Conditions.Add(DQCondition.EQ(pack, "ID", value));
|
|
return Convert.ToInt32(session.ExecuteScalar(dom));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|