[原创]通过外挂程序实现SBO中的价格控制策略
if Exists(select top 1 1 from u_sysparm where SPID='PriCtrlPalicy' and PARM='YES!')
begin
declare @shopid nvarchar(20)
select @shopid=u_part from oinv where docEntry=@nEntry
if not exists (select top 1 1 from u_shop a where a.u_shopid=@shopid and isnull(a.u_bNoPCtrl,0)=1)
begin
--价格控制
if exists( select top 1 1 from
(select a.itemcode, b.itemName, a.Price, c.sRate from inv1 a, oitm b, u_mpcList c where a.docentry=@nEntry and a.itemcode=b.itemcode and b.u_priCType=c.priCType and b.itmsgrpcod=c.itmsgrpcod and isNull(uFlag,0)=1 and isNUll(dFlag,0)=0 and b.itmsgrpcod not in (select itmsGrpCod from uv_npclist where shopid=@shopid) and a.itemcode not in (select distinct itemcode from uv_npcitems u where shopid=@shopid and a.whscode=u.whscode and (getdate() between sdate and edate) and isnull(cFlag,0)=1 )
union all
select a.itemcode, b.itemName, a.Price, c.sRate from inv1 a, oitm b, u_mpcList c, oinv d where a.docentry=@nEntry and a.itemcode=b.itemcode and a.docEntry=d.docEntry and b.u_priCType=c.priCType and b.itmsgrpcod=c.itmsgrpcod and isNull(uFlag,0)=1 and isNUll(dFlag,0)=1 and a.docDate>=c.sdate and a.docDate<=c.edate
and b.itmsgrpcod not in (select itmsGrpCod from uv_npclist where shopid=@shopid) and a.itemcode not in (select distinct itemcode from uv_npcitems u where shopid=@shopid and a.whscode=u.whscode and (getdate() between sdate and edate) and isnull(cFlag,0)=1 ) ) a,
(select inv1.itemcode, case p1.price when 0 then oitw.avgprice*1.17 else p1.price end avgprice from inv1 inner join oitw on inv1.itemcode=oitw.itemcode and inv1.whscode=oitw.whscode inner join oitm on inv1.itemcode=oitm.itemcode left join itm1 p1 on inv1.itemcode=p1.itemcode and p1.pricelist=2 where inv1.docentry=@nEntry
and oitm.itmsgrpcod not in (select itmsGrpCod from uv_npclist where shopid=@shopid) and inv1.itemcode not in (select distinct itemcode from uv_npcitems u where shopid=@shopid and inv1.whscode=u.whscode and (getdate() between sdate and edate) and isnull(cFlag,0)=1 ) ) b
where a.itemcode=b.itemcode and cast(Price as numeric(20,0)) begin
select '您所销售的商品低于最低限价, 销售被拒绝!'
return -1
end
select ''
return 0
end
推荐到鲜果: 查阅更多相关主题的帖子: ERP技术 SAP


评论