Status.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace App\Models\Traits\Orders;
  3. /**
  4. * 订单状态
  5. *
  6. */
  7. trait Status
  8. {
  9. // 交易类型 与 支付方式
  10. private $statusList = ['1'=>[
  11. 'id' =>1,
  12. 'name' =>'创建订单',// 未支付
  13. 'state' =>'待支付',
  14. ],'2'=>[
  15. 'id' =>2,
  16. 'name' =>'已付款待上课',// 已付款待上课
  17. 'state' =>'待上课',
  18. ],'3'=>[
  19. 'id' =>3,
  20. 'name' =>'已上课未上完',// 已上课未上完
  21. 'state' =>'待上课',
  22. ],'4'=>[
  23. 'id' =>4,
  24. 'name' =>'已取消',// 已取消
  25. 'state' =>'已取消',
  26. ],'5'=>[
  27. 'id' =>5,
  28. 'name' =>'退款中',// 退款中
  29. 'state' =>'退款中',
  30. ],'6'=>[
  31. 'id' =>6,
  32. 'name' =>'已退款',// 已退款
  33. 'state' =>'已退款',
  34. ],'7'=>[
  35. 'id' =>7,
  36. 'name' =>'已关闭',// 已关闭
  37. 'state' =>'已关闭',
  38. ],'8'=>[
  39. 'id' =>8,
  40. 'name' =>'已完成',// 已收货
  41. 'state' =>'已完成',
  42. ],'9'=>[
  43. 'id' =>9,
  44. 'name' =>'回执审核',// 回执审核
  45. 'state' =>'回执审核',
  46. ],'10'=>[
  47. 'id' =>10,
  48. 'name' =>'拼团中',// 拼团中
  49. 'state' =>'拼团中',
  50. ],'11'=>[
  51. 'id' =>11,
  52. 'name' =>'拼团失败',// 拼团失败
  53. 'state' =>'拼团失败',
  54. ],'12'=>[
  55. 'id' =>11,
  56. 'name' =>'取消拼团',// 取消拼团
  57. 'state' =>'取消拼团',
  58. ]];
  59. /**
  60. * 交易类型列表
  61. *
  62. */
  63. public function getStatusList(){
  64. // 返回数据
  65. return $this->statusList;
  66. }
  67. /**
  68. * 获取交易类型
  69. *
  70. * @param int $status 交易状态
  71. * @param string $field 字段
  72. *
  73. */
  74. public function getState($status,$field=''){
  75. // 获取交易类型
  76. $status = isset($this->statusList[$status]) ? $this->statusList[$status] : [];
  77. // 如果存在需要的字段
  78. if( $field ) return isset($status[$field]) ? $status[$field] : null;
  79. // 返回结果
  80. return $status;
  81. }
  82. /**
  83. * 获取交易类型
  84. *
  85. * @param string $state 交易状态
  86. *
  87. */
  88. public function getStateToStatus($state){
  89. // 状态列表
  90. $list = $this->getStatusList();
  91. // 状态
  92. foreach ($list as $value) {
  93. if($value['state'] == $state ) return $value['id'];
  94. }
  95. // 返回结果
  96. return -1;
  97. }
  98. /**
  99. * 获取交易类型
  100. *
  101. * @param string $weizanStatus 交易状态
  102. *
  103. */
  104. public function getWeiZanStatus($weizanStatus){
  105. // 状态列表
  106. $list = ['待付款'=>0,'待发货'=>2,'待收货'=>3,'已完成'=>8,'已退款'=>6,'取消交易'=>4];
  107. // 返回结果
  108. return isset($list[$weizanStatus]) ? $list[$weizanStatus] : 0;
  109. }
  110. }