oak-pay-business 1.1.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (444) hide show
  1. package/es/aspects/AspectDict.d.ts +4 -2
  2. package/es/aspects/index.js +2 -2
  3. package/es/aspects/withdraw.d.ts +62 -0
  4. package/es/aspects/withdraw.js +209 -0
  5. package/es/checkers/abstractChecker.d.ts +7 -0
  6. package/es/checkers/abstractChecker.js +27 -0
  7. package/es/checkers/accountOper.js +8 -0
  8. package/es/checkers/index.js +8 -0
  9. package/es/checkers/offlineAccount.js +16 -0
  10. package/es/checkers/order.js +42 -1
  11. package/es/checkers/pay.js +23 -3
  12. package/es/checkers/refund.js +61 -1
  13. package/es/checkers/withdrawAccount.d.ts +5 -0
  14. package/es/checkers/withdrawAccount.js +71 -0
  15. package/es/checkers/withdrawTransfer.d.ts +5 -0
  16. package/es/checkers/withdrawTransfer.js +32 -0
  17. package/es/components/account/detail/index.d.ts +1 -0
  18. package/es/components/account/detail/index.js +23 -2
  19. package/es/components/account/detail/web.js +22 -9
  20. package/es/components/accountOper/pure/List.pc.js +4 -3
  21. package/es/components/offlineAccount/config/index.js +15 -0
  22. package/es/components/offlineAccount/config/web.pc.d.ts +9 -0
  23. package/es/components/offlineAccount/config/web.pc.js +17 -12
  24. package/es/components/offlineAccount/config/web.pc.module.less +1 -1
  25. package/es/components/offlineAccount/upsert/index.js +3 -0
  26. package/es/components/offlineAccount/upsert/locales/zh-CN.json +3 -1
  27. package/es/components/offlineAccount/upsert/web.pc.js +15 -4
  28. package/es/components/order/list/index.d.ts +3 -0
  29. package/es/components/order/list/index.js +49 -0
  30. package/es/components/order/list/locales/zh-CN.json +5 -0
  31. package/es/components/order/list/web.pc.d.ts +9 -0
  32. package/es/components/order/list/web.pc.js +59 -0
  33. package/es/components/pay/list/index.js +1 -0
  34. package/es/components/pay/list/locales/zh-CN.json +3 -0
  35. package/es/components/pay/list/web.pc.js +38 -10
  36. package/es/components/payConfig/system/index.js +2 -0
  37. package/es/components/payConfig/system/web.pc.d.ts +1 -0
  38. package/es/components/payConfig/system/web.pc.js +12 -12
  39. package/es/components/refund/list/index.d.ts +3 -0
  40. package/es/components/refund/list/index.js +75 -0
  41. package/es/components/refund/list/locales/zh-CN.json +11 -0
  42. package/es/components/refund/list/web.pc.d.ts +11 -0
  43. package/es/components/refund/list/web.pc.js +183 -0
  44. package/es/components/refund/list/web.pc.module.less +23 -0
  45. package/es/components/sysAccount/survey/index.d.ts +6 -0
  46. package/es/components/sysAccount/survey/index.js +208 -0
  47. package/es/components/sysAccount/survey/index.json +1 -0
  48. package/es/components/sysAccount/survey/locales/zh-CN.json +28 -0
  49. package/es/components/sysAccount/survey/web.pc.d.ts +22 -0
  50. package/es/components/sysAccount/survey/web.pc.js +191 -0
  51. package/es/components/sysAccount/survey/web.pc.module.less +73 -0
  52. package/es/components/withdraw/create/index.d.ts +1 -0
  53. package/es/components/withdraw/create/index.js +94 -105
  54. package/es/components/withdraw/create/index.json +2 -1
  55. package/es/components/withdraw/create/index.less +36 -9
  56. package/es/components/withdraw/create/index.xml +47 -23
  57. package/es/components/withdraw/create/locales/zh-CN.json +8 -3
  58. package/es/components/withdraw/create/web.d.ts +10 -10
  59. package/es/components/withdraw/create/web.js +73 -68
  60. package/es/components/withdraw/create/web.module.less +10 -0
  61. package/es/components/withdraw/create/web.pc.d.ts +10 -10
  62. package/es/components/withdraw/create/web.pc.js +56 -48
  63. package/es/components/withdraw/create/web.pc.module.less +10 -0
  64. package/es/components/withdraw/detail/index.js +26 -26
  65. package/es/components/withdraw/detail/index.json +1 -1
  66. package/es/components/withdraw/detail/index.less +2 -4
  67. package/es/components/withdraw/detail/index.xml +3 -10
  68. package/es/components/withdraw/detail/web.d.ts +1 -14
  69. package/es/components/withdraw/detail/web.js +4 -4
  70. package/es/components/withdraw/detail/web.pc.d.ts +1 -14
  71. package/es/components/withdraw/detail/web.pc.js +4 -4
  72. package/es/components/withdraw/display/index.d.ts +6 -0
  73. package/es/components/withdraw/display/index.js +79 -0
  74. package/es/components/withdraw/{dry → display}/index.json +1 -0
  75. package/es/components/withdraw/{dry → display}/index.less +9 -3
  76. package/es/components/withdraw/{dry → display}/index.xml +9 -6
  77. package/es/components/withdraw/{dry → display}/locales/zh-CN.json +1 -1
  78. package/es/components/withdraw/display/web.d.ts +26 -0
  79. package/es/components/withdraw/{dry/Detail.mobile.js → display/web.js} +11 -5
  80. package/es/components/withdraw/{dry/Detail.module.less → display/web.module.less} +8 -0
  81. package/es/components/withdraw/display/web.pc.d.ts +26 -0
  82. package/es/components/withdraw/{dry/Detail.pc.js → display/web.pc.js} +14 -9
  83. package/es/components/withdraw/{dry/Detail.pc.module.less → display/web.pc.module.less} +4 -0
  84. package/es/components/{withdrawChannel → withdraw}/list/index.d.ts +3 -4
  85. package/es/components/withdraw/list/index.js +103 -0
  86. package/es/components/withdraw/list/index.json +9 -0
  87. package/es/components/withdraw/list/index.less +42 -0
  88. package/es/components/withdraw/list/index.xml +37 -0
  89. package/es/components/withdraw/list/locales/zh-CN.json +6 -0
  90. package/es/components/withdraw/list/web.d.ts +17 -0
  91. package/es/components/withdraw/list/web.js +20 -0
  92. package/es/components/withdraw/list/web.pc.d.ts +17 -0
  93. package/es/components/withdraw/list/web.pc.js +42 -0
  94. package/es/components/withdraw/list/web.pc.module.less +28 -0
  95. package/es/components/withdrawAccount/list/index.d.ts +8 -0
  96. package/es/components/withdrawAccount/list/index.js +210 -0
  97. package/es/components/withdrawAccount/list/index.json +15 -0
  98. package/es/components/withdrawAccount/list/index.less +116 -0
  99. package/es/components/withdrawAccount/list/index.xml +144 -0
  100. package/es/components/withdrawAccount/list/locales/zh-CN.json +6 -0
  101. package/es/components/withdrawAccount/list/web.d.ts +29 -0
  102. package/es/components/withdrawAccount/list/web.js +87 -0
  103. package/es/components/withdrawAccount/list/web.module.less +41 -0
  104. package/es/components/withdrawAccount/list/web.pc.d.ts +29 -0
  105. package/es/components/withdrawAccount/list/web.pc.js +71 -0
  106. package/es/components/withdrawAccount/list/web.pc.module.less +36 -0
  107. package/es/components/withdrawAccount/upsert/index.d.ts +6 -0
  108. package/es/components/withdrawAccount/upsert/index.js +134 -0
  109. package/es/components/withdrawAccount/upsert/index.json +11 -0
  110. package/es/components/withdrawAccount/upsert/index.less +0 -0
  111. package/es/components/withdrawAccount/upsert/index.xml +53 -0
  112. package/es/components/withdrawAccount/upsert/locales/zh-CN.json +11 -0
  113. package/es/components/withdrawAccount/upsert/web.d.ts +16 -0
  114. package/es/components/withdrawAccount/upsert/web.js +34 -0
  115. package/es/components/withdrawAccount/upsert/web.pc.d.ts +16 -0
  116. package/es/components/withdrawAccount/upsert/web.pc.js +35 -0
  117. package/es/components/withdrawTransfer/list/index.d.ts +4 -0
  118. package/es/components/withdrawTransfer/list/index.js +115 -0
  119. package/es/components/withdrawTransfer/list/index.json +1 -0
  120. package/es/components/withdrawTransfer/list/locales/zh-CN.json +10 -0
  121. package/es/components/withdrawTransfer/list/web.pc.d.ts +16 -0
  122. package/es/components/withdrawTransfer/list/web.pc.js +151 -0
  123. package/es/components/withdrawTransfer/list/web.pc.module.less +34 -0
  124. package/es/components/wpAccount/config/index.d.ts +3 -2
  125. package/es/components/wpAccount/config/index.js +19 -3
  126. package/es/components/wpAccount/config/web.pc.d.ts +7 -0
  127. package/es/components/wpAccount/config/web.pc.js +39 -33
  128. package/es/components/wpAccount/upsert/index.js +4 -0
  129. package/es/components/wpAccount/upsert/locales/zh-CN.json +3 -1
  130. package/es/configuration/attrUpdateMatrix.js +51 -3
  131. package/es/configuration/relation.js +2 -0
  132. package/es/context/BackendRuntimeContext.d.ts +1 -1
  133. package/es/data/actionAuth.js +36 -6
  134. package/es/data/i18n.js +189 -21
  135. package/es/data/path.js +41 -6
  136. package/es/entities/AbstractAccount.d.ts +3 -1
  137. package/es/entities/AbstractAccount.js +2 -0
  138. package/es/entities/AccountOper.d.ts +1 -1
  139. package/es/entities/AccountOper.js +7 -1
  140. package/es/entities/OfflineAccount.d.ts +2 -0
  141. package/es/entities/OfflineAccount.js +3 -0
  142. package/es/entities/Order.d.ts +7 -2
  143. package/es/entities/Order.js +22 -0
  144. package/es/entities/Pay.js +12 -2
  145. package/es/entities/Refund.d.ts +8 -6
  146. package/es/entities/Refund.js +11 -15
  147. package/es/entities/SysAccountOper.d.ts +3 -3
  148. package/es/entities/SysAccountOper.js +7 -3
  149. package/es/entities/Withdraw.d.ts +0 -4
  150. package/es/entities/Withdraw.js +0 -2
  151. package/es/entities/WithdrawAccount.d.ts +5 -2
  152. package/es/entities/WithdrawAccount.js +12 -1
  153. package/es/entities/WithdrawChannel.d.ts +7 -4
  154. package/es/entities/WithdrawChannel.js +14 -3
  155. package/es/entities/WithdrawTransfer.d.ts +27 -0
  156. package/es/entities/WithdrawTransfer.js +52 -0
  157. package/es/entities/WpAccount.d.ts +2 -0
  158. package/es/entities/WpAccount.js +3 -0
  159. package/es/locales/error/zh-CN.json +9 -0
  160. package/es/locales/offlineAccount/zh-CN.json +4 -2
  161. package/es/locales/withdraw/zh-CN.json +35 -0
  162. package/es/oak-app-domain/AbstractAccount/Schema.d.ts +14 -2
  163. package/es/oak-app-domain/AbstractAccount/Storage.js +11 -0
  164. package/es/oak-app-domain/AbstractAccount/locales/zh_CN.json +1 -1
  165. package/es/oak-app-domain/AccountOper/Schema.d.ts +93 -6
  166. package/es/oak-app-domain/AccountOper/Storage.js +2 -2
  167. package/es/oak-app-domain/AccountOper/Style.js +3 -0
  168. package/es/oak-app-domain/AccountOper/locales/zh_CN.json +1 -1
  169. package/es/oak-app-domain/ActionDefDict.d.ts +5 -0
  170. package/es/oak-app-domain/ActionDefDict.js +6 -0
  171. package/es/oak-app-domain/EntityDict.d.ts +2 -0
  172. package/es/oak-app-domain/ModiEntity/Schema.d.ts +34 -5
  173. package/es/oak-app-domain/ModiEntity/Storage.js +1 -1
  174. package/es/oak-app-domain/OfflineAccount/Schema.d.ts +25 -1
  175. package/es/oak-app-domain/OfflineAccount/Storage.js +11 -0
  176. package/es/oak-app-domain/OfflineAccount/locales/zh_CN.json +1 -1
  177. package/es/oak-app-domain/OperEntity/Schema.d.ts +34 -5
  178. package/es/oak-app-domain/OperEntity/Storage.js +1 -1
  179. package/es/oak-app-domain/Order/Action.d.ts +1 -1
  180. package/es/oak-app-domain/Order/Action.js +1 -1
  181. package/es/oak-app-domain/Order/Schema.d.ts +61 -4
  182. package/es/oak-app-domain/Order/Storage.js +27 -0
  183. package/es/oak-app-domain/Order/locales/zh_CN.json +1 -1
  184. package/es/oak-app-domain/Pay/Action.js +1 -1
  185. package/es/oak-app-domain/Pay/Storage.js +11 -1
  186. package/es/oak-app-domain/Refund/Action.d.ts +3 -3
  187. package/es/oak-app-domain/Refund/Action.js +3 -4
  188. package/es/oak-app-domain/Refund/Schema.d.ts +57 -56
  189. package/es/oak-app-domain/Refund/Storage.js +5 -16
  190. package/es/oak-app-domain/Refund/Style.js +3 -4
  191. package/es/oak-app-domain/Refund/locales/zh_CN.json +1 -1
  192. package/es/oak-app-domain/Storage.js +2 -0
  193. package/es/oak-app-domain/StyleDict.js +6 -0
  194. package/es/oak-app-domain/SysAccountOper/Schema.d.ts +33 -33
  195. package/es/oak-app-domain/SysAccountOper/Storage.js +3 -3
  196. package/es/oak-app-domain/SysAccountOper/Style.js +3 -1
  197. package/es/oak-app-domain/SysAccountOper/locales/zh_CN.json +1 -1
  198. package/es/oak-app-domain/System/Schema.d.ts +12 -0
  199. package/es/oak-app-domain/System/Storage.js +2 -1
  200. package/es/oak-app-domain/User/Schema.d.ts +23 -0
  201. package/es/oak-app-domain/Withdraw/Schema.d.ts +24 -63
  202. package/es/oak-app-domain/Withdraw/Storage.js +0 -4
  203. package/es/oak-app-domain/Withdraw/locales/zh_CN.json +1 -1
  204. package/es/oak-app-domain/WithdrawAccount/Action.d.ts +5 -0
  205. package/es/oak-app-domain/WithdrawAccount/Action.js +2 -0
  206. package/es/oak-app-domain/WithdrawAccount/Schema.d.ts +22 -15
  207. package/es/oak-app-domain/WithdrawAccount/Storage.js +5 -2
  208. package/es/oak-app-domain/WithdrawAccount/Style.d.ts +3 -0
  209. package/es/oak-app-domain/WithdrawAccount/Style.js +6 -0
  210. package/es/oak-app-domain/WithdrawAccount/locales/zh_CN.json +1 -1
  211. package/es/oak-app-domain/WithdrawChannel/Action.d.ts +5 -0
  212. package/es/oak-app-domain/WithdrawChannel/Action.js +2 -0
  213. package/es/oak-app-domain/WithdrawChannel/Schema.d.ts +94 -20
  214. package/es/oak-app-domain/WithdrawChannel/Storage.js +12 -8
  215. package/es/oak-app-domain/WithdrawChannel/Style.d.ts +3 -0
  216. package/es/oak-app-domain/WithdrawChannel/Style.js +6 -0
  217. package/es/oak-app-domain/WithdrawChannel/locales/zh_CN.json +1 -1
  218. package/es/oak-app-domain/WithdrawTransfer/Action.d.ts +11 -0
  219. package/es/oak-app-domain/WithdrawTransfer/Action.js +11 -0
  220. package/es/oak-app-domain/WithdrawTransfer/Schema.d.ts +312 -0
  221. package/es/oak-app-domain/WithdrawTransfer/Schema.js +1 -0
  222. package/es/oak-app-domain/WithdrawTransfer/Storage.d.ts +3 -0
  223. package/es/oak-app-domain/WithdrawTransfer/Storage.js +51 -0
  224. package/es/oak-app-domain/WithdrawTransfer/Style.d.ts +3 -0
  225. package/es/oak-app-domain/WithdrawTransfer/Style.js +13 -0
  226. package/es/oak-app-domain/WithdrawTransfer/locales/zh_CN.json +1 -0
  227. package/es/oak-app-domain/WpAccount/Schema.d.ts +25 -1
  228. package/es/oak-app-domain/WpAccount/Storage.js +11 -0
  229. package/es/oak-app-domain/WpAccount/locales/zh_CN.json +1 -1
  230. package/es/oak-app-domain/_SubQuery.d.ts +32 -6
  231. package/es/triggers/abstract.d.ts +5 -0
  232. package/es/triggers/abstract.js +74 -0
  233. package/es/triggers/accountOper.js +10 -0
  234. package/es/triggers/index.js +6 -0
  235. package/es/triggers/pay.d.ts +0 -6
  236. package/es/triggers/pay.js +78 -111
  237. package/es/triggers/refund.d.ts +0 -6
  238. package/es/triggers/refund.js +290 -205
  239. package/es/triggers/withdraw.d.ts +6 -0
  240. package/es/triggers/withdraw.js +110 -43
  241. package/es/triggers/withdrawAccount.d.ts +5 -0
  242. package/es/triggers/withdrawAccount.js +2 -0
  243. package/es/triggers/withdrawTransfer.d.ts +5 -0
  244. package/es/triggers/withdrawTransfer.js +106 -0
  245. package/es/types/PayClazz.d.ts +5 -0
  246. package/es/utils/application.d.ts +1 -1
  247. package/es/utils/pay.d.ts +0 -1
  248. package/es/utils/pay.js +1 -137
  249. package/es/utils/payClazz/Account.d.ts +13 -9
  250. package/es/utils/payClazz/Account.js +15 -0
  251. package/es/utils/payClazz/Offline.d.ts +13 -8
  252. package/es/utils/payClazz/Offline.js +36 -0
  253. package/es/utils/payClazz/WechatPay/WechatPay.d.ts +2 -2
  254. package/es/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -3
  255. package/es/utils/payClazz/WechatPay/WechatPay.debug.js +46 -5
  256. package/es/utils/payClazz/WechatPay/WechatPay.js +7 -5
  257. package/es/utils/payClazz/WechatPay/index.d.ts +1 -1
  258. package/es/utils/payClazz/index.d.ts +9 -3
  259. package/es/utils/payClazz/index.js +99 -63
  260. package/es/watchers/pay.js +1 -1
  261. package/es/watchers/refund.js +4 -7
  262. package/lib/aspects/AspectDict.d.ts +4 -2
  263. package/lib/aspects/index.js +2 -2
  264. package/lib/aspects/withdraw.d.ts +62 -0
  265. package/lib/aspects/withdraw.js +214 -0
  266. package/lib/checkers/abstractChecker.d.ts +7 -0
  267. package/lib/checkers/abstractChecker.js +31 -0
  268. package/lib/checkers/accountOper.js +8 -0
  269. package/lib/checkers/index.js +8 -0
  270. package/lib/checkers/offlineAccount.js +16 -0
  271. package/lib/checkers/order.js +43 -1
  272. package/lib/checkers/pay.js +23 -3
  273. package/lib/checkers/refund.js +61 -1
  274. package/lib/checkers/withdrawAccount.d.ts +5 -0
  275. package/lib/checkers/withdrawAccount.js +74 -0
  276. package/lib/checkers/withdrawTransfer.d.ts +5 -0
  277. package/lib/checkers/withdrawTransfer.js +34 -0
  278. package/lib/components/offlineAccount/config/index.js +15 -0
  279. package/lib/components/payConfig/system/web.pc.d.ts +1 -0
  280. package/lib/components/payConfig/system/web.pc.js +12 -12
  281. package/lib/components/wpAccount/config/index.d.ts +3 -2
  282. package/lib/components/wpAccount/config/index.js +19 -3
  283. package/lib/configuration/attrUpdateMatrix.js +51 -3
  284. package/lib/configuration/relation.js +2 -0
  285. package/lib/context/BackendRuntimeContext.d.ts +1 -1
  286. package/lib/data/actionAuth.js +36 -6
  287. package/lib/data/i18n.js +189 -21
  288. package/lib/data/path.js +41 -6
  289. package/lib/entities/AbstractAccount.d.ts +3 -1
  290. package/lib/entities/AbstractAccount.js +2 -0
  291. package/lib/entities/AccountOper.d.ts +1 -1
  292. package/lib/entities/AccountOper.js +7 -1
  293. package/lib/entities/OfflineAccount.d.ts +2 -0
  294. package/lib/entities/OfflineAccount.js +3 -0
  295. package/lib/entities/Order.d.ts +7 -2
  296. package/lib/entities/Order.js +22 -0
  297. package/lib/entities/Pay.js +12 -2
  298. package/lib/entities/Refund.d.ts +8 -6
  299. package/lib/entities/Refund.js +11 -15
  300. package/lib/entities/SysAccountOper.d.ts +3 -3
  301. package/lib/entities/SysAccountOper.js +7 -3
  302. package/lib/entities/Withdraw.d.ts +0 -4
  303. package/lib/entities/Withdraw.js +0 -2
  304. package/lib/entities/WithdrawAccount.d.ts +5 -2
  305. package/lib/entities/WithdrawAccount.js +12 -1
  306. package/lib/entities/WithdrawChannel.d.ts +7 -4
  307. package/lib/entities/WithdrawChannel.js +14 -3
  308. package/lib/entities/WithdrawTransfer.d.ts +27 -0
  309. package/lib/entities/WithdrawTransfer.js +55 -0
  310. package/lib/entities/WpAccount.d.ts +2 -0
  311. package/lib/entities/WpAccount.js +3 -0
  312. package/lib/locales/error/zh-CN.json +9 -0
  313. package/lib/locales/offlineAccount/zh-CN.json +4 -2
  314. package/lib/locales/withdraw/zh-CN.json +35 -0
  315. package/lib/oak-app-domain/AbstractAccount/Schema.d.ts +14 -2
  316. package/lib/oak-app-domain/AbstractAccount/Storage.js +11 -0
  317. package/lib/oak-app-domain/AbstractAccount/locales/zh_CN.json +1 -1
  318. package/lib/oak-app-domain/AccountOper/Schema.d.ts +93 -6
  319. package/lib/oak-app-domain/AccountOper/Storage.js +2 -2
  320. package/lib/oak-app-domain/AccountOper/Style.js +3 -0
  321. package/lib/oak-app-domain/AccountOper/locales/zh_CN.json +1 -1
  322. package/lib/oak-app-domain/ActionDefDict.d.ts +5 -0
  323. package/lib/oak-app-domain/ActionDefDict.js +8 -2
  324. package/lib/oak-app-domain/EntityDict.d.ts +2 -0
  325. package/lib/oak-app-domain/ModiEntity/Schema.d.ts +34 -5
  326. package/lib/oak-app-domain/ModiEntity/Storage.js +1 -1
  327. package/lib/oak-app-domain/OfflineAccount/Schema.d.ts +25 -1
  328. package/lib/oak-app-domain/OfflineAccount/Storage.js +11 -0
  329. package/lib/oak-app-domain/OfflineAccount/locales/zh_CN.json +1 -1
  330. package/lib/oak-app-domain/OperEntity/Schema.d.ts +34 -5
  331. package/lib/oak-app-domain/OperEntity/Storage.js +1 -1
  332. package/lib/oak-app-domain/Order/Action.d.ts +1 -1
  333. package/lib/oak-app-domain/Order/Action.js +1 -1
  334. package/lib/oak-app-domain/Order/Schema.d.ts +61 -4
  335. package/lib/oak-app-domain/Order/Storage.js +27 -0
  336. package/lib/oak-app-domain/Order/locales/zh_CN.json +1 -1
  337. package/lib/oak-app-domain/Pay/Action.js +1 -1
  338. package/lib/oak-app-domain/Pay/Storage.js +11 -1
  339. package/lib/oak-app-domain/Refund/Action.d.ts +3 -3
  340. package/lib/oak-app-domain/Refund/Action.js +4 -5
  341. package/lib/oak-app-domain/Refund/Schema.d.ts +57 -56
  342. package/lib/oak-app-domain/Refund/Storage.js +5 -16
  343. package/lib/oak-app-domain/Refund/Style.js +3 -4
  344. package/lib/oak-app-domain/Refund/locales/zh_CN.json +1 -1
  345. package/lib/oak-app-domain/Storage.js +6 -4
  346. package/lib/oak-app-domain/StyleDict.js +10 -4
  347. package/lib/oak-app-domain/SysAccountOper/Schema.d.ts +33 -33
  348. package/lib/oak-app-domain/SysAccountOper/Storage.js +3 -3
  349. package/lib/oak-app-domain/SysAccountOper/Style.js +3 -1
  350. package/lib/oak-app-domain/SysAccountOper/locales/zh_CN.json +1 -1
  351. package/lib/oak-app-domain/System/Schema.d.ts +12 -0
  352. package/lib/oak-app-domain/System/Storage.js +2 -1
  353. package/lib/oak-app-domain/User/Schema.d.ts +23 -0
  354. package/lib/oak-app-domain/Withdraw/Schema.d.ts +24 -63
  355. package/lib/oak-app-domain/Withdraw/Storage.js +0 -4
  356. package/lib/oak-app-domain/Withdraw/locales/zh_CN.json +1 -1
  357. package/lib/oak-app-domain/WithdrawAccount/Action.d.ts +5 -0
  358. package/lib/oak-app-domain/WithdrawAccount/Action.js +5 -0
  359. package/lib/oak-app-domain/WithdrawAccount/Schema.d.ts +22 -15
  360. package/lib/oak-app-domain/WithdrawAccount/Storage.js +6 -3
  361. package/lib/oak-app-domain/WithdrawAccount/Style.d.ts +3 -0
  362. package/lib/oak-app-domain/WithdrawAccount/Style.js +9 -0
  363. package/lib/oak-app-domain/WithdrawAccount/locales/zh_CN.json +1 -1
  364. package/lib/oak-app-domain/WithdrawChannel/Action.d.ts +5 -0
  365. package/lib/oak-app-domain/WithdrawChannel/Action.js +5 -0
  366. package/lib/oak-app-domain/WithdrawChannel/Schema.d.ts +94 -20
  367. package/lib/oak-app-domain/WithdrawChannel/Storage.js +13 -9
  368. package/lib/oak-app-domain/WithdrawChannel/Style.d.ts +3 -0
  369. package/lib/oak-app-domain/WithdrawChannel/Style.js +9 -0
  370. package/lib/oak-app-domain/WithdrawChannel/locales/zh_CN.json +1 -1
  371. package/lib/oak-app-domain/WithdrawTransfer/Action.d.ts +11 -0
  372. package/lib/oak-app-domain/WithdrawTransfer/Action.js +14 -0
  373. package/lib/oak-app-domain/WithdrawTransfer/Schema.d.ts +312 -0
  374. package/lib/oak-app-domain/WithdrawTransfer/Schema.js +2 -0
  375. package/lib/oak-app-domain/WithdrawTransfer/Storage.d.ts +3 -0
  376. package/lib/oak-app-domain/WithdrawTransfer/Storage.js +54 -0
  377. package/lib/oak-app-domain/WithdrawTransfer/Style.d.ts +3 -0
  378. package/lib/oak-app-domain/WithdrawTransfer/Style.js +16 -0
  379. package/lib/oak-app-domain/WithdrawTransfer/locales/zh_CN.json +1 -0
  380. package/lib/oak-app-domain/WpAccount/Schema.d.ts +25 -1
  381. package/lib/oak-app-domain/WpAccount/Storage.js +11 -0
  382. package/lib/oak-app-domain/WpAccount/locales/zh_CN.json +1 -1
  383. package/lib/oak-app-domain/_SubQuery.d.ts +32 -6
  384. package/lib/triggers/abstract.d.ts +5 -0
  385. package/lib/triggers/abstract.js +77 -0
  386. package/lib/triggers/accountOper.js +10 -0
  387. package/lib/triggers/index.js +6 -0
  388. package/lib/triggers/pay.d.ts +0 -6
  389. package/lib/triggers/pay.js +78 -113
  390. package/lib/triggers/refund.d.ts +0 -6
  391. package/lib/triggers/refund.js +289 -206
  392. package/lib/triggers/withdraw.d.ts +6 -0
  393. package/lib/triggers/withdraw.js +111 -42
  394. package/lib/triggers/withdrawAccount.d.ts +5 -0
  395. package/lib/triggers/withdrawAccount.js +4 -0
  396. package/lib/triggers/withdrawTransfer.d.ts +5 -0
  397. package/lib/triggers/withdrawTransfer.js +109 -0
  398. package/lib/types/PayClazz.d.ts +5 -0
  399. package/lib/utils/application.d.ts +1 -1
  400. package/lib/utils/pay.d.ts +0 -1
  401. package/lib/utils/pay.js +2 -139
  402. package/lib/utils/payClazz/Account.d.ts +13 -9
  403. package/lib/utils/payClazz/Account.js +15 -0
  404. package/lib/utils/payClazz/Offline.d.ts +13 -8
  405. package/lib/utils/payClazz/Offline.js +36 -0
  406. package/lib/utils/payClazz/WechatPay/WechatPay.d.ts +2 -2
  407. package/lib/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -3
  408. package/lib/utils/payClazz/WechatPay/WechatPay.debug.js +47 -5
  409. package/lib/utils/payClazz/WechatPay/WechatPay.js +7 -5
  410. package/lib/utils/payClazz/WechatPay/index.d.ts +1 -1
  411. package/lib/utils/payClazz/index.d.ts +9 -3
  412. package/lib/utils/payClazz/index.js +102 -65
  413. package/lib/watchers/pay.js +1 -1
  414. package/lib/watchers/refund.js +4 -7
  415. package/package.json +4 -4
  416. package/src/entities/AbstractAccount.ts +5 -1
  417. package/src/entities/AccountOper.ts +9 -2
  418. package/src/entities/OfflineAccount.ts +5 -0
  419. package/src/entities/Order.ts +28 -3
  420. package/src/entities/Pay.ts +12 -2
  421. package/src/entities/Refund.ts +19 -22
  422. package/src/entities/SysAccountOper.ts +10 -6
  423. package/src/entities/Withdraw.ts +0 -4
  424. package/src/entities/WithdrawAccount.ts +17 -3
  425. package/src/entities/WithdrawChannel.ts +19 -6
  426. package/src/entities/WithdrawTransfer.ts +86 -0
  427. package/src/entities/WpAccount.ts +5 -0
  428. package/es/components/withdraw/dry/Detail.d.ts +0 -14
  429. package/es/components/withdraw/dry/Detail.js +0 -71
  430. package/es/components/withdraw/dry/Detail.mobile.d.ts +0 -21
  431. package/es/components/withdraw/dry/Detail.pc.d.ts +0 -21
  432. package/es/components/withdraw/dry/index.d.ts +0 -21
  433. package/es/components/withdraw/dry/index.js +0 -11
  434. package/es/components/withdrawChannel/list/index.js +0 -32
  435. package/es/components/withdrawChannel/list/locales/zh-CN.json +0 -3
  436. package/es/components/withdrawChannel/list/web.pc.d.ts +0 -8
  437. package/es/components/withdrawChannel/list/web.pc.js +0 -25
  438. package/es/components/withdrawChannel/upsert/index.d.ts +0 -3
  439. package/es/components/withdrawChannel/upsert/index.js +0 -14
  440. package/es/components/withdrawChannel/upsert/locales/zh-CN.json +0 -6
  441. package/es/components/withdrawChannel/upsert/web.pc.d.ts +0 -6
  442. package/es/components/withdrawChannel/upsert/web.pc.js +0 -25
  443. /package/es/components/{withdrawChannel → order}/list/index.json +0 -0
  444. /package/es/components/{withdrawChannel/upsert → refund/list}/index.json +0 -0
