OrderUtils.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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: -1,
  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: -1,
  77. type: 'order',
  78. },
  79. ],
  80. [
  81. 'REFUNDING',
  82. {
  83. name: i18n.t('tui-kuan-zhong'),
  84. sort: -1,
  85. type: 'order',
  86. },
  87. ],
  88. [
  89. 'REFUNDED',
  90. {
  91. name: i18n.t('yi-tui-kuan'),
  92. sort: -1,
  93. type: 'order',
  94. },
  95. ],
  96. [
  97. 'COMPLETED',
  98. {
  99. name: i18n.t('yi-wan-cheng'),
  100. sort: 2,
  101. type: 'order',
  102. },
  103. ],
  104. ]);
  105. const RiderStatusMap = new Map([
  106. [
  107. 'NOT_RECEIVED',
  108. {
  109. name: i18n.t('dai-qi-shou-jie-dan'),
  110. sort: -1,
  111. type: 'rider',
  112. },
  113. ],
  114. [
  115. 'RECEIVED',
  116. {
  117. name: i18n.t('qi-shou-yi-jie-dan'),
  118. sort: 1,
  119. type: 'rider',
  120. nowImgType: 'rider',
  121. },
  122. ],
  123. [
  124. 'TAKE_MEAL',
  125. {
  126. name: i18n.t('qi-shou-yi-qu-can'),
  127. sort: 1,
  128. type: 'rider',
  129. nowImgType: 'rider',
  130. },
  131. ],
  132. [
  133. 'MEAL_DELIVERY',
  134. {
  135. name: i18n.t('ding-dan-zheng-zai-pei-song-zhong'),
  136. sort: 1,
  137. type: 'rider',
  138. nowImgType: 'rider',
  139. },
  140. ],
  141. [
  142. 'CARRY_OUT',
  143. {
  144. name: i18n.t('ding-dan-yi-song-da'),
  145. sort: 1,
  146. type: 'rider',
  147. },
  148. ],
  149. ]);
  150. const payMap = new Map([
  151. [
  152. 'ALI_PAY',
  153. {
  154. name: i18n.t('zhi-fu-bao'),
  155. icon: 'alipay-square',
  156. iconColor: 'blue500',
  157. },
  158. ],
  159. [
  160. 'CASH_DELIVERY',
  161. {
  162. name: i18n.t('huo-dao-fu-kuan'),
  163. icon: 'wallet',
  164. iconColor: 'green500',
  165. },
  166. ],
  167. [
  168. 'CREDIT_CARD',
  169. {
  170. name: i18n.t('xin-yong-ka'),
  171. icon: 'creditcard',
  172. iconColor: 'red500',
  173. },
  174. ],
  175. ]);
  176. function getStatusInfo(orderInfo) {
  177. const statusList = [];
  178. if (orderInfo.status) {
  179. statusList.push(orderStatusMap.get(orderInfo.status));
  180. }
  181. if (orderInfo.merchantStatus) {
  182. statusList.push(merchantStatusMap.get(orderInfo.merchantStatus));
  183. }
  184. if (orderInfo.riderStatus) {
  185. statusList.push(RiderStatusMap.get(orderInfo.riderStatus));
  186. }
  187. if (statusList.length > 0) {
  188. return statusList.sort((a, b) => {
  189. return b.sort - a.sort;
  190. })[0];
  191. } else {
  192. return {
  193. name: i18n.t('ding-dan-xiang-qing'),
  194. };
  195. }
  196. }
  197. const reasonMap = new Map([
  198. ['UNABLE_TO_DELIVER', { name: i18n.t('dang-qian-ding-dan-wu-fa-pei-song') }],
  199. [
  200. 'DELIVERY_TIME_IS_TOO_LONG',
  201. { name: i18n.t('pei-song-shi-jian-tai-chang') },
  202. ],
  203. ['ADDRESS_IS_INCORRECT', { name: i18n.t('di-zhi-tian-xie-cuo-wu') }],
  204. [
  205. 'MERCHANT_CANNOT_DELIVER',
  206. { name: i18n.t('shang-jia-wu-fa-song-da-lian-xi-wo-qu-xiao') },
  207. ],
  208. [
  209. 'MERCHANT_OUT_OF_STOCK',
  210. { name: i18n.t('shang-jia-que-huo-da-yang-lian-xi-wo-qu-xiao') },
  211. ],
  212. [
  213. 'FORGOT_TO_USE_THE_RED_ENVELOPE',
  214. { name: i18n.t('wang-ji-shi-yong-hong-bao') },
  215. ],
  216. ['FORGET_ABOUT_STAPLE_FOOD', { name: i18n.t('wang-dian-zhu-shi') }],
  217. [
  218. 'RIDER_CONTACT_ME_TO_CANCEL',
  219. { name: i18n.t('qi-shou-lian-xi-wo-qu-xiao') },
  220. ],
  221. ['MORE_POINTS', { name: i18n.t('dian-duo-le-dian-cuo-le-lou-dian-le') }],
  222. [
  223. 'RIDER_CANNOT_REACH_USER',
  224. { name: i18n.t('lin-shi-you-shi-bu-xiang-yao-le') },
  225. ],
  226. ['OTHER', { name: i18n.t('qi-ta-yuan-yin') }],
  227. ]);
  228. export {
  229. merchantStatusMap,
  230. orderStatusMap,
  231. RiderStatusMap,
  232. payMap,
  233. getStatusInfo,
  234. reasonMap,
  235. };