订单计算相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
3.8 KiB

3 years ago
  1. package ordercalc
  2. /**
  3. '0': 待支付 下单尚未支付 created
  4. '1':已支付 付款成功此状态可退款 payed
  5. '5'已验证 虚拟订单验证核销码 using
  6. '6'已完成 与供应商结算后订单结束配送订单配送完成 finished
  7. '7'已取消 订单取消 canceled
  8. '8'自动取消 到期未支付自动取消此状态可由管理员手动延期取消 autocanceled
  9. '9'申请退款 用户自助申请退订单此状态可退款
  10. '13'已退款 订单完成退款 refunded
  11. '15'自动完成 使用时间过期自动完成 finished
  12. cancel,received,payed,created,finished,using
  13. ## 发货
  14. is_delivery 是否发货 '1': 已发货
  15. delivery 发货时间
  16. ## 收货
  17. is_received 是否收货 '1': 已收货
  18. received 收货时间
  19. */
  20. var statusList map[string]string = map[string]string{
  21. "0": "created",
  22. "1": "payed",
  23. "5": "using",
  24. "6": "finished",
  25. "7": "canceled",
  26. "8": "autocanceled",
  27. "9": "askForRefund",
  28. "13": "refunded",
  29. "15": "autofinished",
  30. }
  31. var statusExtendList map[string]string = map[string]string{
  32. "6": "received", //已收货归入已完成,
  33. }
  34. /*串货订单,供应商系统订单状态*/
  35. var channelOrderStatusList map[string]string = map[string]string{
  36. "1": "nosend",
  37. "2": "created",
  38. "3": "payed",
  39. "4": "askForRefund",
  40. "5": "refunded",
  41. "6": "canceled",
  42. "7": "finished",
  43. "8": "payFailed", //支付失败
  44. "9": "breakoff", //断开
  45. "10": "fullRefund", //全额退款
  46. "14": "autocanceled",
  47. "15": "autofinished",
  48. "16": "delivered",
  49. }
  50. func GetOrderStatusKey(status string) (key string) {
  51. for k, val := range statusList {
  52. if val == status {
  53. key = k
  54. break
  55. }
  56. }
  57. if key == "" { //再找扩展的状态
  58. for k, val := range statusExtendList {
  59. if val == status {
  60. key = k
  61. break
  62. }
  63. }
  64. }
  65. return
  66. }
  67. func GetOrderStatusText(key string) (text string) {
  68. for k, val := range statusList {
  69. if k == key {
  70. text = val
  71. break
  72. }
  73. }
  74. if text == "" { //再找扩展的状态
  75. for k, val := range statusExtendList {
  76. if k == key {
  77. text = val
  78. break
  79. }
  80. }
  81. }
  82. return
  83. }
  84. /**
  85. * 返回订单状态描述
  86. * 2021/01/28
  87. */
  88. func GetOrderStatusDescByFlag(flag string) (text string) {
  89. status := GetStatusText(flag)
  90. return GetStatusDesc(status)
  91. }
  92. /**
  93. * 返回订单状态描述
  94. * 2020/10/22
  95. */
  96. func GetOrderStatusDesc(key string) (text string) {
  97. var statusDesc map[string]string = map[string]string{
  98. "created": "已创建",
  99. "payed": "已支付",
  100. "askForRefund": "请求退款",
  101. "using": "使用中",
  102. "finished": "已完成",
  103. "canceled": "已取消",
  104. "autocanceled": "自动取消",
  105. "refunded": "已退款",
  106. "autofinished": "自动完成",
  107. "received": "已收货",
  108. }
  109. for k, val := range statusDesc {
  110. if k == key {
  111. text = val
  112. break
  113. }
  114. }
  115. return
  116. }
  117. func GetChannelOrderStatusKey(status string) (key string) {
  118. for k, val := range channelOrderStatusList {
  119. if val == status {
  120. key = k
  121. break
  122. }
  123. }
  124. return
  125. }
  126. func GetChannelOrderStatusText(key string) (text string) {
  127. for k, val := range channelOrderStatusList {
  128. if k == key {
  129. text = val
  130. break
  131. }
  132. }
  133. return
  134. }
  135. /**
  136. * 返回订单状态描述
  137. * 2020/10/22
  138. */
  139. func GetChannelOrderStatusDesc(key string) (text string) {
  140. var statusDesc map[string]string = map[string]string{
  141. "nosend": "未发送",
  142. "created": "已创建",
  143. "payed": "已支付",
  144. "askForRefund": "请求退款",
  145. "refunded": "已退款",
  146. "canceled": "已取消",
  147. "finished": "已完成",
  148. "payFailed": "支付失败",
  149. "breakoff": "断开",
  150. "fullRefund": "全额退款",
  151. "autocanceled": "自动取消",
  152. "autofinished": "自动取消",
  153. "delivered": "已发货",
  154. }
  155. for k, val := range statusDesc {
  156. if k == key {
  157. text = val
  158. break
  159. }
  160. }
  161. return
  162. }