@@ -1,7 +1,9 @@
1
1
  import { BRC } from '../types/RuntimeCxt';
2
2
  import { EntityDict } from '../oak-app-domain';
3
3
  export type AspectDict = {
4
- getAccountPayRefunds: (params: {
4
+ getWithdrawCreateData: (params: {
5
5
  accountId: string;
6
- }, context: BRC) => Promise<EntityDict['refund']['CreateSingle']['data'][]>;
6
+ price: number;
7
+ withdrawAccountId?: string;
8
+ }, context: BRC) => Promise<EntityDict['withdraw']['CreateSingle']['data']>;
7
9
  };
@@ -1,5 +1,5 @@
1
- import { getAccountPayRefunds } from './account';
1
+ import { getWithdrawCreateData } from './withdraw';
2
2
  const aspectDict = {
3
- getAccountPayRefunds,
3
+ getWithdrawCreateData,
4
4
  };
5
5
  export default aspectDict;
@@ -0,0 +1,62 @@
1
+ import { BRC } from '../types/RuntimeCxt';
2
+ export declare function getWithdrawCreateData(params: {
3
+ accountId: string;
4
+ price: number;
5
+ withdrawAccountId?: string;
6
+ }, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
7
+ id: string;
8
+ } & {
9
+ accountId: string;
10
+ account?: import("../oak-app-domain/Account/Schema").UpdateOperation | undefined;
11
+ } & {
12
+ creatorId: string;
13
+ creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
14
+ } & {
15
+ refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
16
+ withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
17
+ modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
18
+ operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
19
+ accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
20
+ }) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
21
+ id: string;
22
+ } & {
23
+ accountId: string;
24
+ account?: import("../oak-app-domain/Account/Schema").UpdateOperation | undefined;
25
+ } & {
26
+ creator?: undefined;
27
+ creatorId: string;
28
+ } & {
29
+ refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
30
+ withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
31
+ modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
32
+ operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
33
+ accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
34
+ }) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
35
+ id: string;
36
+ } & {
37
+ account?: undefined;
38
+ accountId: string;
39
+ } & {
40
+ creatorId: string;
41
+ creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
42
+ } & {
43
+ refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
44
+ withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
45
+ modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
46
+ operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
47
+ accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
48
+ }) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
49
+ id: string;
50
+ } & {
51
+ account?: undefined;
52
+ accountId: string;
53
+ } & {
54
+ creator?: undefined;
55
+ creatorId: string;
56
+ } & {
57
+ refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
58
+ withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
59
+ modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
60
+ operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
61
+ accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
62
+ })>;
@@ -0,0 +1,209 @@
1
+ import { OakException, OakInputIllegalException } from 'oak-domain/lib/types';
2
+ import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
3
+ import assert from 'assert';
4
+ import { getPayClazz } from '../utils/payClazz';
5
+ function calcWithdrawLossByConfig(price, withdrawLossConfig) {
6
+ const { ratio, lowest, highest, trim } = withdrawLossConfig;
7
+ assert(ratio);
8
+ let value = Math.round(price * ratio / 100);
9
+ if (highest && value > highest) {
10
+ value = highest;
11
+ }
12
+ if (lowest && value < lowest) {
13
+ value = lowest;
14
+ }
15
+ switch (trim) {
16
+ case 'jiao': {
17
+ value = Math.ceil(value / 10) * 10;
18
+ break;
19
+ }
20
+ case 'yuan': {
21
+ value = Math.ceil(value / 100) * 100;
22
+ break;
23
+ }
24
+ }
25
+ return value;
26
+ }
27
+ export async function getWithdrawCreateData(params, context) {
28
+ const { system } = context.getApplication();
29
+ const withdrawLoss = system?.payConfig?.withdrawLoss;
30
+ if (!withdrawLoss || (!withdrawLoss.conservative && typeof withdrawLoss.ratio !== 'number')) {
31
+ throw new OakException('error::system.withdrawLossUnSet');
32
+ }
33
+ const { accountId, price: totalPrice, withdrawAccountId } = params;
34
+ const [account] = await context.select('account', {
35
+ data: {
36
+ id: 1,
37
+ avail: 1,
38
+ refundable: 1,
39
+ },
40
+ filter: {
41
+ id: accountId,
42
+ },
43
+ }, { dontCollect: true, forUpdate: true });
44
+ const { avail, refundable } = account;
45
+ if (totalPrice > avail) {
46
+ throw new OakInputIllegalException('withdraw', ['price'], 'error::withdraw.overflow');
47
+ }
48
+ if (totalPrice > refundable && !withdrawAccountId) {
49
+ throw new OakInputIllegalException('withdraw', ['price'], 'error::withdraw.needWithdrawAccountId');
50
+ }
51
+ const data = {
52
+ id: await generateNewIdAsync(),
53
+ accountId,
54
+ creatorId: context.getCurrentUserId(),
55
+ dealLoss: 0,
56
+ dealPrice: 0,
57
+ };
58
+ let preComputeLoss = !withdrawLoss.conservative ? calcWithdrawLossByConfig(totalPrice, withdrawLoss) : 0;
59
+ let totalLoss = 0;
60
+ let price2 = 0; // 计算过程中累积已经退款的金额
61
+ data.price = totalPrice;
62
+ if (refundable) {
63
+ const refundData = [];
64
+ const pays = await context.select('pay', {
65
+ data: {
66
+ id: 1,
67
+ price: 1,
68
+ paid: 1,
69
+ refunded: 1,
70
+ entity: 1,
71
+ entityId: 1,
72
+ offlineAccount: {
73
+ id: 1,
74
+ type: 1,
75
+ channel: 1,
76
+ },
77
+ applicationId: 1,
78
+ },
79
+ filter: {
80
+ refundable: true,
81
+ deposit: {
82
+ accountId,
83
+ },
84
+ orderId: {
85
+ $exists: false,
86
+ },
87
+ },
88
+ sorter: [
89
+ {
90
+ $attr: {
91
+ forbidRefundAt: 1,
92
+ },
93
+ $direction: 'asc',
94
+ }
95
+ ],
96
+ }, { forUpdate: true });
97
+ for (const pay of pays) {
98
+ const { price, paid, refunded, refundable, entity, entityId, applicationId, offlineAccount } = pay;
99
+ assert(price === paid && refundable);
100
+ assert(!['account'].includes(entity));
101
+ const rest = paid - refunded;
102
+ assert(rest > 0);
103
+ let refundPrice = rest;
104
+ if (totalPrice && totalPrice - price2 < rest) {
105
+ refundPrice = totalPrice - price2;
106
+ }
107
+ price2 += refundPrice;
108
+ let loss = 0;
109
+ let lossExplanation = 'withdraw::refund.lossReason.preCompute';
110
+ // 如果是保守策略,则按照渠道配置的规则来计算这次提现的损失,并转嫁到整体的loss上
111
+ if (withdrawLoss.conservative) {
112
+ // tax + delta即是这次refund损失的税费,如果配置是conservative,就按这个价格退
113
+ const payClazz = await getPayClazz(entity, entityId, context);
114
+ const [delta] = payClazz.calcRefundTax(refundPrice);
115
+ const [tax] = payClazz.calcPayTax(refundPrice);
116
+ loss = tax + delta;
117
+ lossExplanation = loss ? 'withdraw::refund.lossReason.noBack' : 'withdraw::refund.lossReason.back';
118
+ }
119
+ else {
120
+ // 如果是预计算策略,这里就按比例折算,这样成功或者失败的时候易于计算
121
+ loss = Math.ceil(preComputeLoss * refundPrice / totalPrice);
122
+ }
123
+ totalLoss += loss;
124
+ refundData.push({
125
+ id: await generateNewIdAsync(),
126
+ price: refundPrice,
127
+ loss,
128
+ creatorId: context.getCurrentUserId(),
129
+ payId: pay.id,
130
+ iState: 'refunding',
131
+ meta: {
132
+ channel: entity === 'offlineAccount' ? `withdraw::channel.offlineAccount.${offlineAccount.type}` : `${entity}:name`,
133
+ lossExplanation,
134
+ }
135
+ });
136
+ if (price2 === totalPrice) {
137
+ break;
138
+ }
139
+ }
140
+ data.refund$withdraw = await Promise.all(refundData.map(async (ele) => ({
141
+ id: await generateNewIdAsync(),
142
+ action: 'create',
143
+ data: ele,
144
+ })));
145
+ }
146
+ else {
147
+ data.refund$withdraw = [];
148
+ }
149
+ if (totalPrice > price2) {
150
+ // 如果还有要退的部分,就从withdrawAccount来进行转账
151
+ const rest = totalPrice - price2;
152
+ assert(price2 === refundable); // 可退款的额度计算必须匹配
153
+ assert(withdrawAccountId);
154
+ const [withdrawAccount] = await context.select('withdrawAccount', {
155
+ data: {
156
+ id: 1,
157
+ entity: 1,
158
+ enabled: 1,
159
+ entityId: 1,
160
+ channel: {
161
+ id: 1,
162
+ entity: 1,
163
+ entityId: 1,
164
+ },
165
+ },
166
+ filter: {
167
+ id: withdrawAccountId,
168
+ }
169
+ }, { dontCollect: true });
170
+ const { enabled, entity, entityId, channel } = withdrawAccount;
171
+ assert(enabled);
172
+ let loss = 0;
173
+ let lossExplanation = 'withdraw::transfer.lossReason.preCompute';
174
+ // 如果是保守策略,则按照渠道配置的规则来计算这次提现的损失,并转嫁到整体的loss上
175
+ if (withdrawLoss.conservative) {
176
+ // 如果配置是conservative,就按计算所选渠道的费用损失值
177
+ const payClazz = await getPayClazz(channel.entity, channel.entityId, context);
178
+ loss = payClazz.calcTransferTax(rest)[0];
179
+ lossExplanation = loss ? 'withdraw::transfer.lossReason.fee' : 'withdraw::transfer.lossReason.noFee';
180
+ }
181
+ else {
182
+ // 如果是预计算策略,这里就按比例折算,这样成功或者失败的时候易于计算
183
+ loss = Math.ceil(preComputeLoss * rest / totalPrice);
184
+ }
185
+ totalLoss += loss;
186
+ data.withdrawTransfer$withdraw = [
187
+ {
188
+ id: await generateNewIdAsync(),
189
+ action: 'create',
190
+ data: {
191
+ id: await generateNewIdAsync(),
192
+ price: rest,
193
+ loss,
194
+ withdrawAccountId,
195
+ creatorId: context.getCurrentUserId(),
196
+ meta: {
197
+ lossExplanation,
198
+ }
199
+ }
200
+ }
201
+ ];
202
+ }
203
+ else {
204
+ // 保持结构完整,让上层可以和withdraw$detail同构渲染
205
+ data.withdrawTransfer$withdraw = [];
206
+ }
207
+ data.loss = totalLoss;
208
+ return data;
209
+ }
@@ -0,0 +1,7 @@
1
+ import { EntityDict } from '../oak-app-domain';
2
+ import { RuntimeCxt } from '../types/RuntimeCxt';
3
+ import { Checker } from 'oak-domain/lib/types/Auth';
4
+ export declare function registerAccountEntity<ED extends EntityDict>(entity: keyof ED): void;
5
+ export declare const accountEntities: string[];
6
+ declare const triggers: Checker<EntityDict, keyof EntityDict, RuntimeCxt>[];
7
+ export default triggers;
@@ -0,0 +1,27 @@
1
+ import { generateNewId } from 'oak-domain/lib/utils/uuid';
2
+ // 当注入一个新的account entity时,将withdrawChannel的删除与之相关联
3
+ export function registerAccountEntity(entity) {
4
+ accountEntities.push(entity);
5
+ }
6
+ export const accountEntities = ['offlineAccount'];
7
+ const triggers = [
8
+ ...accountEntities.filter(ele => !!ele).map((entity) => [
9
+ {
10
+ entity,
11
+ action: 'remove',
12
+ type: 'logical',
13
+ checker: (operation, context) => {
14
+ const { filter } = operation;
15
+ return context.operate('withdrawChannel', {
16
+ id: generateNewId(),
17
+ action: 'remove',
18
+ data: {},
19
+ filter: {
20
+ [entity]: filter,
21
+ }
22
+ }, { dontCollect: true });
23
+ }
24
+ },
25
+ ]).flat(),
26
+ ];
27
+ export default triggers;
@@ -51,12 +51,14 @@ const checkers = [
51
51
  }
