通过外挂程序实现SBO中的价格控制策略

写在前面
竟然做起了基于SBO的开发。
SBO 2004 2B是一个轻型的企业业务管理软件,结构和框架设计的很不错,也很灵活。但是毕竟是国外产品,进入到中国,还是要有水土适应期。
本来,SBO是提供软件开发接口的,但是SBO的软件供应商没有进行很好的交接,这些资料完全没有,不过在网上看到更多的是,SBO的开发版SDK是需要Money的。
既然没有更多的资料,也只能凭借自身的经验和对SBO软件的浅薄理解做一些力所能力的开发了。
 
开发需求
对全省各个门店实行商品的价格控制,价格控制方案为:
1、缺省情况下对公司经营的所有商品进行价格控制。
2、根据销售量、销售趋势、毛利润、厂家政策、季节因素、经营性质(经销、代销)商品动态定义产品的价格控制类型为常规、主流、主推、特价等10个价格控制类型。
3、不同品类的不同价格类型的具有不同的价格控制参数(就是说:销售价格必须不低于成本价*(1+r),其中r是价格控制参数)。
4、支持按照以下方式进行价格策略排除:
    A、某门店或者某几个门店的所有商品不参加价格控制
    B、某品类或者某几个品类商品不参加价格控制
    C、某门店或者某几个门店的某个品类或者某几个品类在某个时段内不参加价格控制
    D、某门店的某种或者某些单品在某个时段内不参加价格控制
 
程序实现
在SBO 2004 2B中无法直接实现上述的价格控制,需要二次开发。开发方案如下:
1、数据结构
为了完成以上的价格控制策略,需要对SBO的数据结构进行如下修改。
1.1、加入用户表:u_SHOP,用于定义门店属性,其中包括字段ShopID, ShopName。为了对价格控制予以支持,还有字段:bNoPCtrl,bit, 不参加价格控制标志,缺省为0;SDATE, EDATE,不参加价格控制的时段。
1.2、对门店仓库进行属性扩展,加入门店属性,字段为u_ShopID。
1.3、对操作员进行门店属性扩展,每个操作员特别的销售人员门店位置化,加入门店属性,字段为u_ShopID。
1.4、对采销发票信息、明细列表门店化,加入门店属性,字段为u_ShopID。
1.5、对商品主文件表加入价格控制级别字段:u_CPriType char(1),支持62个类别(0-9, a-z, A-Z)。 
1.6、加入用户表:u_MPCList,用于定义品类价格控制参数,主要字段:itmsGrpCod 商品品类, CPriType 价格控制类型, cRate 价格控制参数,CFlag 是否启用此价格控制方案, DFlag 是否按照时段进行价控, SDate, EDate,如果按照时段价控的起止时间。如果不启用此价控方案,按照时段进行价控及其时段参数都将无效。
1.7、加入用户表:u_NPCList,用于定义门店价控排除的品类,主要字段:ShopID 门店, itmsGrpCod 品类, CFlag 是否启用此价控排除方案, DFlag 是否按照时段进行价控排除, SDate, EDate,如果按照时段价控排除的起止时间。如果不启用此价控排除方案,按照时段进行价控排除及其时段参数都将无效。
1.8、加入用户表:u_NPCItems,用于定义门店价控排除的单品,主要字段:ShopID 门店, itmCode 品类, CFlag 是否启用此价控排除方案, SDate, EDate,价控排除的起止时间。
 
2、商品价控类别
因为可能涉及到公司经营机密,价格控制类别的算法略。价格控制类别动态完成之后,可以通过UI界面进行维护和调整。
应该说,上述数据结构通过UI界面进行增加删除修改的操作,也是很容易实现的。以下显示的是商品价格控制排除维护界面,更多的实现界面略。(可以使用不同的语言来实现,VS.NET 2005是非常好的开发平台,推荐一下
3、价格控制
上面的数据结构实现了,价格控制其实就很简单了。在销售存盘的时候通过以下SQL为主体的存储过程进行销售价格控制校验即可。
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))<cast(avgprice*(1+sRate/100) as numeric(20,0)) )
    begin
     select '您所销售的商品低于最低限价, 销售被拒绝!'
     return -1
    end
   
    select ''
    return 0
end

你可能感兴趣的:(职场,休闲,Sbo,企业信息管理)