uo_taobao_outware.sru 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. $PBExportHeader$uo_taobao_outware.sru
  2. forward
  3. global type uo_taobao_outware from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_taobao_outware from nonvisualobject
  7. end type
  8. global uo_taobao_outware uo_taobao_outware
  9. forward prototypes
  10. public function integer add_tranfy (long arg_scid, long arg_outwareid, long arg_itemid, decimal arg_amt, ref string arg_msg, boolean arg_if_commit)
  11. public function integer save_transcode (string arg_outwarecode, string arg_relstr_1, string arg_transcode, decimal arg_weight, ref string arg_msg, boolean arg_ifcommit)
  12. public function integer save_transcode (string arg_outwarecode, string arg_relstr_1, string arg_transcode, ref string arg_msg, boolean arg_ifcommit)
  13. end prototypes
  14. public function integer add_tranfy (long arg_scid, long arg_outwareid, long arg_itemid, decimal arg_amt, ref string arg_msg, boolean arg_if_commit);Int rslt = 1
  15. UPDATE u_outware SET
  16. transcode = transcode
  17. WHERE scid = :arg_scid
  18. And outwareid = :arg_outwareid;
  19. // 加锁,避免其他人修改单据
  20. IF sqlca.SQLCode <> 0 THEN
  21. rslt = 0
  22. arg_msg = '对销售发货单加锁失败,' + sqlca.SQLErrText
  23. GOTO ext
  24. END IF
  25. IF sqlca.SQLNRows = 0 THEN
  26. rslt = 0
  27. arg_msg = '对应销售发货单已经被删除'
  28. GOTO ext
  29. END IF
  30. Long secflag
  31. SELECT secflag
  32. INTO :secflag
  33. FROM u_outware
  34. WHERE scid = :arg_scid
  35. And outwareid = :arg_outwareid;
  36. IF sqlca.SQLCode <> 0 THEN
  37. rslt = 0
  38. arg_msg = '查询销售发货单财审状态失败,' + sqlca.SQLErrText
  39. GOTO ext
  40. END IF
  41. IF secflag = 1 THEN
  42. rslt = 0
  43. arg_msg = '销售发货单已经财审,不能录入运费'
  44. GOTO ext
  45. END IF
  46. Long ll_dfttype
  47. SELECT dfttype
  48. INTO :ll_dfttype
  49. FROM u_itemdef
  50. Where itemid = :arg_itemid;
  51. IF sqlca.SQLCode <> 0 THEN
  52. rslt = 0
  53. arg_msg = '查询收支项目类型失败,' + sqlca.SQLErrText
  54. GOTO ext
  55. END IF
  56. IF ll_dfttype <> 15 THEN
  57. rslt = 0
  58. arg_msg = '收支项目类型不是默认淘宝运费'
  59. GOTO ext
  60. END IF
  61. //Long ll_cnt
  62. //SELECT COUNT(0)
  63. // INTO :ll_cnt
  64. // FROM u_outware_itemmx INNER JOIN
  65. // u_itemdef ON u_outware_itemmx.itemid = u_itemdef.itemid
  66. // Where (u_itemdef.dfttype = 15);
  67. //IF sqlca.SQLCode <> 0 THEN
  68. // rslt = 0
  69. // arg_msg = '查询现有运费失败,' + sqlca.SQLErrText
  70. // GOTO ext
  71. //END IF
  72. //IF ll_cnt > 1 THEN
  73. //
  74. //ELSEIF ll_cnt = 1 THEN
  75. //
  76. //ELSE
  77. //
  78. //END IF
  79. DELETE FROM u_outware_itemmx
  80. FROM u_outware_itemmx INNER JOIN
  81. u_itemdef ON u_outware_itemmx.itemid = u_itemdef.itemid
  82. WHERE (u_itemdef.dfttype = 15)
  83. AND (u_outware_itemmx.scid = :arg_scid)
  84. And (u_outware_itemmx.outwareid = :arg_outwareid);
  85. IF sqlca.SQLCode <> 0 THEN
  86. rslt = 0
  87. arg_msg = '删除旧运费失败,' + sqlca.SQLErrText
  88. GOTO ext
  89. END IF
  90. Long printid
  91. SELECT isnull(max(printid), 0)
  92. INTO :printid
  93. FROM u_outware_itemmx
  94. WHERE scid = :arg_scid
  95. And outwareid = :arg_outwareid;
  96. IF sqlca.SQLCode <> 0 THEN
  97. rslt = 0
  98. arg_msg = '获取费用明细序号失败,' + sqlca.SQLErrText
  99. GOTO ext
  100. END IF
  101. printid ++
  102. INSERT INTO u_outware_itemmx(scid, outwareid, printid, itemid, amt)
  103. Values(:arg_scid, :arg_outwareid, :printid, :arg_itemid, :arg_amt);
  104. IF sqlca.SQLCode <> 0 THEN
  105. rslt = 0
  106. arg_msg = '添加费用明细失败,' + sqlca.SQLErrText
  107. GOTO ext
  108. END IF
  109. UPDATE u_outware_itemmx
  110. SET IsCusAmt = 0
  111. WHERE scid = :arg_scid
  112. AND outwareid = :arg_outwareid
  113. And printid = :printid;
  114. ext:
  115. IF arg_if_commit THEN
  116. IF rslt = 1 THEN
  117. COMMIT;
  118. ELSE
  119. ROLLBACK;
  120. END IF
  121. END IF
  122. RETURN rslt
  123. end function
  124. public function integer save_transcode (string arg_outwarecode, string arg_relstr_1, string arg_transcode, decimal arg_weight, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  125. //rslt = 0
  126. //arg_msg = '需要子类实现'
  127. //GOTO ext
  128. UPDATE u_outware
  129. SET relstr_1 = :arg_relstr_1,
  130. transcode = :arg_transcode,
  131. tb_weight = :arg_weight
  132. WHERE outwarecode = :arg_outwarecode
  133. And secflag = 0;
  134. IF sqlca.SQLCode <> 0 THEN
  135. rslt = 0
  136. arg_msg = arg_outwarecode + '更新发货单货运单号失败,' + sqlca.SQLErrText
  137. GOTO ext
  138. END IF
  139. IF sqlca.SQLNRows = 0 THEN
  140. rslt = 0
  141. arg_msg = arg_outwarecode + '更新发货单货运单号失败,发货单已经审核或被删除'
  142. GOTO ext
  143. END IF
  144. ext:
  145. IF arg_ifcommit THEN
  146. IF rslt = 1 THEN
  147. COMMIT;
  148. ELSE
  149. ROLLBACK;
  150. END IF
  151. END IF
  152. RETURN rslt
  153. end function
  154. public function integer save_transcode (string arg_outwarecode, string arg_relstr_1, string arg_transcode, ref string arg_msg, boolean arg_ifcommit);return save_transcode(arg_outwarecode, arg_relstr_1, arg_transcode, 0, ref arg_msg, arg_ifcommit)
  155. end function
  156. on uo_taobao_outware.create
  157. call super::create
  158. TriggerEvent( this, "constructor" )
  159. end on
  160. on uo_taobao_outware.destroy
  161. TriggerEvent( this, "destructor" )
  162. call super::destroy
  163. end on