52
52
  break;
53
53
  }
54
+ case 'refund':
54
55
  case 'withdraw': {
55
56
  if (totalPlus >= 0 || availPlus >= 0 || totalPlus !== availPlus) {
56
57
  throw new OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为withdraw时,其totalPlus和availPlus必须为不相等的负数');
57
58
  }
58
59
  break;
59
60
  }
61
+ case 'refundFailure':
60
62
  case 'withdrawBack': {
61
63
  if (totalPlus <= 0 || availPlus <= 0 || totalPlus !== availPlus) {
62
64
  throw new OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为withdraw时,其totalPlus和availPlus必须为不相等的正数');
@@ -87,6 +89,12 @@ const checkers = [
87
89
  }
88
90
  break;
89
91
  }
92
+ case 'taxRefund': {
93
+ if (totalPlus <= 0 || availPlus <= 0 || totalPlus !== availPlus) {
94
+ throw new OakInputIllegalException('accountOper', ['totalPlus', 'availPlus'], 'accountOper为taxRefund时,其totalPlus/availPlus必须为正且相等');
95
+ }
96
+ break;
97
+ }
90
98
  default: {
91
99
  assert(false);
92
100
  break;
@@ -4,12 +4,20 @@ import orderCheckers from './order';
4
4
  import applicationCheckers from './application';
5
5
  import offlineAccountCheckers from './offlineAccount';
6
6
  import wpProductCheckers from './wpProduct';
7
+ import abstractCheckers from './abstractChecker';
8
+ import withdrawAccounts from './withdrawAccount';
9
+ import refundCheckers from './refund';
10
+ import withdrawTransferCheckers from './withdrawTransfer';
7
11
  const checkers = [
12
+ ...refundCheckers,
13
+ ...withdrawAccounts,
14
+ ...abstractCheckers,
8
15
  ...aoCheckers,
9
16
  ...payCheckers,
10
17
  ...orderCheckers,
11
18
  ...applicationCheckers,
12
19
  ...offlineAccountCheckers,
13
20
  ...wpProductCheckers,
21
+ ...withdrawTransferCheckers,
14
22
  ];
15
23
  export default checkers;
@@ -27,6 +27,13 @@ function checkAttributes(data) {
27
27
  }
28
28
  }
29
29
  }
