12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574 |
- $PBExportHeader$uo_price_order.sru
- forward
- global type uo_price_order from nonvisualobject
- end type
- end forward
- global type uo_price_order from nonvisualobject
- end type
- global uo_price_order uo_price_order
- type variables
- int uo_option_price_order_check
- int uo_option_if_oa_price_order
- int uo_option_price_order_secaudit
- Long audit_buildtype
- end variables
- forward prototypes
- public function integer save (s_price_order arg_s_order, ref string arg_msg, boolean arg_ifcommit)
- public function integer del (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
- public function integer caudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_inuse (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_add_salenum (long arg_poid, long arg_saleqty, decimal arg_addnum, boolean arg_ifcommit, ref string arg_msg)
- public function integer audit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg)
- public function datastore uof_getorderprice (long arg_cusid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_qty, ref string arg_msg)
- public function integer uof_chk_orderprice (datastore arg_ds_price)
- public function decimal uof_priceorder_cmpl (string arg_poexpr, decimal arg_price)
- public function boolean uof_priceorder_cmpl_1 (string arg_poexpr, decimal arg_price)
- public function integer secaudit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg)
- public function integer csecaudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
- public function integer add_dscrp (long arg_poid, string arg_newdescppart, ref string arg_msg)
- public function integer uof_c_inuse (long arg_poid, string arg_cinusereason, boolean arg_ifcommit, ref string arg_msg)
- end prototypes
- public function integer save (s_price_order arg_s_order, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt = 0,ll_cnt = 0
- Long ll_newid
- String ls_code
- DateTime server_dt
- String ls_mtrlcode
- IF uo_option_price_order_check = -1000 THEN
- arg_msg = '选项:[363]建立高级价格策略检查标准价格表已审核,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- IF IsNull(arg_s_order.poid) THEN arg_s_order.poid = 0
- IF IsNull(arg_s_order.mtrlid) THEN arg_s_order.mtrlid = 0
- IF IsNull(arg_s_order.mtrltypeid) THEN arg_s_order.mtrltypeid = 0
- IF IsNull(arg_s_order.mtrlsectype) THEN arg_s_order.mtrlsectype = ''
- IF IsNull(arg_s_order.zxmtrlmode) THEN arg_s_order.zxmtrlmode = ''
- IF IsNull(arg_s_order.usermtrlmode) THEN arg_s_order.usermtrlmode = ''
- IF IsNull(arg_s_order.cusid) THEN arg_s_order.cusid = 0
- IF IsNull(arg_s_order.cusareaid) THEN arg_s_order.cusareaid = 0
- IF IsNull(arg_s_order.poexpr) THEN arg_s_order.poexpr = ''
- IF IsNull(arg_s_order.inuse) THEN arg_s_order.inuse = 0
- IF IsNull(arg_s_order.Kind) THEN arg_s_order.Kind = 0
- IF IsNull(arg_s_order.typestr) THEN arg_s_order.typestr = ''
- IF IsNull(arg_s_order.orderint) THEN arg_s_order.orderint = 0
- IF IsNull(arg_s_order.saleqty) THEN arg_s_order.saleqty = 0
- IF IsNull(arg_s_order.saleqty1) THEN arg_s_order.saleqty1 = 0
- IF IsNull(arg_s_order.LimitNum) THEN arg_s_order.LimitNum = 0
- //IF IsNull(arg_s_order.SaleNum) THEN arg_s_order.SaleNum = 0
- IF IsNull(arg_s_order.LimitType) THEN arg_s_order.LimitType = 0
- IF IsNull(arg_s_order.status) THEN arg_s_order.status = ''
- IF IsNull(arg_s_order.woodcode) THEN arg_s_order.woodcode = ''
- IF IsNull(arg_s_order.pcode) THEN arg_s_order.pcode = ''
- IF IsNull(arg_s_order.ifusestatus) THEN arg_s_order.ifusestatus = 1
- IF IsNull(arg_s_order.ifusewoodcode) THEN arg_s_order.ifusewoodcode = 1
- IF IsNull(arg_s_order.ifusepcode) THEN arg_s_order.ifusepcode = 1
- IF IsNull(arg_s_order.dscrp) THEN arg_s_order.dscrp = ''
- SELECT Top 1 getdate() Into :server_dt From u_user;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF arg_s_order.begindate <= DateTime(Date('1900-01-01'),Time(0)) THEN
- rslt = 0
- arg_msg = '不合理的开始日期'
- GOTO ext
- END IF
- IF arg_s_order.mtrlid = 0 And arg_s_order.mtrltypeid = 0 THEN
- rslt = 0
- arg_msg = '请选择按产品生效还是按类别生效'
- GOTO ext
- END IF
- cnt = 0
- IF arg_s_order.mtrlid > 0 THEN
- SELECT mtrlcode INTO :ls_mtrlcode
- FROM u_mtrldef
- Where mtrlid = :arg_s_order.mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询产品是否存在失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF uo_option_price_order_check = 1 THEN
-
- SELECT count(*) INTO :ll_cnt
- FROM u_sale_price_mx INNER JOIN
- u_sale_price_list ON
- u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
- WHERE (u_sale_price_list.dftflag = 1)
- And u_sale_price_mx.mtrlid = :arg_s_order.mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询产品'+ls_mtrlcode+'是否已有标准价格表失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ll_cnt = 0 THEN
- rslt = 0
- arg_msg = '产品'+ls_mtrlcode+'未设定标准价格表,不能建立高级价格策略'
- GOTO ext
- END IF
-
-
- SELECT count(*)
- INTO :cnt
- FROM u_sale_price_mx INNER JOIN
- u_sale_price_list ON
- u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
- WHERE (u_sale_price_list.dftflag = 1)
- AND (u_sale_price_mx.flag = 1)
- And u_sale_price_mx.mtrlid = :arg_s_order.mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询产品'+ls_mtrlcode+'标准价格表是否已审核失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '产品'+ls_mtrlcode+'标准价格表未审核,不能建立高级价格策略'
- GOTO ext
- END IF
-
- END IF
- END IF
- cnt = 0
- IF arg_s_order.mtrltypeid > 0 THEN
- SELECT count(*) INTO :cnt
- FROM u_mtrltype
- Where mtrltypeid = :arg_s_order.mtrltypeid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询物料类别是否存在失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '物料类别不存在,请检查'
- GOTO ext
- END IF
- END IF
- IF arg_s_order.cusid = 0 And arg_s_order.cusareaid = 0 THEN
- rslt = 0
- arg_msg = '请选择按客户生效还是按区域生效'
- GOTO ext
- END IF
- cnt = 0
- //客户存在性检查
- IF arg_s_order.cusid > 0 THEN
- SELECT count(*)
- INTO :cnt
- FROM u_cust
- Where u_cust.cusid = :arg_s_order.cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询客户是否存在失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '客户不存在,请检查'
- GOTO ext
- END IF
- END IF
- cnt = 0
- //客户区域存在性检查
- IF arg_s_order.cusareaid > 0 THEN
- SELECT count(*)
- INTO :cnt
- FROM u_cusarea
- Where u_cusarea.cusareaid = :arg_s_order.cusareaid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询区域是否存在失败'+sqlca.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '区域不存在,请检查'
- GOTO ext
- END IF
- END IF
- Decimal lde_hisprice
- IF arg_s_order.poid = 0 THEN //新建
- IF arg_s_order.mtrlid > 0 And arg_s_order.cusid > 0 THEN
-
- SELECT top 1 price
- INTO :lde_hisprice
- FROM u_price_order
- WHERE ( cusid = :arg_s_order.cusid ) AND
- ( mtrlid = :arg_s_order.mtrlid ) AND
- ( status = :arg_s_order.status ) AND
- ( pcode = :arg_s_order.pcode ) AND
- ( woodcode = :arg_s_order.woodcode ) AND
- ( flag = 1) and
- ( secflag = 1)
- Order By opdate Desc;
- IF sqlca.SQLCode <> 0 THEN
- lde_hisprice = 0
- END IF
- arg_s_order.hisprice = lde_hisprice
- ELSE
- arg_s_order.hisprice = arg_s_order.listprice
- END IF
- ELSE
- SELECT hisprice INTO :lde_hisprice
- FROM u_price_order
- Where poid = :arg_s_order.poid;
- IF sqlca.SQLCode <> 0 THEN
- lde_hisprice = 0
- END IF
- arg_s_order.hisprice = lde_hisprice
- END IF
- IF arg_s_order.hisprice = 0 THEN
- arg_s_order.frate = 0
- ELSE
- arg_s_order.frate = (arg_s_order.price - arg_s_order.hisprice) / arg_s_order.hisprice
- END IF
- IF arg_s_order.poid = 0 THEN
- ll_newid = f_sys_scidentity(0,"u_price_order","poid",arg_msg,True,id_sqlca)
-
- IF ll_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ls_code = getid(0,'PO',Date(server_dt),False,sqlca)
-
- INSERT INTO u_price_order
- (u_price_order.POID,
- u_price_order.pocode,
- u_price_order.Begindate,
- u_price_order.enddate,
- u_price_order.Mtrlid,
- u_price_order.mtrltypeid,
- u_price_order.Cusid,
- u_price_order.Cusareaid,
- u_price_order.Poexpr,
- u_price_order.Inuse,
- u_price_order.mtrlsectype,
- u_price_order.zxmtrlmode,
- u_price_order.usermtrlmode,
- u_price_order.kind,
- u_price_order.opemp,
- u_price_order.opdate,
- u_price_order.typestr,
- u_price_order.orderint,
- u_price_order.saleqty,
- u_price_order.saleqty1,
- u_price_order.LimitNum,
- u_price_order.LimitType,
- u_price_order.status,
- u_price_order.woodcode,
- u_price_order.pcode,
- u_price_order.ifusestatus,
- u_price_order.ifusewoodcode,
- u_price_order.ifusepcode,
- u_price_order.dscrp,
- u_price_order.price,
- u_price_order.listprice,
- u_price_order.hisprice,
- u_price_order.frate)
- VALUES
- (:ll_newid,
- :ls_code,
- :arg_s_order.Begindate,
- :arg_s_order.enddate,
- :arg_s_order.Mtrlid,
- :arg_s_order.mtrltypeid,
- :arg_s_order.Cusid,
- :arg_s_order.cusareaid,
- :arg_s_order.Poexpr,
- :arg_s_order.Inuse,
- :arg_s_order.mtrlsectype,
- :arg_s_order.zxmtrlmode,
- :arg_s_order.usermtrlmode,
- :arg_s_order.kind,
- :publ_operator,
- getdate(),
- :arg_s_order.typestr,
- :arg_s_order.orderint,
- :arg_s_order.saleqty,
- :arg_s_order.saleqty1,
- :arg_s_order.LimitNum,
- :arg_s_order.LimitType,
- :arg_s_order.status,
- :arg_s_order.woodcode,
- :arg_s_order.pcode,
- :arg_s_order.ifusestatus,
- :arg_s_order.ifusewoodcode,
- :arg_s_order.ifusepcode,
- :arg_s_order.dscrp,
- :arg_s_order.price,
- :arg_s_order.listprice,
- :arg_s_order.hisprice,
- :arg_s_order.frate);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '新增价格指令失败'+sqlca.SQLErrText
- GOTO ext
- END IF
- ELSE
- UPDATE u_price_order
- SET Begindate = :arg_s_order.begindate,
- enddate = :arg_s_order.enddate,
- Mtrlid = :arg_s_order.mtrlid,
- mtrltypeid = :arg_s_order.mtrltypeid,
- CusID = :arg_s_order.cusid,
- cusareaid = :arg_s_order.cusareaid,
- Poexpr = :arg_s_order.Poexpr,
- inuse = :arg_s_order.inuse,
- mtrlsectype = :arg_s_order.mtrlsectype,
- zxmtrlmode = :arg_s_order.zxmtrlmode,
- usermtrlmode = :arg_s_order.usermtrlmode,
- kind = :arg_s_order.kind,
- modemp = :publ_operator,
- moddate = getdate(),
- typestr = :arg_s_order.typestr,
- orderint = :arg_s_order.orderint,
- saleqty = :arg_s_order.saleqty,
- saleqty1 = :arg_s_order.saleqty1,
- LimitNum = :arg_s_order.LimitNum,
- LimitType = :arg_s_order.LimitType,
- status = :arg_s_order.status,
- woodcode = :arg_s_order.woodcode,
- pcode = :arg_s_order.pcode,
- ifusestatus = :arg_s_order.ifusestatus,
- ifusewoodcode = :arg_s_order.ifusewoodcode,
- ifusepcode = :arg_s_order.ifusepcode,
- dscrp = :arg_s_order.dscrp,
- u_price_order.price = :arg_s_order.price,
- u_price_order.listprice = :arg_s_order.listprice,
- u_price_order.hisprice = :arg_s_order.hisprice,
- u_price_order.frate = :arg_s_order.frate
- Where u_price_order.poid = :arg_s_order.poid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '修改价格指令失败'+sqlca.SQLErrText
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF arg_ifcommit And rslt = 1 THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer del (long arg_poid, boolean arg_ifcommit, ref string arg_msg);//uf_del_priceorder(arg_poid,arg_ifcommit,arg_msg)
- //删除价格指令
- Long rslt = 1
- Long cnt = 0
- Int li_flag
- SELECT COUNT(*)
- INTO :CNT
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- GOTO ext
- END IF
- SELECT flag INTO :li_flag
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF li_flag = 1 THEN
- rslt = 0
- arg_msg = '价格指令已审核,不能删除'
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*)
- INTO :cnt
- FROM u_saletaskmx
- Where poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- arg_msg = '查询价格指令是否已用于销售订单失败,请检查,'+SQLCA.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF cnt > 0 THEN
- arg_msg = '价格指令已用于销售订单,不能删除,只取设无效'
- rslt = 0
- GOTO ext
- END IF
- //删除价格指令
- DELETE FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因删除失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer caudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0
- Int li_flag, li_secflag
- DateTime null_dt
- SetNull(null_dt)
- IF uo_option_if_oa_price_order = -1000 THEN
- rslt = 0
- arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_price_order_secaudit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- SELECT COUNT(*)
- INTO :CNT
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- GOTO ext
- END IF
- SELECT flag, secflag INTO :li_flag, :li_secflag
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF li_flag = 0 THEN
- rslt = 0
- arg_msg = '价格指令未审核,不能撤审'
- GOTO ext
- END IF
- IF li_secflag = 1 THEN
- rslt = 0
- arg_msg = '价格指令已终审,不能撤审'
- GOTO ext
- END IF
- If uo_option_if_oa_price_order = 1 And uo_option_price_order_secaudit = 1 And audit_buildtype = 0 Then
- If f_check_if_oaflow_caudit(0,arg_poid,2404,ARG_MSG ) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //查询价格指令是否已用于销售订单
- SELECT count(*)
- INTO :cnt
- FROM u_SaleTaskMx
- Where poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已用于销售订单失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF cnt > 0 THEN
- rslt = 0
- arg_msg = '价格指令已用于销售订单,不能撤审'
- GOTO ext
- END IF
- UPDATE u_price_order
- SET u_price_order.flag = 0,
- u_price_order.auditemp = '',
- u_price_order.auditdate = :null_dt
- WHERE u_price_order.poid = :arg_poid
- And u_price_order.flag = 1
- And u_price_order.secflag = 0;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因导致撤审价格指令失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- //将相关已完成的OA公文的状态设为作废
- If (uo_option_price_order_secaudit = 1 And uo_option_if_oa_price_order = 1) Then
- Update oa_doc
- Set docflag = 12
- Where powerid = 2404
- And scid = 0
- And billid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新相关公文状态失败'+SQLCA.SQLErrText
- Goto ext
- End If
- End If
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer uof_inuse (long arg_poid, boolean arg_ifcommit, ref string arg_msg);
- Long rslt = 1
- Long cnt = 0
- Int li_inuse
- DateTime ldt_null
- SetNull(ldt_null)
- Select COUNT(*)
- Into :CNT
- From u_price_order
- Where u_price_order.poid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- If cnt = 0 Then
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- Goto ext
- End If
- Select inuse Into :li_inuse
- From u_price_order
- Where u_price_order.poid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- If li_inuse = 1 Then
- rslt = 0
- arg_msg = '价格指令已设为有效,不能重复设置'
- Goto ext
- End If
- Update u_price_order
- Set u_price_order.inuse = 1,
- u_price_order.cinusereason = '',
- u_price_order.cinuseemp = '',
- u_price_order.cinusedate = :ldt_null
- Where u_price_order.poid = :arg_poid
- And u_price_order.inuse = 0;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因导致设置价格指令有效失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- ext:
- If rslt = 0 Then
- Rollback;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit;
- End If
- Return rslt
- end function
- public function integer uof_add_salenum (long arg_poid, long arg_saleqty, decimal arg_addnum, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- If arg_poid <= 0 Then
- arg_msg = "错误的价格指令唯一码"
- rslt = 0
- Goto ext
- End If
- Long ll_limitnum, ll_salenum
- Int li_inuse,li_inusetype
- String ls_pocode
- Decimal lde_saleqty, lde_saleqty1
- Select limitnum , salenum, pocode, saleqty, saleqty1, inuse, pocode,inusetype
- Into :ll_limitnum, :ll_salenum, :ls_pocode, :lde_saleqty, :lde_saleqty1, :li_inuse, :ls_pocode,:li_inusetype
- From u_price_order
- Where poid = :arg_poid;
- If sqlca.SQLCode <> 0 Then
- arg_msg = "查询价格指令信息失败,"+sqlca.SQLErrText
- rslt = 0
- Goto ext
- End If
- If li_inuse = 0 and li_inusetype = 0 Then
- arg_msg = "价格指令["+ls_pocode+"]已无效"
- rslt = 0
- Goto ext
- End If
- //1.lde_saleqty = 0 且 lde_saleqty1 = 0 ; 不限制
- //2.lde_saleqty > 0 且 lde_saleqty1 = 0 ; 不设上限;
- //3.lde_saleqty = 0 且 lde_saleqty1 > 0 ; 不设下限;
- //4.lde_saleqty > 0 且 lde_saleqty1 > 0 ; 一定范围;
- If lde_saleqty > 0 Then //限制销售数量 > 0 的才算有效, 0的默认不限制
- If arg_saleqty < lde_saleqty Then
- arg_msg = "价格指令["+ls_pocode+"]限制销售数量下限为["+String(lde_saleqty,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],没达到数量要求."
- rslt = 0
- Goto ext
- End If
- End If
- If lde_saleqty1 > 0 Then //限制销售数量 > 0 的才算有效, 0的默认不限制
- If arg_saleqty > lde_saleqty1 Then
- arg_msg = "价格指令["+ls_pocode+"]限制销售数量上限为["+String(lde_saleqty1,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],超过数量要求."
- rslt = 0
- Goto ext
- End If
- End If
- If ll_limitnum > 0 Then //限制次数 > 0 的才算有效, 0的默认不限制
- If arg_addnum = 0 Then //增加 1
- If ll_limitnum < ll_salenum + 1 Then
- arg_msg = "价格指令["+ls_pocode+"]限制使用次数为["+String(ll_limitnum)+"]次, 使用次数已达上限."
- rslt = 0
- Goto ext
- End If
-
- Update u_price_order
- Set salenum = salenum + 1
- Where poid = :arg_poid;
-
- Else //减少 1
- If ll_salenum < 1 Then
- arg_msg = "价格指令["+ls_pocode+"]还没有使用记录,不能减少使用次数."
- rslt = 0
- Goto ext
- End If
-
- Update u_price_order
- Set salenum = salenum - 1
- Where poid = :arg_poid;
- End If
-
- If sqlca.SQLCode <> 0 Then
- arg_msg = "更新价格指令使用次数信息失败,"+sqlca.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- Update u_price_order
- Set inuse = case when salenum >= limitnum then 0 else 1 end ,
- inusetype = 1
- Where poid = :arg_poid;
- If sqlca.SQLCode <> 0 Then
- arg_msg = "更新价格指令有效状态失败,"+sqlca.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- End If
- ext:
- If rslt = 0 Then
- Rollback Using sqlca;
- ElseIf arg_ifcommit And rslt = 1 Then
- Commit Using sqlca;
- End If
- Return rslt
- end function
- public function integer audit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg);
- //审核价格指令
- Long rslt = 1
- Long cnt = 0
- Int li_flag, li_secflag
- string ls_pocode,ls_dscrp
- IF uo_option_if_oa_price_order = -1000 THEN
- rslt = 0
- arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_price_order_secaudit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- SELECT COUNT(*)
- INTO :CNT
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- GOTO ext
- END IF
- SELECT flag,pocode,dscrp
- INTO :li_flag,:ls_pocode,:ls_dscrp
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF li_flag = 1 THEN
- rslt = 0
- arg_msg = '价格指令已审核,不能重复审核'
- GOTO ext
- END IF
- UPDATE u_price_order
- SET u_price_order.flag = 1,
- u_price_order.auditdate = getdate(),
- u_price_order.auditemp = :arg_opemp
- WHERE u_price_order.poid = :arg_poid
- AND u_price_order.flag = 0;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因导致审核价格指令失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- If uo_option_price_order_secaudit = 1 And uo_option_if_oa_price_order = 1 And audit_buildtype = 0 Then
- If f_oa(sqlca,False,ARG_MSG,2404,0,arg_poid,ls_pocode,ls_pocode,ls_dscrp) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function datastore uof_getorderprice (long arg_cusid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_qty, ref string arg_msg);Int rslt = 1
- DateTime server_time
- String ls_mtrlsectype,ls_zxmtrlmode,ls_usermtrlmode
- long ll_cnt, ll_cnt2, ll_parentid
- long ll_mtrltypeid, ll_mtrltypeid_arr[]
- long ll_cusareaid, ll_cusareaid_arr[]
- long ll_kind, ll_row
- datastore ds_price
- ds_price = Create datastore
- ds_price.DataObject = 'ds_price_order_index'
- ds_price.SetTransObject(sqlca)
- //查自定义
- SELECT mtrlsectype,zxmtrlmode,usermtrlmode
- INTO :ls_mtrlsectype,:ls_zxmtrlmode,:ls_usermtrlmode
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext
- END IF
- /////// //检查价格指令
- SELECT Top 1 getdate() Into :server_time From u_user;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因取服务器时间失败'+sqlca.SQLErrText
- GOTO ext
- END IF
- server_time = DateTime(Date(String(server_time,'yyyy-mm-dd')),Time(0))
- //查物料类别
- SELECT mtrltypeid INTO :ll_mtrltypeid
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询产品类型失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ll_cnt++
- ll_mtrltypeid_arr[ll_cnt] = ll_mtrltypeid
- SELECT parentid INTO :ll_parentid
- FROM u_mtrltype
- WHERE mtrltypeid = :ll_mtrltypeid
- And parentid > 0 ;
- DO WHILE sqlca.SQLCode = 0
- ll_cnt++
- ll_mtrltypeid_arr[ll_cnt] = ll_parentid
- ll_mtrltypeid = ll_parentid
-
- SELECT parentid INTO :ll_parentid
- FROM u_mtrltype
- WHERE mtrltypeid = :ll_mtrltypeid
- And parentid > 0 ;
- LOOP
- //
- //查客户区域
- SELECT cusareaid INTO :ll_cusareaid
- FROM u_cust
- Where cusid = :arg_cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户区域失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ll_cnt2++
- ll_cusareaid_arr[ll_cnt2] = ll_cusareaid
- SELECT parentid INTO :ll_parentid
- FROM u_Cusarea
- WHERE CusareaID = :ll_cusareaid
- And parentid > 0 ;
- DO WHILE sqlca.SQLCode = 0
- ll_cnt2++
- ll_cusareaid_arr[ll_cnt2] = ll_parentid
- ll_cusareaid = ll_parentid
-
- SELECT parentid INTO :ll_parentid
- FROM u_Cusarea
- WHERE CusareaID = :ll_cusareaid
- And parentid > 0 ;
- LOOP
- //查价格指令
- ds_price.Retrieve(arg_mtrlid,ll_mtrltypeid_arr[],arg_cusid,ll_cusareaid_arr[],server_time,ls_mtrlsectype,ls_zxmtrlmode,ls_usermtrlmode,arg_qty,arg_status, arg_woodcode, arg_pcode)
- //ll_row = ds_price.RowCount()
- //IF ll_row > 0 THEN
- // ll_kind = ds_price.Object.Kind[1]
- //ELSE
- // ll_kind = 0
- //END IF
- ext:
- return ds_price
- end function
- public function integer uof_chk_orderprice (datastore arg_ds_price);//由价格指令 比较
- //
- //无价格指令 返回''
- //或 价格指定 kind = 0 返回价格
- //或 价格限制 kind = 1 检查价格是否受限
- //或 折扣指定 kind = 2 返回折扣
- int rslt = 1
- //long ll_row
- //long ll_Kind
- decimal lde_saleqty, lde_saleqty1
- string ls_pocode
- //
- //ll_row = arg_ds_price.RowCount()
- //
- //IF ll_row > 0 THEN
- // ll_kind = arg_ds_price.Object.Kind[1]
- //ELSE
- // ll_kind = 0
- //END IF
- //
- //IF ll_row = 0 then //无价格指令, 不做任何操作
- // goto ext
- //end if
- //
- //ls_poexpr = arg_ds_price.Object.poexpr[1]
- lde_saleqty = arg_ds_price.Object.saleqty[1]
- lde_saleqty1 = arg_ds_price.Object.saleqty1[1]
- ls_pocode = arg_ds_price.Object.pocode[1]
- //
- ////检查使用次数
- //IF arg_ds_price.Object.limitnum[1] > 0 THEN
- // IF arg_ds_price.Object.limitnum[1] <= arg_ds_price.Object.salenum[1] THEN//使用次数达上限
- // rslt = 2
- // GOTO ext
- // END IF
- //END IF
- //
- ////检查数量范围
- //IF lde_saleqty > 0 THEN //限制销售数量 > 0 的才算有效, 0的默认不限制
- // IF arg_saleqty < lde_saleqty THEN
- // arg_msg = "价格指令["+ls_pocode+"]限制销售数量下限为["+String(lde_saleqty,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],没达到数量要求."
- // rslt = 2
- // GOTO ext
- // END IF
- //END IF
- //
- //IF lde_saleqty1 > 0 THEN //限制销售数量 > 0 的才算有效, 0的默认不限制
- // IF arg_saleqty > lde_saleqty1 THEN
- // arg_msg = "价格指令["+ls_pocode+"]限制销售数量上限为["+String(lde_saleqty1,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],超过数量要求."
- // rslt = 2
- // GOTO ext
- // END IF
- //END IF
- //choose case ll_kind
- //
- // case 0
- //
- // case 1
- //
- //
- //
- // IF Pos(ls_poexpr,'{') > 0 And Pos(ls_poexpr,'}') > 0 THEN
- // ll_pricelistid = Long(Mid(ls_poexpr,Pos(ls_poexpr,'[') + 1,Pos(ls_poexpr,']') - Pos(ls_poexpr,'[') - 1))
- //
- // SELECT moneyid INTO :ll_moneyid_pricelist
- // FROM u_sale_price_list
- // Where u_sale_price_list.pricelistid = :ll_pricelistid;
- // IF sqlca.SQLCode <> 0 THEN
- // rslt = 2
- // rtn_price = 0.00
- // rtn_zqrate = 1
- // GOTO ext
- // END IF
- //
- // IF ll_moneyid_pricelist <> ll_moneyid THEN
- // rslt = 2
- // rtn_price = 0.00
- // rtn_zqrate = 1
- // GOTO ext
- // END IF
- //
- // IF ll_statusflag = 2 And arg_status <> '' THEN
- // f_checkpz(arg_status,s_pz[])
- // arg_pcode = ''
- // arg_woodcode = ''
- //
- // FOR ll_i = 1 To UpperBound(s_pz)
- // ls_status_zj = s_pz[ll_i].cfgname
- // ld_price_zj = 0
- // ld_rebate_zj = 0
- //
- // SELECT u_sale_price_mx.price,
- // u_sale_price_list.flag,
- // u_sale_price_list.listname,
- // u_sale_price_mx.rebate,
- // u_sale_price_mx.pricestr
- // INTO :ld_lmsaleprice,:li_flag,:ls_listname,:ld_rebate,:ls_pricestr
- // FROM u_sale_price_list,u_sale_price_mx
- // WHERE u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
- // AND u_sale_price_mx.mtrlid = :arg_mtrlid
- // AND u_sale_price_mx.status = :ls_status_zj
- // AND u_sale_price_mx.woodcode = :arg_woodcode
- // AND u_sale_price_mx.pcode = :arg_pcode
- // AND u_sale_price_list.flag = 1
- // And u_sale_price_mx.pricelistid = :ll_pricelistid;
- //
- // IF sqlca.SQLCode <> 0 THEN
- // rslt = 2
- // rtn_price = 0.00
- // rtn_zqrate = 1
- // GOTO ext
- // END IF
- //
- // IF li_flag = 0 THEN
- // rslt = 2
- // rtn_price = 0.00
- // rtn_zqrate = 1
- // GOTO ext
- // END IF
- //
- // IF Trim(ls_pricestr) <> '' THEN
- // li_rslt_cmp = uof_pricestr_cmp(ls_pricestr,ls_status_ori,ls_woodcode_ori,ls_pcode_ori,ld_price_cmp)
- //
- // IF li_rslt_cmp = 1 THEN
- // ld_lmsaleprice = ld_price_cmp
- // ELSEIF li_rslt_cmp = 0 THEN
- // ld_lmsaleprice = 0
- // END IF
- //
- // END IF
- //
- // obj_price = obj_price + ld_lmsaleprice * ld_rebate * Dec(s_pz[ll_i].qty)
- // NEXT
- // ELSE
- // SELECT u_sale_price_mx.price,
- // u_sale_price_list.flag,
- // u_sale_price_list.listname,
- // u_sale_price_mx.rebate,
- // u_sale_price_mx.pricestr
- // INTO :ld_lmsaleprice,:li_flag,:ls_listname,:ld_rebate,:ls_pricestr
- // FROM u_sale_price_list,u_sale_price_mx
- // WHERE u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
- // AND u_sale_price_mx.mtrlid = :arg_mtrlid
- // AND u_sale_price_mx.status = :arg_status
- // AND u_sale_price_mx.woodcode = :arg_woodcode
- // AND u_sale_price_mx.pcode = :arg_pcode
- // AND u_sale_price_list.flag = 1
- // And u_sale_price_mx.pricelistid = :ll_pricelistid;
- //
- // IF sqlca.SQLCode <> 0 THEN
- // rslt = 2
- // rtn_price = 0.00
- // rtn_zqrate = 1
- // GOTO ext
- // END IF
- //
- // IF li_flag = 0 THEN
- // rslt = 2
- // rtn_price = 0.00
- // rtn_zqrate = 1
- // GOTO ext
- // END IF
- //
- // IF Trim(ls_pricestr) <> '' THEN
- // li_rslt_cmp = uof_pricestr_cmp(ls_pricestr,ls_status_ori,ls_woodcode_ori,ls_pcode_ori,ld_price_cmp)
- //
- // IF li_rslt_cmp = 1 THEN
- // ld_lmsaleprice = ld_price_cmp
- // ELSEIF li_rslt_cmp = 0 THEN
- // ld_lmsaleprice = 0
- // END IF
- //
- // END IF
- //
- // obj_price = ld_lmsaleprice * ld_rebate
- // END IF
- // ls_poexpr = Replace(ls_poexpr,Pos(ls_poexpr,'{'),Pos(ls_poexpr,'}') - Pos(ls_poexpr,'{') + 1,String(obj_price,'###0.00########'))
- //
- // END IF
- // datastore dw_price_check
- // dw_price_check = Create datastore
- // dw_price_check.DataObject = 'dw_compute_priceorder'
- // dw_price_check.InsertRow(0)
- // dw_price_check.Modify("compute.expression='"+Mid(ls_poexpr,Pos(ls_poexpr,'=') + 1)+"'")
- //
- // ld_lmsaleprice = dw_price_check.Object.compute[ll_row]
- //
- // ld_rebate = 1
- //
- // rtn_price = ld_lmsaleprice
- // rtn_zqrate = ld_rebate
- // case 2
- //
- //end choose
- //
- //
- //
- //ext:
- return rslt
- end function
- public function decimal uof_priceorder_cmpl (string arg_poexpr, decimal arg_price);//kind = 0 或 kind = 2适用, 返回指定的价格
- String ls_poexpr
- Long ll_row
- Decimal lde_rtncmp
- ls_poexpr = arg_poexpr
- IF Pos(ls_poexpr,'{') > 0 And Pos(ls_poexpr,'}') > 0 THEN
- ls_poexpr = Replace(ls_poexpr,Pos(ls_poexpr,'{'),Pos(ls_poexpr,'}') - Pos(ls_poexpr,'{') + 1,String(arg_price,'###0.00########'))
- END IF
- ls_poexpr = Mid(ls_poexpr,Pos(ls_poexpr,'=') + 1)
- datastore ds_price_chk
- ds_price_chk = Create datastore
- ds_price_chk.DataObject = 'dw_compute_priceorder'
- ll_row = ds_price_chk.InsertRow(0)
- ds_price_chk.Modify("compute.expression='"+ls_poexpr+"'")
- lde_rtncmp = ds_price_chk.Object.compute[ll_row]
- destroy ds_price_chk
- RETURN lde_rtncmp
- end function
- public function boolean uof_priceorder_cmpl_1 (string arg_poexpr, decimal arg_price);//kind = 1 适用, 返回指定的价格是否符合价格限定
- String ls_poexpr
- Long ll_row
- string ls_rtncmp
- ls_poexpr = arg_poexpr
- IF Pos(ls_poexpr,'{') > 0 And Pos(ls_poexpr,'}') > 0 THEN
- ls_poexpr = Replace(ls_poexpr,Pos(ls_poexpr,'{'),Pos(ls_poexpr,'}') - Pos(ls_poexpr,'{') + 1,String(arg_price,'###0.00########'))
- END IF
- //ls_poexpr = Mid(ls_poexpr,Pos(ls_poexpr,'=') + 1)
- datastore ds_price_chk
- ds_price_chk = Create datastore
- ds_price_chk.DataObject = 'dw_compute_priceorder'
- ll_row = ds_price_chk.InsertRow(0)
- ds_price_chk.Modify("compute.expression='"+ls_poexpr+"'")
- ls_rtncmp = String(ds_price_chk.Object.compute[ll_row])
- destroy ds_price_chk
- IF ls_rtncmp = 'false' THEN
- RETURN False
- ELSE
- RETURN True
- END IF
- end function
- public function integer secaudit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg);
- //终审核价格指令
- Long rslt = 1
- Long cnt = 0
- Int li_flag, li_secflag
- IF uo_option_if_oa_price_order = -1000 THEN
- rslt = 0
- arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_price_order_secaudit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- SELECT COUNT(*)
- INTO :CNT
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- GOTO ext
- END IF
- SELECT flag, secflag INTO :li_flag, :li_secflag
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF li_flag = 0 THEN
- rslt = 0
- arg_msg = '价格指令未审核,不能终审'
- GOTO ext
- END IF
- IF li_secflag = 1 THEN
- rslt = 0
- arg_msg = '价格指令已终审'
- GOTO ext
- END IF
- If uo_option_if_oa_price_order = 1 And uo_option_price_order_secaudit = 1 And audit_buildtype = 0 Then
- If f_check_if_oaflow(0,arg_poid,2404,ARG_MSG ) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- UPDATE u_price_order
- SET u_price_order.secflag = 1,
- u_price_order.secauditdate = getdate(),
- u_price_order.secauditemp = :arg_opemp
- WHERE u_price_order.poid = :arg_poid
- AND u_price_order.flag = 1
- AND u_price_order.secflag = 0;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因导致终审核价格指令失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer csecaudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0
- Int li_flag, li_secflag
- DateTime null_dt
- SetNull(null_dt)
- If uo_option_if_oa_price_order = -1000 Then
- rslt = 0
- arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_price_order_secaudit = -1000 Then
- rslt = 0
- arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- Select COUNT(*)
- Into :CNT
- From u_price_order
- Where u_price_order.poid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- If cnt = 0 Then
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- Goto ext
- End If
- Select flag, secflag Into :li_flag, :li_secflag
- From u_price_order
- Where u_price_order.poid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- If li_secflag = 0 Then
- rslt = 0
- arg_msg = '价格指令未终审,不能撤审'
- Goto ext
- End If
- //查询价格指令是否已用于销售订单
- Select count(*)
- Into :cnt
- From u_SaleTaskMx
- Where poid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已用于销售订单失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- If cnt > 0 Then
- rslt = 0
- arg_msg = '价格指令已用于销售订单,不能撤审'
- Goto ext
- End If
- If uo_option_if_oa_price_order = 0 Then
-
- Update u_price_order
- Set u_price_order.secflag = 0,
- u_price_order.secauditemp = '',
- u_price_order.secauditdate = :null_dt
- Where u_price_order.poid = :arg_poid
- And u_price_order.secflag = 1;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因导致撤审价格指令失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- Else
- Update u_price_order
- Set u_price_order.flag = 0,
- u_price_order.auditemp = '',
- u_price_order.auditdate = :null_dt,
- u_price_order.secflag = 0,
- u_price_order.secauditemp = '',
- u_price_order.secauditdate = :null_dt
- Where u_price_order.poid = :arg_poid
- And u_price_order.secflag = 1;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其他原因导致撤审价格指令失败>>'+SQLCA.SQLErrText
- Goto ext
- End If
- End If
- //将相关已完成的OA公文的状态设为作废
- If (uo_option_price_order_secaudit = 1 And uo_option_if_oa_price_order = 1) Then
- Update oa_doc
- Set docflag = 12
- Where powerid = 2404
- And scid = 0
- And billid = :arg_poid;
- If SQLCA.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新相关公文状态失败'+SQLCA.SQLErrText
- Goto ext
- End If
- End If
- ext:
- If rslt = 0 Then
- Rollback;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit;
- End If
- Return rslt
- end function
- public function integer add_dscrp (long arg_poid, string arg_newdescppart, ref string arg_msg);
- Int rslt = 1
- Int li_flag,li_billtype
- IF arg_newdescppart = '' THEN
- rslt = 0
- arG_MSG = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- SELECT flag INTO :li_flag
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询指令是否已审核失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF li_flag = 0 THEN
- rslt = 0
- arG_MSG = "待审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_price_order
- SET DSCRP = DSCRP+' '+:arg_newdescppart
- WHERE u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '添加备注操作失败,'+SQLCA.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 1 THEN
- COMMIT;
- ELSE
- ROLLBACK;
- END IF
- Return (rslt)
- end function
- public function integer uof_c_inuse (long arg_poid, string arg_cinusereason, boolean arg_ifcommit, ref string arg_msg);
- Long rslt = 1
- Long cnt = 0
- Int li_inuse
- SELECT COUNT(*)
- INTO :CNT
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '没有找到合适的价格指令'
- GOTO ext
- END IF
- SELECT inuse INTO :li_inuse
- FROM u_price_order
- Where u_price_order.poid = :arg_poid;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- IF li_inuse = 0 THEN
- rslt = 0
- arg_msg = '价格指令已设为无效,不能重复设置'
- GOTO ext
- END IF
- UPDATE u_price_order
- SET u_price_order.inuse = 0,
- u_price_order.inusetype = 0,
- u_price_order.cinusereason = :arg_cinusereason,
- u_price_order.cinuseemp = :publ_operator,
- u_price_order.cinusedate = getdate()
- WHERE u_price_order.poid = :arg_poid
- AND u_price_order.inuse = 1;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其他原因导致设置价格指令无效失败>>'+SQLCA.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- on uo_price_order.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_price_order.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event constructor;String arg_msg
- String str_optionvalue
- str_optionvalue = ''
- f_get_sys_option_value('363',str_optionvalue,arg_msg)
- uo_option_price_order_check = Long(str_optionvalue)
- str_optionvalue = ''
- f_get_sys_option_value('367',str_optionvalue,arg_msg)
- uo_option_price_order_secaudit = Long(str_optionvalue)
- str_optionvalue = ''
- f_get_sys_option_value('408',str_optionvalue,arg_msg)
- uo_option_if_oa_price_order = Long(str_optionvalue)
- end event
|