uni-pay-orders.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. // 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
  2. const validator = {
  3. "user_id": {
  4. "rules": [
  5. {
  6. "format": "string"
  7. }
  8. ],
  9. "label": "用户ID"
  10. },
  11. "provider": {
  12. "rules": [
  13. {
  14. "format": "string"
  15. },
  16. {
  17. "range": [
  18. {
  19. "text": "微信支付",
  20. "value": "wxpay"
  21. },
  22. {
  23. "text": "支付宝",
  24. "value": "alipay"
  25. },
  26. {
  27. "text": "苹果应用内支付",
  28. "value": "appleiap"
  29. }
  30. ]
  31. }
  32. ],
  33. "label": "支付供应商"
  34. },
  35. "provider_pay_type": {
  36. "rules": [
  37. {
  38. "format": "string"
  39. }
  40. ],
  41. "label": "支付方式"
  42. },
  43. "uni_platform": {
  44. "rules": [
  45. {
  46. "format": "string"
  47. }
  48. ],
  49. "label": "应用平台"
  50. },
  51. "status": {
  52. "rules": [
  53. {
  54. "format": "int"
  55. },
  56. {
  57. "range": [
  58. {
  59. "text": "已关闭",
  60. "value": -1
  61. },
  62. {
  63. "text": "未支付",
  64. "value": 0
  65. },
  66. {
  67. "text": "已支付",
  68. "value": 1
  69. },
  70. {
  71. "text": "已部分退款",
  72. "value": 2
  73. },
  74. {
  75. "text": "已全额退款",
  76. "value": 3
  77. }
  78. ]
  79. }
  80. ],
  81. "defaultValue": 0,
  82. "label": "订单状态"
  83. },
  84. "type": {
  85. "rules": [
  86. {
  87. "format": "string"
  88. }
  89. ],
  90. "label": "订单类型"
  91. },
  92. "order_no": {
  93. "rules": [
  94. {
  95. "format": "string"
  96. },
  97. {
  98. "minLength": 20,
  99. "maxLength": 28
  100. }
  101. ],
  102. "label": "业务系统订单号"
  103. },
  104. "out_trade_no": {
  105. "rules": [
  106. {
  107. "format": "string"
  108. }
  109. ],
  110. "label": "支付插件订单号"
  111. },
  112. "transaction_id": {
  113. "rules": [
  114. {
  115. "format": "string"
  116. }
  117. ],
  118. "label": "交易单号"
  119. },
  120. "device_id": {
  121. "rules": [
  122. {
  123. "format": "string"
  124. }
  125. ],
  126. "label": "设备ID"
  127. },
  128. "client_ip": {
  129. "rules": [
  130. {
  131. "format": "string"
  132. }
  133. ],
  134. "label": "客户端IP"
  135. },
  136. "openid": {
  137. "rules": [
  138. {
  139. "format": "string"
  140. }
  141. ],
  142. "label": "openid"
  143. },
  144. "description": {
  145. "rules": [
  146. {
  147. "format": "string"
  148. }
  149. ],
  150. "label": "支付描述"
  151. },
  152. "err_msg ": {
  153. "rules": [
  154. {
  155. "format": "string"
  156. }
  157. ],
  158. "label": "支付失败原因"
  159. },
  160. "total_fee": {
  161. "rules": [
  162. {
  163. "format": "int"
  164. }
  165. ],
  166. "label": "订单总金额"
  167. },
  168. "refund_fee": {
  169. "rules": [
  170. {
  171. "format": "int"
  172. }
  173. ],
  174. "label": "订单总退款金额"
  175. },
  176. "refund_count": {
  177. "rules": [
  178. {
  179. "format": "int"
  180. }
  181. ],
  182. "label": "当前退款笔数"
  183. },
  184. "refund_list": {
  185. "rules": [
  186. {
  187. "format": "array"
  188. }
  189. ],
  190. "label": "退款详情"
  191. },
  192. "provider_appid": {
  193. "rules": [
  194. {
  195. "format": "string"
  196. }
  197. ],
  198. "label": "开放平台appid"
  199. },
  200. "appid": {
  201. "rules": [
  202. {
  203. "format": "string"
  204. }
  205. ],
  206. "label": "DCloud AppId"
  207. },
  208. "user_order_success": {
  209. "rules": [
  210. {
  211. "format": "bool"
  212. }
  213. ],
  214. "label": "回调状态"
  215. },
  216. "pay_date": {
  217. "rules": [
  218. {
  219. "format": "timestamp"
  220. }
  221. ],
  222. "label": "支付时间"
  223. },
  224. "notify_date": {
  225. "rules": [
  226. {
  227. "format": "timestamp"
  228. }
  229. ],
  230. "label": "异步通知时间"
  231. },
  232. "cancel_date": {
  233. "rules": [
  234. {
  235. "format": "timestamp"
  236. }
  237. ],
  238. "label": "取消时间"
  239. }
  240. }
  241. const enumConverter = {
  242. "provider_valuetotext": {
  243. "wxpay": "微信支付",
  244. "alipay": "支付宝",
  245. "appleiap": "苹果应用内支付"
  246. },
  247. "status_valuetotext": {
  248. "0": "未支付",
  249. "1": "已支付",
  250. "2": "已部分退款",
  251. "3": "已全额退款",
  252. "-1": "已关闭"
  253. }
  254. }
  255. function filterToWhere(filter, command) {
  256. let where = {}
  257. for (let field in filter) {
  258. let { type, value } = filter[field]
  259. switch (type) {
  260. case "search":
  261. if (typeof value === 'string' && value.length) {
  262. //where[field] = new RegExp(value)
  263. where[field] = value
  264. }
  265. // if (typeof value === 'string' && value.length) {
  266. // str += `(${field} == '${value}' || /${value}/.test(${field}))`
  267. // where[field] = new RegExp(value)
  268. // }
  269. break;
  270. case "select":
  271. if (value.length) {
  272. let selectValue = []
  273. for (let s of value) {
  274. selectValue.push(command.eq(s))
  275. }
  276. where[field] = command.or(selectValue)
  277. }
  278. break;
  279. case "range":
  280. if (value.length) {
  281. let gt = value[0]
  282. let lt = value[1]
  283. where[field] = command.and([command.gte(gt), command.lte(lt)])
  284. }
  285. break;
  286. case "date":
  287. if (value.length) {
  288. let [s, e] = value
  289. let startDate = new Date(s)
  290. let endDate = new Date(e)
  291. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  292. }
  293. break;
  294. case "timestamp":
  295. if (value.length) {
  296. let [startDate, endDate] = value
  297. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  298. }
  299. break;
  300. }
  301. }
  302. return where
  303. }
  304. export { validator, enumConverter, filterToWhere }