30
+ const { refundCompensateRatio, refundGapDays } = data;
31
+ if (typeof refundGapDays !== 'number' || refundGapDays < 0) {
32
+ throw new OakInputIllegalException('offlineAccount', ['refundGapDays'], 'offlineAccount::error.refundGapDaysNotNegative');
33
+ }
34
+ if (typeof refundCompensateRatio !== 'number' || refundCompensateRatio < 0 || refundCompensateRatio > 100) {
35
+ throw new OakInputIllegalException('offlineAccount', ['refundGapDays'], 'offlineAccount::error.refundCompensateIllegal');
36
+ }
30
37
  }
31
38
  const checkers = [
32
39
  {
@@ -51,6 +58,15 @@ const checkers = [
51
58
  channel: 1,
52
59
  name: 1,
53
60
  qrCode: 1,
61
+ allowDeposit: 1,
62
+ allowPay: 1,
63
+ systemId: 1,
64
+ enabled: 1,
65
+ refundCompensateRatio: 1,
66
+ taxLossRatio: 1,
67
+ refundGapDays: 1,
68
+ allowWithdrawTransfer: 1,
69
+ withdrawTransferLossRatio: 1,
54
70
  },
55
71
  filter
56
72
  }, { dontCollect: true }), (accounts) => {
@@ -1,3 +1,5 @@
1
+ import assert from 'assert';
2
+ import { pipeline } from 'oak-domain/lib/utils/executor';
1
3
  const checkers = [
2
4
  {
3
5
  type: 'logical',
@@ -10,7 +12,46 @@ const checkers = [
10
12
  }
11
13
  data.paid = 0;
12
14
  data.refunded = 0;
13
- return 1;
15
+ data.settled = false;
16
+ data.systemId = context.getApplication()?.systemId;
17
+ }
18
+ },
19
+ {
20
+ // 订单结算,将收入分帐到相关的Account中
21
+ type: 'logicalData',
22
+ entity: 'order',
23
+ action: 'settle',
24
+ checker: (operation, context) => {
25
+ const { data, filter } = operation;
26
+ assert(typeof filter.id === 'string');
27
+ data.settled = true;
28
+ return pipeline(() => context.select('order', {
29
+ data: {
30
+ id: 1,
31
+ price: 1,
32
+ paid: 1,
33
+ refunded: 1,
34
+ iState: 1,
35
+ },
36
+ filter: {
37
+ id: filter.id,
38
+ },
39
+ }, {}), (orders) => {
40
+ const [order] = orders;
41
+ const { price, paid, refunded, iState } = order;
42
+ assert(['paid', 'partiallyRefunded'].includes(iState));
43
+ const { accountOper$entity: opers } = data;
44
+ assert(opers instanceof Array);
45
+ let amount = 0;
46
+ opers.forEach(({ action, data }) => {
47
+ assert(action === 'create');
48
+ const { type, totalPlus, availPlus, refundablePlus } = data;
49
+ assert(type === 'earn');
50
+ assert(totalPlus === availPlus);
51
+ amount += totalPlus;
52
+ });
53
+ assert(amount === paid - refunded);
54
+ });
14
55
  }
15
56
  }
16
57
  ];
