OrderUtils.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // 权重大的在前面显示 基础是-1在最后
  2. import i18n from '../i18n';
  3. const merchantStatusMap = new Map([
  4. [
  5. 'NOT_RECEIVED',
  6. {
  7. name: i18n.t('dai-shang-jia-jie-dan'),
  8. sort: 0,
  9. type: 'merchant',
  10. nowImgType: 'merchant',
  11. },
  12. ],
  13. [
  14. 'RECEIVED',
  15. {
  16. name: i18n.t('shang-jia-yi-jie-dan'),
  17. sort: 0,
  18. type: 'merchant',
  19. nowImgType: 'merchant',
  20. },
  21. ],
  22. [
  23. 'REJECTED',
  24. {
  25. name: i18n.t('shang-jia-yi-tui-dan'),
  26. sort: 2,
  27. type: 'merchant',
  28. },
  29. ],
  30. [
  31. 'COMPLETED',
  32. {
  33. name: i18n.t('yi-wan-cheng'),
  34. sort: -1,
  35. type: 'merchant',
  36. },
  37. ],
  38. ]);
  39. const orderStatusMap = new Map([
  40. [
  41. 'UNPAID',
  42. {
  43. name: i18n.t('ding-dan-wei-zhi-fu'),
  44. sort: 1,
  45. type: 'order',
  46. },
  47. ],
  48. [
  49. 'PAID',
  50. {
  51. name: i18n.t('yong-hu-yi-zhi-fu'),
  52. sort: -1,
  53. type: 'order',
  54. },
  55. ],
  56. [
  57. 'RATED',
  58. {
  59. name: i18n.t('dai-ping-jia'),
  60. sort: 0,
  61. type: 'order',
  62. },
  63. ],
  64. [
  65. 'CANCELLED',
  66. {
  67. name: i18n.t('ding-dan-yi-qu-xiao'),
  68. sort: 2,
  69. type: 'order',
  70. },
  71. ],
  72. [
  73. 'REFUNDED_PENDING',
  74. {
  75. name: i18n.t('shen-qing-tui-kuan-zhong'),
  76. sort: 2,
  77. type: 'order',
  78. isRefund: true,
  79. },
  80. ],
  81. [
  82. 'REFUNDING',
  83. {
  84. name: i18n.t('tui-kuan-zhong'),
  85. sort: 2,
  86. type: 'order',
  87. isRefund: true,
  88. },
  89. ],
  90. [
  91. 'REFUNDED',
  92. {
  93. name: i18n.t('yi-tui-kuan'),
  94. sort: 2,
  95. type: 'order',
  96. isRefund: true,
  97. },
  98. ],
  99. [
  100. 'COMPLETED',
  101. {
  102. name: i18n.t('yi-wan-cheng'),
  103. sort: 2,
  104. type: 'order',
  105. },
  106. ],
  107. ]);
  108. const RiderStatusMap = new Map([
  109. [
  110. 'NOT_RECEIVED',
  111. {
  112. name: i18n.t('dai-qi-shou-jie-dan'),
  113. sort: -1,
  114. type: 'rider',
  115. },
  116. ],
  117. [
  118. 'RECEIVED',
  119. {
  120. name: i18n.t('qi-shou-yi-jie-dan'),
  121. sort: 1,
  122. type: 'rider',
  123. nowImgType: 'rider',
  124. },
  125. ],
  126. [
  127. 'TAKE_MEAL',
  128. {
  129. name: i18n.t('qi-shou-yi-qu-can'),
  130. sort: 1,
  131. type: 'rider',
  132. nowImgType: 'rider',
  133. },
  134. ],
  135. [
  136. 'MEAL_DELIVERY',
  137. {
  138. name: i18n.t('ding-dan-zheng-zai-pei-song-zhong'),
  139. sort: 1,
  140. type: 'rider',
  141. nowImgType: 'rider',
  142. },
  143. ],
  144. [
  145. 'CARRY_OUT',
  146. {
  147. name: i18n.t('ding-dan-yi-song-da'),
  148. sort: 1,
  149. type: 'rider',
  150. },
  151. ],
  152. ]);
  153. const payMap = new Map([
  154. [
  155. 'ALI_PAY',
  156. {
  157. name: i18n.t('zhi-fu-bao'),
  158. icon: 'alipay-square',
  159. iconColor: 'blue500',
  160. },
  161. ],
  162. [
  163. 'CASH_DELIVERY',
  164. {
  165. name: i18n.t('huo-dao-fu-kuan'),
  166. icon: 'wallet',
  167. iconColor: 'green500',
  168. },
  169. ],
  170. [
  171. 'CREDIT_CARD',
  172. {
  173. name: i18n.t('xin-yong-ka'),
  174. icon: 'creditcard',
  175. iconColor: 'red500',
  176. },
  177. ],
  178. ]);
  179. function getStatusInfo(orderInfo) {
  180. const statusList = [];
  181. if (orderInfo.status) {
  182. statusList.push(orderStatusMap.get(orderInfo.status));
  183. }
  184. if (orderInfo.merchantStatus) {
  185. statusList.push(merchantStatusMap.get(orderInfo.merchantStatus));
  186. }
  187. if (orderInfo.riderStatus) {
  188. statusList.push(RiderStatusMap.get(orderInfo.riderStatus));
  189. }
  190. console.log(statusList);
  191. if (statusList.length > 0) {
  192. return statusList.sort((a, b) => {
  193. return b.sort - a.sort;
  194. })[0];
  195. } else {
  196. return {
  197. name: i18n.t('ding-dan-xiang-qing'),
  198. };
  199. }
  200. }
  201. function getGoodsInfo(orderGoodsSpecs) {
  202. const info = {
  203. list: orderGoodsSpecs,
  204. };
  205. if (orderGoodsSpecs.length > 0) {
  206. info.num = orderGoodsSpecs.reduce((pre, cur) => {
  207. return pre + cur.num;
  208. }, 0);
  209. info.name = orderGoodsSpecs[0].goods.name;
  210. }
  211. return info;
  212. }
  213. const reasonMap = new Map([
  214. ['UNABLE_TO_DELIVER', { name: i18n.t('dang-qian-ding-dan-wu-fa-pei-song') }],
  215. [
  216. 'DELIVERY_TIME_IS_TOO_LONG',
  217. { name: i18n.t('pei-song-shi-jian-tai-chang') },
  218. ],
  219. ['ADDRESS_IS_INCORRECT', { name: i18n.t('di-zhi-tian-xie-cuo-wu') }],
  220. [
  221. 'MERCHANT_CANNOT_DELIVER',
  222. { name: i18n.t('shang-jia-wu-fa-song-da-lian-xi-wo-qu-xiao') },
  223. ],
  224. [
  225. 'MERCHANT_OUT_OF_STOCK',
  226. { name: i18n.t('shang-jia-que-huo-da-yang-lian-xi-wo-qu-xiao') },
  227. ],
  228. [
  229. 'FORGOT_TO_USE_THE_RED_ENVELOPE',
  230. { name: i18n.t('wang-ji-shi-yong-hong-bao') },
  231. ],
  232. ['FORGET_ABOUT_STAPLE_FOOD', { name: i18n.t('wang-dian-zhu-shi') }],
  233. [
  234. 'RIDER_CONTACT_ME_TO_CANCEL',
  235. { name: i18n.t('qi-shou-lian-xi-wo-qu-xiao') },
  236. ],
  237. ['MORE_POINTS', { name: i18n.t('dian-duo-le-dian-cuo-le-lou-dian-le') }],
  238. [
  239. 'RIDER_CANNOT_REACH_USER',
  240. { name: i18n.t('lin-shi-you-shi-bu-xiang-yao-le') },
  241. ],
  242. ['OTHER', { name: i18n.t('qi-ta-yuan-yin') }],
  243. ]);
  244. export {
  245. merchantStatusMap,
  246. orderStatusMap,
  247. RiderStatusMap,
  248. payMap,
  249. getStatusInfo,
  250. getGoodsInfo,
  251. reasonMap,
  252. };