uo_price_order.sru 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574
  1. $PBExportHeader$uo_price_order.sru
  2. forward
  3. global type uo_price_order from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_price_order from nonvisualobject
  7. end type
  8. global uo_price_order uo_price_order
  9. type variables
  10. int uo_option_price_order_check
  11. int uo_option_if_oa_price_order
  12. int uo_option_price_order_secaudit
  13. Long audit_buildtype
  14. end variables
  15. forward prototypes
  16. public function integer save (s_price_order arg_s_order, ref string arg_msg, boolean arg_ifcommit)
  17. public function integer del (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
  18. public function integer caudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
  19. public function integer uof_inuse (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
  20. public function integer uof_add_salenum (long arg_poid, long arg_saleqty, decimal arg_addnum, boolean arg_ifcommit, ref string arg_msg)
  21. public function integer audit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg)
  22. 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)
  23. public function integer uof_chk_orderprice (datastore arg_ds_price)
  24. public function decimal uof_priceorder_cmpl (string arg_poexpr, decimal arg_price)
  25. public function boolean uof_priceorder_cmpl_1 (string arg_poexpr, decimal arg_price)
  26. public function integer secaudit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg)
  27. public function integer csecaudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg)
  28. public function integer add_dscrp (long arg_poid, string arg_newdescppart, ref string arg_msg)
  29. public function integer uof_c_inuse (long arg_poid, string arg_cinusereason, boolean arg_ifcommit, ref string arg_msg)
  30. end prototypes
  31. public function integer save (s_price_order arg_s_order, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  32. Long cnt = 0,ll_cnt = 0
  33. Long ll_newid
  34. String ls_code
  35. DateTime server_dt
  36. String ls_mtrlcode
  37. IF uo_option_price_order_check = -1000 THEN
  38. arg_msg = '选项:[363]建立高级价格策略检查标准价格表已审核,读取初始默认值失败,操作取消!'
  39. rslt = 0
  40. GOTO ext
  41. END IF
  42. IF IsNull(arg_s_order.poid) THEN arg_s_order.poid = 0
  43. IF IsNull(arg_s_order.mtrlid) THEN arg_s_order.mtrlid = 0
  44. IF IsNull(arg_s_order.mtrltypeid) THEN arg_s_order.mtrltypeid = 0
  45. IF IsNull(arg_s_order.mtrlsectype) THEN arg_s_order.mtrlsectype = ''
  46. IF IsNull(arg_s_order.zxmtrlmode) THEN arg_s_order.zxmtrlmode = ''
  47. IF IsNull(arg_s_order.usermtrlmode) THEN arg_s_order.usermtrlmode = ''
  48. IF IsNull(arg_s_order.cusid) THEN arg_s_order.cusid = 0
  49. IF IsNull(arg_s_order.cusareaid) THEN arg_s_order.cusareaid = 0
  50. IF IsNull(arg_s_order.poexpr) THEN arg_s_order.poexpr = ''
  51. IF IsNull(arg_s_order.inuse) THEN arg_s_order.inuse = 0
  52. IF IsNull(arg_s_order.Kind) THEN arg_s_order.Kind = 0
  53. IF IsNull(arg_s_order.typestr) THEN arg_s_order.typestr = ''
  54. IF IsNull(arg_s_order.orderint) THEN arg_s_order.orderint = 0
  55. IF IsNull(arg_s_order.saleqty) THEN arg_s_order.saleqty = 0
  56. IF IsNull(arg_s_order.saleqty1) THEN arg_s_order.saleqty1 = 0
  57. IF IsNull(arg_s_order.LimitNum) THEN arg_s_order.LimitNum = 0
  58. //IF IsNull(arg_s_order.SaleNum) THEN arg_s_order.SaleNum = 0
  59. IF IsNull(arg_s_order.LimitType) THEN arg_s_order.LimitType = 0
  60. IF IsNull(arg_s_order.status) THEN arg_s_order.status = ''
  61. IF IsNull(arg_s_order.woodcode) THEN arg_s_order.woodcode = ''
  62. IF IsNull(arg_s_order.pcode) THEN arg_s_order.pcode = ''
  63. IF IsNull(arg_s_order.ifusestatus) THEN arg_s_order.ifusestatus = 1
  64. IF IsNull(arg_s_order.ifusewoodcode) THEN arg_s_order.ifusewoodcode = 1
  65. IF IsNull(arg_s_order.ifusepcode) THEN arg_s_order.ifusepcode = 1
  66. IF IsNull(arg_s_order.dscrp) THEN arg_s_order.dscrp = ''
  67. SELECT Top 1 getdate() Into :server_dt From u_user;
  68. IF sqlca.SQLCode <> 0 THEN
  69. rslt = 0
  70. arg_msg = "查询操作失败,日期 "
  71. GOTO ext
  72. END IF
  73. IF arg_s_order.begindate <= DateTime(Date('1900-01-01'),Time(0)) THEN
  74. rslt = 0
  75. arg_msg = '不合理的开始日期'
  76. GOTO ext
  77. END IF
  78. IF arg_s_order.mtrlid = 0 And arg_s_order.mtrltypeid = 0 THEN
  79. rslt = 0
  80. arg_msg = '请选择按产品生效还是按类别生效'
  81. GOTO ext
  82. END IF
  83. cnt = 0
  84. IF arg_s_order.mtrlid > 0 THEN
  85. SELECT mtrlcode INTO :ls_mtrlcode
  86. FROM u_mtrldef
  87. Where mtrlid = :arg_s_order.mtrlid;
  88. IF sqlca.SQLCode <> 0 THEN
  89. rslt = 0
  90. arg_msg = '查询产品是否存在失败,'+sqlca.SQLErrText
  91. GOTO ext
  92. END IF
  93. IF uo_option_price_order_check = 1 THEN
  94. SELECT count(*) INTO :ll_cnt
  95. FROM u_sale_price_mx INNER JOIN
  96. u_sale_price_list ON
  97. u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
  98. WHERE (u_sale_price_list.dftflag = 1)
  99. And u_sale_price_mx.mtrlid = :arg_s_order.mtrlid;
  100. IF sqlca.SQLCode <> 0 THEN
  101. rslt = 0
  102. arg_msg = '查询产品'+ls_mtrlcode+'是否已有标准价格表失败,'+sqlca.SQLErrText
  103. GOTO ext
  104. END IF
  105. IF ll_cnt = 0 THEN
  106. rslt = 0
  107. arg_msg = '产品'+ls_mtrlcode+'未设定标准价格表,不能建立高级价格策略'
  108. GOTO ext
  109. END IF
  110. SELECT count(*)
  111. INTO :cnt
  112. FROM u_sale_price_mx INNER JOIN
  113. u_sale_price_list ON
  114. u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
  115. WHERE (u_sale_price_list.dftflag = 1)
  116. AND (u_sale_price_mx.flag = 1)
  117. And u_sale_price_mx.mtrlid = :arg_s_order.mtrlid;
  118. IF sqlca.SQLCode <> 0 THEN
  119. rslt = 0
  120. arg_msg = '查询产品'+ls_mtrlcode+'标准价格表是否已审核失败,'+sqlca.SQLErrText
  121. GOTO ext
  122. END IF
  123. IF cnt = 0 THEN
  124. rslt = 0
  125. arg_msg = '产品'+ls_mtrlcode+'标准价格表未审核,不能建立高级价格策略'
  126. GOTO ext
  127. END IF
  128. END IF
  129. END IF
  130. cnt = 0
  131. IF arg_s_order.mtrltypeid > 0 THEN
  132. SELECT count(*) INTO :cnt
  133. FROM u_mtrltype
  134. Where mtrltypeid = :arg_s_order.mtrltypeid;
  135. IF sqlca.SQLCode <> 0 THEN
  136. rslt = 0
  137. arg_msg = '查询物料类别是否存在失败,'+sqlca.SQLErrText
  138. GOTO ext
  139. END IF
  140. IF cnt = 0 THEN
  141. rslt = 0
  142. arg_msg = '物料类别不存在,请检查'
  143. GOTO ext
  144. END IF
  145. END IF
  146. IF arg_s_order.cusid = 0 And arg_s_order.cusareaid = 0 THEN
  147. rslt = 0
  148. arg_msg = '请选择按客户生效还是按区域生效'
  149. GOTO ext
  150. END IF
  151. cnt = 0
  152. //客户存在性检查
  153. IF arg_s_order.cusid > 0 THEN
  154. SELECT count(*)
  155. INTO :cnt
  156. FROM u_cust
  157. Where u_cust.cusid = :arg_s_order.cusid;
  158. IF sqlca.SQLCode <> 0 THEN
  159. rslt = 0
  160. arg_msg = '查询客户是否存在失败,'+sqlca.SQLErrText
  161. GOTO ext
  162. END IF
  163. IF cnt = 0 THEN
  164. rslt = 0
  165. arg_msg = '客户不存在,请检查'
  166. GOTO ext
  167. END IF
  168. END IF
  169. cnt = 0
  170. //客户区域存在性检查
  171. IF arg_s_order.cusareaid > 0 THEN
  172. SELECT count(*)
  173. INTO :cnt
  174. FROM u_cusarea
  175. Where u_cusarea.cusareaid = :arg_s_order.cusareaid;
  176. IF sqlca.SQLCode <> 0 THEN
  177. rslt = 0
  178. arg_msg = '查询区域是否存在失败'+sqlca.SQLErrText
  179. GOTO ext
  180. END IF
  181. IF cnt = 0 THEN
  182. rslt = 0
  183. arg_msg = '区域不存在,请检查'
  184. GOTO ext
  185. END IF
  186. END IF
  187. Decimal lde_hisprice
  188. IF arg_s_order.poid = 0 THEN //新建
  189. IF arg_s_order.mtrlid > 0 And arg_s_order.cusid > 0 THEN
  190. SELECT top 1 price
  191. INTO :lde_hisprice
  192. FROM u_price_order
  193. WHERE ( cusid = :arg_s_order.cusid ) AND
  194. ( mtrlid = :arg_s_order.mtrlid ) AND
  195. ( status = :arg_s_order.status ) AND
  196. ( pcode = :arg_s_order.pcode ) AND
  197. ( woodcode = :arg_s_order.woodcode ) AND
  198. ( flag = 1) and
  199. ( secflag = 1)
  200. Order By opdate Desc;
  201. IF sqlca.SQLCode <> 0 THEN
  202. lde_hisprice = 0
  203. END IF
  204. arg_s_order.hisprice = lde_hisprice
  205. ELSE
  206. arg_s_order.hisprice = arg_s_order.listprice
  207. END IF
  208. ELSE
  209. SELECT hisprice INTO :lde_hisprice
  210. FROM u_price_order
  211. Where poid = :arg_s_order.poid;
  212. IF sqlca.SQLCode <> 0 THEN
  213. lde_hisprice = 0
  214. END IF
  215. arg_s_order.hisprice = lde_hisprice
  216. END IF
  217. IF arg_s_order.hisprice = 0 THEN
  218. arg_s_order.frate = 0
  219. ELSE
  220. arg_s_order.frate = (arg_s_order.price - arg_s_order.hisprice) / arg_s_order.hisprice
  221. END IF
  222. IF arg_s_order.poid = 0 THEN
  223. ll_newid = f_sys_scidentity(0,"u_price_order","poid",arg_msg,True,id_sqlca)
  224. IF ll_newid <= 0 THEN
  225. rslt = 0
  226. GOTO ext
  227. END IF
  228. ls_code = getid(0,'PO',Date(server_dt),False,sqlca)
  229. INSERT INTO u_price_order
  230. (u_price_order.POID,
  231. u_price_order.pocode,
  232. u_price_order.Begindate,
  233. u_price_order.enddate,
  234. u_price_order.Mtrlid,
  235. u_price_order.mtrltypeid,
  236. u_price_order.Cusid,
  237. u_price_order.Cusareaid,
  238. u_price_order.Poexpr,
  239. u_price_order.Inuse,
  240. u_price_order.mtrlsectype,
  241. u_price_order.zxmtrlmode,
  242. u_price_order.usermtrlmode,
  243. u_price_order.kind,
  244. u_price_order.opemp,
  245. u_price_order.opdate,
  246. u_price_order.typestr,
  247. u_price_order.orderint,
  248. u_price_order.saleqty,
  249. u_price_order.saleqty1,
  250. u_price_order.LimitNum,
  251. u_price_order.LimitType,
  252. u_price_order.status,
  253. u_price_order.woodcode,
  254. u_price_order.pcode,
  255. u_price_order.ifusestatus,
  256. u_price_order.ifusewoodcode,
  257. u_price_order.ifusepcode,
  258. u_price_order.dscrp,
  259. u_price_order.price,
  260. u_price_order.listprice,
  261. u_price_order.hisprice,
  262. u_price_order.frate)
  263. VALUES
  264. (:ll_newid,
  265. :ls_code,
  266. :arg_s_order.Begindate,
  267. :arg_s_order.enddate,
  268. :arg_s_order.Mtrlid,
  269. :arg_s_order.mtrltypeid,
  270. :arg_s_order.Cusid,
  271. :arg_s_order.cusareaid,
  272. :arg_s_order.Poexpr,
  273. :arg_s_order.Inuse,
  274. :arg_s_order.mtrlsectype,
  275. :arg_s_order.zxmtrlmode,
  276. :arg_s_order.usermtrlmode,
  277. :arg_s_order.kind,
  278. :publ_operator,
  279. getdate(),
  280. :arg_s_order.typestr,
  281. :arg_s_order.orderint,
  282. :arg_s_order.saleqty,
  283. :arg_s_order.saleqty1,
  284. :arg_s_order.LimitNum,
  285. :arg_s_order.LimitType,
  286. :arg_s_order.status,
  287. :arg_s_order.woodcode,
  288. :arg_s_order.pcode,
  289. :arg_s_order.ifusestatus,
  290. :arg_s_order.ifusewoodcode,
  291. :arg_s_order.ifusepcode,
  292. :arg_s_order.dscrp,
  293. :arg_s_order.price,
  294. :arg_s_order.listprice,
  295. :arg_s_order.hisprice,
  296. :arg_s_order.frate);
  297. IF sqlca.SQLCode <> 0 THEN
  298. rslt = 0
  299. arg_msg = '新增价格指令失败'+sqlca.SQLErrText
  300. GOTO ext
  301. END IF
  302. ELSE
  303. UPDATE u_price_order
  304. SET Begindate = :arg_s_order.begindate,
  305. enddate = :arg_s_order.enddate,
  306. Mtrlid = :arg_s_order.mtrlid,
  307. mtrltypeid = :arg_s_order.mtrltypeid,
  308. CusID = :arg_s_order.cusid,
  309. cusareaid = :arg_s_order.cusareaid,
  310. Poexpr = :arg_s_order.Poexpr,
  311. inuse = :arg_s_order.inuse,
  312. mtrlsectype = :arg_s_order.mtrlsectype,
  313. zxmtrlmode = :arg_s_order.zxmtrlmode,
  314. usermtrlmode = :arg_s_order.usermtrlmode,
  315. kind = :arg_s_order.kind,
  316. modemp = :publ_operator,
  317. moddate = getdate(),
  318. typestr = :arg_s_order.typestr,
  319. orderint = :arg_s_order.orderint,
  320. saleqty = :arg_s_order.saleqty,
  321. saleqty1 = :arg_s_order.saleqty1,
  322. LimitNum = :arg_s_order.LimitNum,
  323. LimitType = :arg_s_order.LimitType,
  324. status = :arg_s_order.status,
  325. woodcode = :arg_s_order.woodcode,
  326. pcode = :arg_s_order.pcode,
  327. ifusestatus = :arg_s_order.ifusestatus,
  328. ifusewoodcode = :arg_s_order.ifusewoodcode,
  329. ifusepcode = :arg_s_order.ifusepcode,
  330. dscrp = :arg_s_order.dscrp,
  331. u_price_order.price = :arg_s_order.price,
  332. u_price_order.listprice = :arg_s_order.listprice,
  333. u_price_order.hisprice = :arg_s_order.hisprice,
  334. u_price_order.frate = :arg_s_order.frate
  335. Where u_price_order.poid = :arg_s_order.poid;
  336. IF sqlca.SQLCode <> 0 THEN
  337. rslt = 0
  338. arg_msg = '修改价格指令失败'+sqlca.SQLErrText
  339. GOTO ext
  340. END IF
  341. END IF
  342. ext:
  343. IF rslt = 0 THEN
  344. ROLLBACK;
  345. ELSEIF arg_ifcommit And rslt = 1 THEN
  346. COMMIT;
  347. END IF
  348. RETURN rslt
  349. end function
  350. public function integer del (long arg_poid, boolean arg_ifcommit, ref string arg_msg);//uf_del_priceorder(arg_poid,arg_ifcommit,arg_msg)
  351. //删除价格指令
  352. Long rslt = 1
  353. Long cnt = 0
  354. Int li_flag
  355. SELECT COUNT(*)
  356. INTO :CNT
  357. FROM u_price_order
  358. Where u_price_order.poid = :arg_poid;
  359. IF SQLCA.SQLCode <> 0 THEN
  360. rslt = 0
  361. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  362. GOTO ext
  363. END IF
  364. IF cnt = 0 THEN
  365. rslt = 0
  366. arg_msg = '没有找到合适的价格指令'
  367. GOTO ext
  368. END IF
  369. SELECT flag INTO :li_flag
  370. FROM u_price_order
  371. Where u_price_order.poid = :arg_poid;
  372. IF SQLCA.SQLCode <> 0 THEN
  373. rslt = 0
  374. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  375. GOTO ext
  376. END IF
  377. IF li_flag = 1 THEN
  378. rslt = 0
  379. arg_msg = '价格指令已审核,不能删除'
  380. GOTO ext
  381. END IF
  382. cnt = 0
  383. SELECT count(*)
  384. INTO :cnt
  385. FROM u_saletaskmx
  386. Where poid = :arg_poid;
  387. IF SQLCA.SQLCode <> 0 THEN
  388. arg_msg = '查询价格指令是否已用于销售订单失败,请检查,'+SQLCA.SQLErrText
  389. rslt = 0
  390. GOTO ext
  391. END IF
  392. IF cnt > 0 THEN
  393. arg_msg = '价格指令已用于销售订单,不能删除,只取设无效'
  394. rslt = 0
  395. GOTO ext
  396. END IF
  397. //删除价格指令
  398. DELETE FROM u_price_order
  399. Where u_price_order.poid = :arg_poid;
  400. IF SQLCA.SQLCode <> 0 THEN
  401. rslt = 0
  402. arg_msg = '因网络或其他原因删除失败>>'+SQLCA.SQLErrText
  403. GOTO ext
  404. END IF
  405. ext:
  406. IF rslt = 0 THEN
  407. ROLLBACK;
  408. ELSEIF rslt = 1 And arg_ifcommit THEN
  409. COMMIT;
  410. END IF
  411. RETURN rslt
  412. end function
  413. public function integer caudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  414. Long cnt = 0
  415. Int li_flag, li_secflag
  416. DateTime null_dt
  417. SetNull(null_dt)
  418. IF uo_option_if_oa_price_order = -1000 THEN
  419. rslt = 0
  420. arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
  421. GOTO ext
  422. END IF
  423. IF uo_option_price_order_secaudit = -1000 THEN
  424. rslt = 0
  425. arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
  426. GOTO ext
  427. END IF
  428. SELECT COUNT(*)
  429. INTO :CNT
  430. FROM u_price_order
  431. Where u_price_order.poid = :arg_poid;
  432. IF SQLCA.SQLCode <> 0 THEN
  433. rslt = 0
  434. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  435. GOTO ext
  436. END IF
  437. IF cnt = 0 THEN
  438. rslt = 0
  439. arg_msg = '没有找到合适的价格指令'
  440. GOTO ext
  441. END IF
  442. SELECT flag, secflag INTO :li_flag, :li_secflag
  443. FROM u_price_order
  444. Where u_price_order.poid = :arg_poid;
  445. IF SQLCA.SQLCode <> 0 THEN
  446. rslt = 0
  447. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  448. GOTO ext
  449. END IF
  450. IF li_flag = 0 THEN
  451. rslt = 0
  452. arg_msg = '价格指令未审核,不能撤审'
  453. GOTO ext
  454. END IF
  455. IF li_secflag = 1 THEN
  456. rslt = 0
  457. arg_msg = '价格指令已终审,不能撤审'
  458. GOTO ext
  459. END IF
  460. If uo_option_if_oa_price_order = 1 And uo_option_price_order_secaudit = 1 And audit_buildtype = 0 Then
  461. If f_check_if_oaflow_caudit(0,arg_poid,2404,ARG_MSG ) = 0 Then
  462. rslt = 0
  463. Goto ext
  464. End If
  465. End If
  466. //查询价格指令是否已用于销售订单
  467. SELECT count(*)
  468. INTO :cnt
  469. FROM u_SaleTaskMx
  470. Where poid = :arg_poid;
  471. IF SQLCA.SQLCode <> 0 THEN
  472. rslt = 0
  473. arg_msg = '因网络或其他原因查询指令是否已用于销售订单失败>>'+SQLCA.SQLErrText
  474. GOTO ext
  475. END IF
  476. IF cnt > 0 THEN
  477. rslt = 0
  478. arg_msg = '价格指令已用于销售订单,不能撤审'
  479. GOTO ext
  480. END IF
  481. UPDATE u_price_order
  482. SET u_price_order.flag = 0,
  483. u_price_order.auditemp = '',
  484. u_price_order.auditdate = :null_dt
  485. WHERE u_price_order.poid = :arg_poid
  486. And u_price_order.flag = 1
  487. And u_price_order.secflag = 0;
  488. IF SQLCA.SQLCode <> 0 THEN
  489. rslt = 0
  490. arg_msg = '因网络或其他原因导致撤审价格指令失败>>'+SQLCA.SQLErrText
  491. GOTO ext
  492. END IF
  493. //将相关已完成的OA公文的状态设为作废
  494. If (uo_option_price_order_secaudit = 1 And uo_option_if_oa_price_order = 1) Then
  495. Update oa_doc
  496. Set docflag = 12
  497. Where powerid = 2404
  498. And scid = 0
  499. And billid = :arg_poid;
  500. If SQLCA.SQLCode <> 0 Then
  501. rslt = 0
  502. arg_msg = '更新相关公文状态失败'+SQLCA.SQLErrText
  503. Goto ext
  504. End If
  505. End If
  506. ext:
  507. IF rslt = 0 THEN
  508. ROLLBACK;
  509. ELSEIF rslt = 1 And arg_ifcommit THEN
  510. COMMIT;
  511. END IF
  512. RETURN rslt
  513. end function
  514. public function integer uof_inuse (long arg_poid, boolean arg_ifcommit, ref string arg_msg);
  515. Long rslt = 1
  516. Long cnt = 0
  517. Int li_inuse
  518. DateTime ldt_null
  519. SetNull(ldt_null)
  520. Select COUNT(*)
  521. Into :CNT
  522. From u_price_order
  523. Where u_price_order.poid = :arg_poid;
  524. If SQLCA.SQLCode <> 0 Then
  525. rslt = 0
  526. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  527. Goto ext
  528. End If
  529. If cnt = 0 Then
  530. rslt = 0
  531. arg_msg = '没有找到合适的价格指令'
  532. Goto ext
  533. End If
  534. Select inuse Into :li_inuse
  535. From u_price_order
  536. Where u_price_order.poid = :arg_poid;
  537. If SQLCA.SQLCode <> 0 Then
  538. rslt = 0
  539. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  540. Goto ext
  541. End If
  542. If li_inuse = 1 Then
  543. rslt = 0
  544. arg_msg = '价格指令已设为有效,不能重复设置'
  545. Goto ext
  546. End If
  547. Update u_price_order
  548. Set u_price_order.inuse = 1,
  549. u_price_order.cinusereason = '',
  550. u_price_order.cinuseemp = '',
  551. u_price_order.cinusedate = :ldt_null
  552. Where u_price_order.poid = :arg_poid
  553. And u_price_order.inuse = 0;
  554. If SQLCA.SQLCode <> 0 Then
  555. rslt = 0
  556. arg_msg = '因网络或其他原因导致设置价格指令有效失败>>'+SQLCA.SQLErrText
  557. Goto ext
  558. End If
  559. ext:
  560. If rslt = 0 Then
  561. Rollback;
  562. ElseIf rslt = 1 And arg_ifcommit Then
  563. Commit;
  564. End If
  565. Return rslt
  566. end function
  567. 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
  568. If arg_poid <= 0 Then
  569. arg_msg = "错误的价格指令唯一码"
  570. rslt = 0
  571. Goto ext
  572. End If
  573. Long ll_limitnum, ll_salenum
  574. Int li_inuse,li_inusetype
  575. String ls_pocode
  576. Decimal lde_saleqty, lde_saleqty1
  577. Select limitnum , salenum, pocode, saleqty, saleqty1, inuse, pocode,inusetype
  578. Into :ll_limitnum, :ll_salenum, :ls_pocode, :lde_saleqty, :lde_saleqty1, :li_inuse, :ls_pocode,:li_inusetype
  579. From u_price_order
  580. Where poid = :arg_poid;
  581. If sqlca.SQLCode <> 0 Then
  582. arg_msg = "查询价格指令信息失败,"+sqlca.SQLErrText
  583. rslt = 0
  584. Goto ext
  585. End If
  586. If li_inuse = 0 and li_inusetype = 0 Then
  587. arg_msg = "价格指令["+ls_pocode+"]已无效"
  588. rslt = 0
  589. Goto ext
  590. End If
  591. //1.lde_saleqty = 0 且 lde_saleqty1 = 0 ; 不限制
  592. //2.lde_saleqty > 0 且 lde_saleqty1 = 0 ; 不设上限;
  593. //3.lde_saleqty = 0 且 lde_saleqty1 > 0 ; 不设下限;
  594. //4.lde_saleqty > 0 且 lde_saleqty1 > 0 ; 一定范围;
  595. If lde_saleqty > 0 Then //限制销售数量 > 0 的才算有效, 0的默认不限制
  596. If arg_saleqty < lde_saleqty Then
  597. arg_msg = "价格指令["+ls_pocode+"]限制销售数量下限为["+String(lde_saleqty,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],没达到数量要求."
  598. rslt = 0
  599. Goto ext
  600. End If
  601. End If
  602. If lde_saleqty1 > 0 Then //限制销售数量 > 0 的才算有效, 0的默认不限制
  603. If arg_saleqty > lde_saleqty1 Then
  604. arg_msg = "价格指令["+ls_pocode+"]限制销售数量上限为["+String(lde_saleqty1,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],超过数量要求."
  605. rslt = 0
  606. Goto ext
  607. End If
  608. End If
  609. If ll_limitnum > 0 Then //限制次数 > 0 的才算有效, 0的默认不限制
  610. If arg_addnum = 0 Then //增加 1
  611. If ll_limitnum < ll_salenum + 1 Then
  612. arg_msg = "价格指令["+ls_pocode+"]限制使用次数为["+String(ll_limitnum)+"]次, 使用次数已达上限."
  613. rslt = 0
  614. Goto ext
  615. End If
  616. Update u_price_order
  617. Set salenum = salenum + 1
  618. Where poid = :arg_poid;
  619. Else //减少 1
  620. If ll_salenum < 1 Then
  621. arg_msg = "价格指令["+ls_pocode+"]还没有使用记录,不能减少使用次数."
  622. rslt = 0
  623. Goto ext
  624. End If
  625. Update u_price_order
  626. Set salenum = salenum - 1
  627. Where poid = :arg_poid;
  628. End If
  629. If sqlca.SQLCode <> 0 Then
  630. arg_msg = "更新价格指令使用次数信息失败,"+sqlca.SQLErrText
  631. rslt = 0
  632. Goto ext
  633. End If
  634. Update u_price_order
  635. Set inuse = case when salenum >= limitnum then 0 else 1 end ,
  636. inusetype = 1
  637. Where poid = :arg_poid;
  638. If sqlca.SQLCode <> 0 Then
  639. arg_msg = "更新价格指令有效状态失败,"+sqlca.SQLErrText
  640. rslt = 0
  641. Goto ext
  642. End If
  643. End If
  644. ext:
  645. If rslt = 0 Then
  646. Rollback Using sqlca;
  647. ElseIf arg_ifcommit And rslt = 1 Then
  648. Commit Using sqlca;
  649. End If
  650. Return rslt
  651. end function
  652. public function integer audit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg);
  653. //审核价格指令
  654. Long rslt = 1
  655. Long cnt = 0
  656. Int li_flag, li_secflag
  657. string ls_pocode,ls_dscrp
  658. IF uo_option_if_oa_price_order = -1000 THEN
  659. rslt = 0
  660. arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
  661. GOTO ext
  662. END IF
  663. IF uo_option_price_order_secaudit = -1000 THEN
  664. rslt = 0
  665. arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
  666. GOTO ext
  667. END IF
  668. SELECT COUNT(*)
  669. INTO :CNT
  670. FROM u_price_order
  671. Where u_price_order.poid = :arg_poid;
  672. IF SQLCA.SQLCode <> 0 THEN
  673. rslt = 0
  674. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  675. GOTO ext
  676. END IF
  677. IF cnt = 0 THEN
  678. rslt = 0
  679. arg_msg = '没有找到合适的价格指令'
  680. GOTO ext
  681. END IF
  682. SELECT flag,pocode,dscrp
  683. INTO :li_flag,:ls_pocode,:ls_dscrp
  684. FROM u_price_order
  685. Where u_price_order.poid = :arg_poid;
  686. IF SQLCA.SQLCode <> 0 THEN
  687. rslt = 0
  688. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  689. GOTO ext
  690. END IF
  691. IF li_flag = 1 THEN
  692. rslt = 0
  693. arg_msg = '价格指令已审核,不能重复审核'
  694. GOTO ext
  695. END IF
  696. UPDATE u_price_order
  697. SET u_price_order.flag = 1,
  698. u_price_order.auditdate = getdate(),
  699. u_price_order.auditemp = :arg_opemp
  700. WHERE u_price_order.poid = :arg_poid
  701. AND u_price_order.flag = 0;
  702. IF SQLCA.SQLCode <> 0 THEN
  703. rslt = 0
  704. arg_msg = '因网络或其他原因导致审核价格指令失败>>'+SQLCA.SQLErrText
  705. GOTO ext
  706. END IF
  707. If uo_option_price_order_secaudit = 1 And uo_option_if_oa_price_order = 1 And audit_buildtype = 0 Then
  708. If f_oa(sqlca,False,ARG_MSG,2404,0,arg_poid,ls_pocode,ls_pocode,ls_dscrp) = 0 Then
  709. rslt = 0
  710. Goto ext
  711. End If
  712. End If
  713. ext:
  714. IF rslt = 0 THEN
  715. ROLLBACK;
  716. ELSEIF rslt = 1 AND arg_ifcommit THEN
  717. COMMIT;
  718. END IF
  719. RETURN rslt
  720. end function
  721. 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
  722. DateTime server_time
  723. String ls_mtrlsectype,ls_zxmtrlmode,ls_usermtrlmode
  724. long ll_cnt, ll_cnt2, ll_parentid
  725. long ll_mtrltypeid, ll_mtrltypeid_arr[]
  726. long ll_cusareaid, ll_cusareaid_arr[]
  727. long ll_kind, ll_row
  728. datastore ds_price
  729. ds_price = Create datastore
  730. ds_price.DataObject = 'ds_price_order_index'
  731. ds_price.SetTransObject(sqlca)
  732. //查自定义
  733. SELECT mtrlsectype,zxmtrlmode,usermtrlmode
  734. INTO :ls_mtrlsectype,:ls_zxmtrlmode,:ls_usermtrlmode
  735. FROM u_mtrldef
  736. Where mtrlid = :arg_mtrlid;
  737. IF sqlca.SQLCode <> 0 THEN
  738. rslt = 0
  739. GOTO ext
  740. END IF
  741. /////// //检查价格指令
  742. SELECT Top 1 getdate() Into :server_time From u_user;
  743. IF sqlca.SQLCode <> 0 THEN
  744. rslt = 0
  745. arg_msg = '因网络或其他原因取服务器时间失败'+sqlca.SQLErrText
  746. GOTO ext
  747. END IF
  748. server_time = DateTime(Date(String(server_time,'yyyy-mm-dd')),Time(0))
  749. //查物料类别
  750. SELECT mtrltypeid INTO :ll_mtrltypeid
  751. FROM u_mtrldef
  752. Where mtrlid = :arg_mtrlid;
  753. IF sqlca.SQLCode <> 0 THEN
  754. arg_msg = '查询产品类型失败'+sqlca.SQLErrText
  755. rslt = 0
  756. GOTO ext
  757. END IF
  758. ll_cnt++
  759. ll_mtrltypeid_arr[ll_cnt] = ll_mtrltypeid
  760. SELECT parentid INTO :ll_parentid
  761. FROM u_mtrltype
  762. WHERE mtrltypeid = :ll_mtrltypeid
  763. And parentid > 0 ;
  764. DO WHILE sqlca.SQLCode = 0
  765. ll_cnt++
  766. ll_mtrltypeid_arr[ll_cnt] = ll_parentid
  767. ll_mtrltypeid = ll_parentid
  768. SELECT parentid INTO :ll_parentid
  769. FROM u_mtrltype
  770. WHERE mtrltypeid = :ll_mtrltypeid
  771. And parentid > 0 ;
  772. LOOP
  773. //
  774. //查客户区域
  775. SELECT cusareaid INTO :ll_cusareaid
  776. FROM u_cust
  777. Where cusid = :arg_cusid;
  778. IF sqlca.SQLCode <> 0 THEN
  779. arg_msg = '查询客户区域失败'+sqlca.SQLErrText
  780. rslt = 0
  781. GOTO ext
  782. END IF
  783. ll_cnt2++
  784. ll_cusareaid_arr[ll_cnt2] = ll_cusareaid
  785. SELECT parentid INTO :ll_parentid
  786. FROM u_Cusarea
  787. WHERE CusareaID = :ll_cusareaid
  788. And parentid > 0 ;
  789. DO WHILE sqlca.SQLCode = 0
  790. ll_cnt2++
  791. ll_cusareaid_arr[ll_cnt2] = ll_parentid
  792. ll_cusareaid = ll_parentid
  793. SELECT parentid INTO :ll_parentid
  794. FROM u_Cusarea
  795. WHERE CusareaID = :ll_cusareaid
  796. And parentid > 0 ;
  797. LOOP
  798. //查价格指令
  799. 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)
  800. //ll_row = ds_price.RowCount()
  801. //IF ll_row > 0 THEN
  802. // ll_kind = ds_price.Object.Kind[1]
  803. //ELSE
  804. // ll_kind = 0
  805. //END IF
  806. ext:
  807. return ds_price
  808. end function
  809. public function integer uof_chk_orderprice (datastore arg_ds_price);//由价格指令 比较
  810. //
  811. //无价格指令 返回''
  812. //或 价格指定 kind = 0 返回价格
  813. //或 价格限制 kind = 1 检查价格是否受限
  814. //或 折扣指定 kind = 2 返回折扣
  815. int rslt = 1
  816. //long ll_row
  817. //long ll_Kind
  818. decimal lde_saleqty, lde_saleqty1
  819. string ls_pocode
  820. //
  821. //ll_row = arg_ds_price.RowCount()
  822. //
  823. //IF ll_row > 0 THEN
  824. // ll_kind = arg_ds_price.Object.Kind[1]
  825. //ELSE
  826. // ll_kind = 0
  827. //END IF
  828. //
  829. //IF ll_row = 0 then //无价格指令, 不做任何操作
  830. // goto ext
  831. //end if
  832. //
  833. //ls_poexpr = arg_ds_price.Object.poexpr[1]
  834. lde_saleqty = arg_ds_price.Object.saleqty[1]
  835. lde_saleqty1 = arg_ds_price.Object.saleqty1[1]
  836. ls_pocode = arg_ds_price.Object.pocode[1]
  837. //
  838. ////检查使用次数
  839. //IF arg_ds_price.Object.limitnum[1] > 0 THEN
  840. // IF arg_ds_price.Object.limitnum[1] <= arg_ds_price.Object.salenum[1] THEN//使用次数达上限
  841. // rslt = 2
  842. // GOTO ext
  843. // END IF
  844. //END IF
  845. //
  846. ////检查数量范围
  847. //IF lde_saleqty > 0 THEN //限制销售数量 > 0 的才算有效, 0的默认不限制
  848. // IF arg_saleqty < lde_saleqty THEN
  849. // arg_msg = "价格指令["+ls_pocode+"]限制销售数量下限为["+String(lde_saleqty,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],没达到数量要求."
  850. // rslt = 2
  851. // GOTO ext
  852. // END IF
  853. //END IF
  854. //
  855. //IF lde_saleqty1 > 0 THEN //限制销售数量 > 0 的才算有效, 0的默认不限制
  856. // IF arg_saleqty > lde_saleqty1 THEN
  857. // arg_msg = "价格指令["+ls_pocode+"]限制销售数量上限为["+String(lde_saleqty1,"#,##0.####")+"], 本次销售数量为["+String(arg_saleqty,"#,##0.####")+"],超过数量要求."
  858. // rslt = 2
  859. // GOTO ext
  860. // END IF
  861. //END IF
  862. //choose case ll_kind
  863. //
  864. // case 0
  865. //
  866. // case 1
  867. //
  868. //
  869. //
  870. // IF Pos(ls_poexpr,'{') > 0 And Pos(ls_poexpr,'}') > 0 THEN
  871. // ll_pricelistid = Long(Mid(ls_poexpr,Pos(ls_poexpr,'[') + 1,Pos(ls_poexpr,']') - Pos(ls_poexpr,'[') - 1))
  872. //
  873. // SELECT moneyid INTO :ll_moneyid_pricelist
  874. // FROM u_sale_price_list
  875. // Where u_sale_price_list.pricelistid = :ll_pricelistid;
  876. // IF sqlca.SQLCode <> 0 THEN
  877. // rslt = 2
  878. // rtn_price = 0.00
  879. // rtn_zqrate = 1
  880. // GOTO ext
  881. // END IF
  882. //
  883. // IF ll_moneyid_pricelist <> ll_moneyid THEN
  884. // rslt = 2
  885. // rtn_price = 0.00
  886. // rtn_zqrate = 1
  887. // GOTO ext
  888. // END IF
  889. //
  890. // IF ll_statusflag = 2 And arg_status <> '' THEN
  891. // f_checkpz(arg_status,s_pz[])
  892. // arg_pcode = ''
  893. // arg_woodcode = ''
  894. //
  895. // FOR ll_i = 1 To UpperBound(s_pz)
  896. // ls_status_zj = s_pz[ll_i].cfgname
  897. // ld_price_zj = 0
  898. // ld_rebate_zj = 0
  899. //
  900. // SELECT u_sale_price_mx.price,
  901. // u_sale_price_list.flag,
  902. // u_sale_price_list.listname,
  903. // u_sale_price_mx.rebate,
  904. // u_sale_price_mx.pricestr
  905. // INTO :ld_lmsaleprice,:li_flag,:ls_listname,:ld_rebate,:ls_pricestr
  906. // FROM u_sale_price_list,u_sale_price_mx
  907. // WHERE u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
  908. // AND u_sale_price_mx.mtrlid = :arg_mtrlid
  909. // AND u_sale_price_mx.status = :ls_status_zj
  910. // AND u_sale_price_mx.woodcode = :arg_woodcode
  911. // AND u_sale_price_mx.pcode = :arg_pcode
  912. // AND u_sale_price_list.flag = 1
  913. // And u_sale_price_mx.pricelistid = :ll_pricelistid;
  914. //
  915. // IF sqlca.SQLCode <> 0 THEN
  916. // rslt = 2
  917. // rtn_price = 0.00
  918. // rtn_zqrate = 1
  919. // GOTO ext
  920. // END IF
  921. //
  922. // IF li_flag = 0 THEN
  923. // rslt = 2
  924. // rtn_price = 0.00
  925. // rtn_zqrate = 1
  926. // GOTO ext
  927. // END IF
  928. //
  929. // IF Trim(ls_pricestr) <> '' THEN
  930. // li_rslt_cmp = uof_pricestr_cmp(ls_pricestr,ls_status_ori,ls_woodcode_ori,ls_pcode_ori,ld_price_cmp)
  931. //
  932. // IF li_rslt_cmp = 1 THEN
  933. // ld_lmsaleprice = ld_price_cmp
  934. // ELSEIF li_rslt_cmp = 0 THEN
  935. // ld_lmsaleprice = 0
  936. // END IF
  937. //
  938. // END IF
  939. //
  940. // obj_price = obj_price + ld_lmsaleprice * ld_rebate * Dec(s_pz[ll_i].qty)
  941. // NEXT
  942. // ELSE
  943. // SELECT u_sale_price_mx.price,
  944. // u_sale_price_list.flag,
  945. // u_sale_price_list.listname,
  946. // u_sale_price_mx.rebate,
  947. // u_sale_price_mx.pricestr
  948. // INTO :ld_lmsaleprice,:li_flag,:ls_listname,:ld_rebate,:ls_pricestr
  949. // FROM u_sale_price_list,u_sale_price_mx
  950. // WHERE u_sale_price_mx.pricelistid = u_sale_price_list.pricelistid
  951. // AND u_sale_price_mx.mtrlid = :arg_mtrlid
  952. // AND u_sale_price_mx.status = :arg_status
  953. // AND u_sale_price_mx.woodcode = :arg_woodcode
  954. // AND u_sale_price_mx.pcode = :arg_pcode
  955. // AND u_sale_price_list.flag = 1
  956. // And u_sale_price_mx.pricelistid = :ll_pricelistid;
  957. //
  958. // IF sqlca.SQLCode <> 0 THEN
  959. // rslt = 2
  960. // rtn_price = 0.00
  961. // rtn_zqrate = 1
  962. // GOTO ext
  963. // END IF
  964. //
  965. // IF li_flag = 0 THEN
  966. // rslt = 2
  967. // rtn_price = 0.00
  968. // rtn_zqrate = 1
  969. // GOTO ext
  970. // END IF
  971. //
  972. // IF Trim(ls_pricestr) <> '' THEN
  973. // li_rslt_cmp = uof_pricestr_cmp(ls_pricestr,ls_status_ori,ls_woodcode_ori,ls_pcode_ori,ld_price_cmp)
  974. //
  975. // IF li_rslt_cmp = 1 THEN
  976. // ld_lmsaleprice = ld_price_cmp
  977. // ELSEIF li_rslt_cmp = 0 THEN
  978. // ld_lmsaleprice = 0
  979. // END IF
  980. //
  981. // END IF
  982. //
  983. // obj_price = ld_lmsaleprice * ld_rebate
  984. // END IF
  985. // ls_poexpr = Replace(ls_poexpr,Pos(ls_poexpr,'{'),Pos(ls_poexpr,'}') - Pos(ls_poexpr,'{') + 1,String(obj_price,'###0.00########'))
  986. //
  987. // END IF
  988. // datastore dw_price_check
  989. // dw_price_check = Create datastore
  990. // dw_price_check.DataObject = 'dw_compute_priceorder'
  991. // dw_price_check.InsertRow(0)
  992. // dw_price_check.Modify("compute.expression='"+Mid(ls_poexpr,Pos(ls_poexpr,'=') + 1)+"'")
  993. //
  994. // ld_lmsaleprice = dw_price_check.Object.compute[ll_row]
  995. //
  996. // ld_rebate = 1
  997. //
  998. // rtn_price = ld_lmsaleprice
  999. // rtn_zqrate = ld_rebate
  1000. // case 2
  1001. //
  1002. //end choose
  1003. //
  1004. //
  1005. //
  1006. //ext:
  1007. return rslt
  1008. end function
  1009. public function decimal uof_priceorder_cmpl (string arg_poexpr, decimal arg_price);//kind = 0 或 kind = 2适用, 返回指定的价格
  1010. String ls_poexpr
  1011. Long ll_row
  1012. Decimal lde_rtncmp
  1013. ls_poexpr = arg_poexpr
  1014. IF Pos(ls_poexpr,'{') > 0 And Pos(ls_poexpr,'}') > 0 THEN
  1015. ls_poexpr = Replace(ls_poexpr,Pos(ls_poexpr,'{'),Pos(ls_poexpr,'}') - Pos(ls_poexpr,'{') + 1,String(arg_price,'###0.00########'))
  1016. END IF
  1017. ls_poexpr = Mid(ls_poexpr,Pos(ls_poexpr,'=') + 1)
  1018. datastore ds_price_chk
  1019. ds_price_chk = Create datastore
  1020. ds_price_chk.DataObject = 'dw_compute_priceorder'
  1021. ll_row = ds_price_chk.InsertRow(0)
  1022. ds_price_chk.Modify("compute.expression='"+ls_poexpr+"'")
  1023. lde_rtncmp = ds_price_chk.Object.compute[ll_row]
  1024. destroy ds_price_chk
  1025. RETURN lde_rtncmp
  1026. end function
  1027. public function boolean uof_priceorder_cmpl_1 (string arg_poexpr, decimal arg_price);//kind = 1 适用, 返回指定的价格是否符合价格限定
  1028. String ls_poexpr
  1029. Long ll_row
  1030. string ls_rtncmp
  1031. ls_poexpr = arg_poexpr
  1032. IF Pos(ls_poexpr,'{') > 0 And Pos(ls_poexpr,'}') > 0 THEN
  1033. ls_poexpr = Replace(ls_poexpr,Pos(ls_poexpr,'{'),Pos(ls_poexpr,'}') - Pos(ls_poexpr,'{') + 1,String(arg_price,'###0.00########'))
  1034. END IF
  1035. //ls_poexpr = Mid(ls_poexpr,Pos(ls_poexpr,'=') + 1)
  1036. datastore ds_price_chk
  1037. ds_price_chk = Create datastore
  1038. ds_price_chk.DataObject = 'dw_compute_priceorder'
  1039. ll_row = ds_price_chk.InsertRow(0)
  1040. ds_price_chk.Modify("compute.expression='"+ls_poexpr+"'")
  1041. ls_rtncmp = String(ds_price_chk.Object.compute[ll_row])
  1042. destroy ds_price_chk
  1043. IF ls_rtncmp = 'false' THEN
  1044. RETURN False
  1045. ELSE
  1046. RETURN True
  1047. END IF
  1048. end function
  1049. public function integer secaudit (long arg_poid, string arg_opemp, boolean arg_ifcommit, ref string arg_msg);
  1050. //终审核价格指令
  1051. Long rslt = 1
  1052. Long cnt = 0
  1053. Int li_flag, li_secflag
  1054. IF uo_option_if_oa_price_order = -1000 THEN
  1055. rslt = 0
  1056. arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
  1057. GOTO ext
  1058. END IF
  1059. IF uo_option_price_order_secaudit = -1000 THEN
  1060. rslt = 0
  1061. arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
  1062. GOTO ext
  1063. END IF
  1064. SELECT COUNT(*)
  1065. INTO :CNT
  1066. FROM u_price_order
  1067. Where u_price_order.poid = :arg_poid;
  1068. IF SQLCA.SQLCode <> 0 THEN
  1069. rslt = 0
  1070. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  1071. GOTO ext
  1072. END IF
  1073. IF cnt = 0 THEN
  1074. rslt = 0
  1075. arg_msg = '没有找到合适的价格指令'
  1076. GOTO ext
  1077. END IF
  1078. SELECT flag, secflag INTO :li_flag, :li_secflag
  1079. FROM u_price_order
  1080. Where u_price_order.poid = :arg_poid;
  1081. IF SQLCA.SQLCode <> 0 THEN
  1082. rslt = 0
  1083. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  1084. GOTO ext
  1085. END IF
  1086. IF li_flag = 0 THEN
  1087. rslt = 0
  1088. arg_msg = '价格指令未审核,不能终审'
  1089. GOTO ext
  1090. END IF
  1091. IF li_secflag = 1 THEN
  1092. rslt = 0
  1093. arg_msg = '价格指令已终审'
  1094. GOTO ext
  1095. END IF
  1096. If uo_option_if_oa_price_order = 1 And uo_option_price_order_secaudit = 1 And audit_buildtype = 0 Then
  1097. If f_check_if_oaflow(0,arg_poid,2404,ARG_MSG ) = 0 Then
  1098. rslt = 0
  1099. Goto ext
  1100. End If
  1101. End If
  1102. UPDATE u_price_order
  1103. SET u_price_order.secflag = 1,
  1104. u_price_order.secauditdate = getdate(),
  1105. u_price_order.secauditemp = :arg_opemp
  1106. WHERE u_price_order.poid = :arg_poid
  1107. AND u_price_order.flag = 1
  1108. AND u_price_order.secflag = 0;
  1109. IF SQLCA.SQLCode <> 0 THEN
  1110. rslt = 0
  1111. arg_msg = '因网络或其他原因导致终审核价格指令失败>>'+SQLCA.SQLErrText
  1112. GOTO ext
  1113. END IF
  1114. ext:
  1115. IF rslt = 0 THEN
  1116. ROLLBACK;
  1117. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1118. COMMIT;
  1119. END IF
  1120. RETURN rslt
  1121. end function
  1122. public function integer csecaudit (long arg_poid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1123. Long cnt = 0
  1124. Int li_flag, li_secflag
  1125. DateTime null_dt
  1126. SetNull(null_dt)
  1127. If uo_option_if_oa_price_order = -1000 Then
  1128. rslt = 0
  1129. arg_msg = '选项:[408]高级价格策略使用OA审批流程,读取初始默认值失败,操作取消!'
  1130. Goto ext
  1131. End If
  1132. If uo_option_price_order_secaudit = -1000 Then
  1133. rslt = 0
  1134. arg_msg = '选项:[367]高级价格策略使用二级审核,读取初始默认值失败,操作取消!'
  1135. Goto ext
  1136. End If
  1137. Select COUNT(*)
  1138. Into :CNT
  1139. From u_price_order
  1140. Where u_price_order.poid = :arg_poid;
  1141. If SQLCA.SQLCode <> 0 Then
  1142. rslt = 0
  1143. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  1144. Goto ext
  1145. End If
  1146. If cnt = 0 Then
  1147. rslt = 0
  1148. arg_msg = '没有找到合适的价格指令'
  1149. Goto ext
  1150. End If
  1151. Select flag, secflag Into :li_flag, :li_secflag
  1152. From u_price_order
  1153. Where u_price_order.poid = :arg_poid;
  1154. If SQLCA.SQLCode <> 0 Then
  1155. rslt = 0
  1156. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  1157. Goto ext
  1158. End If
  1159. If li_secflag = 0 Then
  1160. rslt = 0
  1161. arg_msg = '价格指令未终审,不能撤审'
  1162. Goto ext
  1163. End If
  1164. //查询价格指令是否已用于销售订单
  1165. Select count(*)
  1166. Into :cnt
  1167. From u_SaleTaskMx
  1168. Where poid = :arg_poid;
  1169. If SQLCA.SQLCode <> 0 Then
  1170. rslt = 0
  1171. arg_msg = '因网络或其他原因查询指令是否已用于销售订单失败>>'+SQLCA.SQLErrText
  1172. Goto ext
  1173. End If
  1174. If cnt > 0 Then
  1175. rslt = 0
  1176. arg_msg = '价格指令已用于销售订单,不能撤审'
  1177. Goto ext
  1178. End If
  1179. If uo_option_if_oa_price_order = 0 Then
  1180. Update u_price_order
  1181. Set u_price_order.secflag = 0,
  1182. u_price_order.secauditemp = '',
  1183. u_price_order.secauditdate = :null_dt
  1184. Where u_price_order.poid = :arg_poid
  1185. And u_price_order.secflag = 1;
  1186. If SQLCA.SQLCode <> 0 Then
  1187. rslt = 0
  1188. arg_msg = '因网络或其他原因导致撤审价格指令失败>>'+SQLCA.SQLErrText
  1189. Goto ext
  1190. End If
  1191. Else
  1192. Update u_price_order
  1193. Set u_price_order.flag = 0,
  1194. u_price_order.auditemp = '',
  1195. u_price_order.auditdate = :null_dt,
  1196. u_price_order.secflag = 0,
  1197. u_price_order.secauditemp = '',
  1198. u_price_order.secauditdate = :null_dt
  1199. Where u_price_order.poid = :arg_poid
  1200. And u_price_order.secflag = 1;
  1201. If SQLCA.SQLCode <> 0 Then
  1202. rslt = 0
  1203. arg_msg = '因网络或其他原因导致撤审价格指令失败>>'+SQLCA.SQLErrText
  1204. Goto ext
  1205. End If
  1206. End If
  1207. //将相关已完成的OA公文的状态设为作废
  1208. If (uo_option_price_order_secaudit = 1 And uo_option_if_oa_price_order = 1) Then
  1209. Update oa_doc
  1210. Set docflag = 12
  1211. Where powerid = 2404
  1212. And scid = 0
  1213. And billid = :arg_poid;
  1214. If SQLCA.SQLCode <> 0 Then
  1215. rslt = 0
  1216. arg_msg = '更新相关公文状态失败'+SQLCA.SQLErrText
  1217. Goto ext
  1218. End If
  1219. End If
  1220. ext:
  1221. If rslt = 0 Then
  1222. Rollback;
  1223. ElseIf rslt = 1 And arg_ifcommit Then
  1224. Commit;
  1225. End If
  1226. Return rslt
  1227. end function
  1228. public function integer add_dscrp (long arg_poid, string arg_newdescppart, ref string arg_msg);
  1229. Int rslt = 1
  1230. Int li_flag,li_billtype
  1231. IF arg_newdescppart = '' THEN
  1232. rslt = 0
  1233. arG_MSG = "要添加内容为空,操作取消"
  1234. GOTO ext
  1235. END IF
  1236. SELECT flag INTO :li_flag
  1237. FROM u_price_order
  1238. Where u_price_order.poid = :arg_poid;
  1239. IF SQLCA.SQLCode <> 0 THEN
  1240. rslt = 0
  1241. arg_msg = '查询指令是否已审核失败>>'+SQLCA.SQLErrText
  1242. GOTO ext
  1243. END IF
  1244. IF li_flag = 0 THEN
  1245. rslt = 0
  1246. arG_MSG = "待审核状态下不可用"
  1247. GOTO ext
  1248. END IF
  1249. UPDATE u_price_order
  1250. SET DSCRP = DSCRP+' '+:arg_newdescppart
  1251. WHERE u_price_order.poid = :arg_poid;
  1252. IF SQLCA.SQLCode <> 0 THEN
  1253. rslt = 0
  1254. arg_msg = '添加备注操作失败,'+SQLCA.SQLErrText
  1255. GOTO ext
  1256. END IF
  1257. ext:
  1258. IF rslt = 1 THEN
  1259. COMMIT;
  1260. ELSE
  1261. ROLLBACK;
  1262. END IF
  1263. Return (rslt)
  1264. end function
  1265. public function integer uof_c_inuse (long arg_poid, string arg_cinusereason, boolean arg_ifcommit, ref string arg_msg);
  1266. Long rslt = 1
  1267. Long cnt = 0
  1268. Int li_inuse
  1269. SELECT COUNT(*)
  1270. INTO :CNT
  1271. FROM u_price_order
  1272. Where u_price_order.poid = :arg_poid;
  1273. IF SQLCA.SQLCode <> 0 THEN
  1274. rslt = 0
  1275. arg_msg = '因网络或其他原因查询失败>>'+SQLCA.SQLErrText
  1276. GOTO ext
  1277. END IF
  1278. IF cnt = 0 THEN
  1279. rslt = 0
  1280. arg_msg = '没有找到合适的价格指令'
  1281. GOTO ext
  1282. END IF
  1283. SELECT inuse INTO :li_inuse
  1284. FROM u_price_order
  1285. Where u_price_order.poid = :arg_poid;
  1286. IF SQLCA.SQLCode <> 0 THEN
  1287. rslt = 0
  1288. arg_msg = '因网络或其他原因查询指令是否已审核失败>>'+SQLCA.SQLErrText
  1289. GOTO ext
  1290. END IF
  1291. IF li_inuse = 0 THEN
  1292. rslt = 0
  1293. arg_msg = '价格指令已设为无效,不能重复设置'
  1294. GOTO ext
  1295. END IF
  1296. UPDATE u_price_order
  1297. SET u_price_order.inuse = 0,
  1298. u_price_order.inusetype = 0,
  1299. u_price_order.cinusereason = :arg_cinusereason,
  1300. u_price_order.cinuseemp = :publ_operator,
  1301. u_price_order.cinusedate = getdate()
  1302. WHERE u_price_order.poid = :arg_poid
  1303. AND u_price_order.inuse = 1;
  1304. IF SQLCA.SQLCode <> 0 THEN
  1305. rslt = 0
  1306. arg_msg = '因网络或其他原因导致设置价格指令无效失败>>'+SQLCA.SQLErrText
  1307. GOTO ext
  1308. END IF
  1309. ext:
  1310. IF rslt = 0 THEN
  1311. ROLLBACK;
  1312. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1313. COMMIT;
  1314. END IF
  1315. RETURN rslt
  1316. end function
  1317. on uo_price_order.create
  1318. call super::create
  1319. TriggerEvent( this, "constructor" )
  1320. end on
  1321. on uo_price_order.destroy
  1322. TriggerEvent( this, "destructor" )
  1323. call super::destroy
  1324. end on
  1325. event constructor;String arg_msg
  1326. String str_optionvalue
  1327. str_optionvalue = ''
  1328. f_get_sys_option_value('363',str_optionvalue,arg_msg)
  1329. uo_option_price_order_check = Long(str_optionvalue)
  1330. str_optionvalue = ''
  1331. f_get_sys_option_value('367',str_optionvalue,arg_msg)
  1332. uo_option_price_order_secaudit = Long(str_optionvalue)
  1333. str_optionvalue = ''
  1334. f_get_sys_option_value('408',str_optionvalue,arg_msg)
  1335. uo_option_if_oa_price_order = Long(str_optionvalue)
  1336. end event