@@ -101,13 +101,33 @@ const checkers = [
101
101
  {
102
102
  entity: 'pay',
103
103
  action: 'succeedPaying',
104
- type: 'data',
105
- checker(data) {
104
+ type: 'logicalData',
105
+ checker(operation, context) {
106
+ const { data, filter } = operation;
106
107
  assert(!(data instanceof Array));
107
- const { successAt } = data;
108
+ const { successAt, externalId } = data;
108
109
  if (!successAt) {
109
110
  throw new OakAttrNotNullException('pay', ['successAt']);
110
111
  }
112
+ assert(typeof filter?.id === 'string');
113
+ // 必须有ExternalId,除非之间prepay的时候已经填过了
114
+ if (!externalId) {
115
+ return pipeline(() => context.select('pay', {
116
+ data: {
117
+ id: 1,
118
+ externalId: 1,
119
+ entity: 1,
120
+ },
121
+ filter: {
122
+ id: filter.id,
123
+ }
124
+ }, { dontCollect: true }), (pays) => {
125
+ const [pay] = pays;
126
+ if (pay.entity !== 'account' && !pay.externalId) {
127
+ throw new OakAttrNotNullException('pay', ['externalId']);
128
+ }
129
+ });
130
+ }
111
131
  }
112
132
  },
113
133
  {
@@ -1,3 +1,5 @@
1
+ import { OakAttrNotNullException } from 'oak-domain/lib/types';
2
+ import { pipeline } from 'oak-domain/lib/utils/executor';
1
3
  const checkers = [
2
4
  {
3
5
  // 退款所在的pay一定是可以退款状态,且其上不能有另一个正在退款的请求
@@ -13,6 +15,64 @@ const checkers = [
13
15
  },
14
16
  },
15
17
  action: 'create',
16
- }
18
+ },
19
+ {
20
+ entity: 'refund',
21
+ action: 'succeed',
22
+ type: 'logicalData',
23
+ checker(operation, context) {
24
+ const { data, filter } = operation;
25
+ const { externalId } = data;
26
+ // 必须有ExternalId,除非是account类型的支付
27
+ if (!externalId) {
28
+ return pipeline(() => context.select('refund', {
29
+ data: {
30
+ id: 1,
31
+ pay: {
32
+ id: 1,
33
+ entity: 1,
34
+ },
35
+ },
36
+ filter: {
37
+ id: filter.id,
38
+ }
39
+ }, { dontCollect: true }), (refunds) => {
40
+ const [refund] = refunds;
41
+ if (refund.pay.entity !== 'account') {
42
+ throw new OakAttrNotNullException('refund', ['externalId']);
43
+ }
44
+ });
45
+ }
46
+ }
47
+ },
48
+ {
49
+ entity: 'refund',
50
+ action: 'fail',
51
+ type: 'logicalData',
52
+ checker(operation, context) {
53
+ const { data, filter } = operation;
54
+ const { reason } = data;
55
+ // 必须有reason,除非是account类型的支付
56
+ if (!reason) {
57
+ return pipeline(() => context.select('refund', {
58
+ data: {
59
+ id: 1,
60
+ pay: {
61
+ id: 1,
62
+ entity: 1,
63
+ },
64
+ },
65
+ filter: {
66
+ id: filter.id,
67
+ }
68
+ }, { dontCollect: true }), (refunds) => {
69
+ const [refund] = refunds;
70
+ if (refund.pay.entity !== 'account') {
71
+ throw new OakAttrNotNullException('refund', ['reason']);
72
+ }
73
+ });
74
+ }
75
+ }
76
+ },
17
77
  ];
18
78
  export default checkers;
@@ -0,0 +1,5 @@
1
+ import { Checker } from 'oak-domain/lib/types/Auth';
2
+ import { EntityDict } from '../oak-app-domain';
3
+ import { RuntimeCxt } from '../types/RuntimeCxt';
4
+ declare const checkers: Checker<EntityDict, 'withdrawAccount', RuntimeCxt>[];
5
+ export default checkers;