Status.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace App\Models\Traits\Orders;
  3. /**
  4. * 订单状态
  5. *
  6. */
  7. trait Status
  8. {
  9. // 交易类型 与 支付方式
  10. private $statusList = ['0'=>[
  11. 'id' =>0,
  12. 'name' =>'创建订单',// 未付款
  13. 'state' =>'待付款',
  14. ],'1'=>[
  15. 'id' =>1,
  16. 'name' =>'创建订单',// 未付款,系统报单不走支付流程的状态
  17. 'state' =>'进行中',
  18. ],'2'=>[
  19. 'id' =>2,
  20. 'name' =>'已付款未发货',// 已付款未发货
  21. 'state' =>'待发货',
  22. ],'3'=>[
  23. 'id' =>3,
  24. 'name' =>'已发货未收货',// 已发货未收货
  25. 'state' =>'待收货',
  26. ],'4'=>[
  27. 'id' =>4,
  28. 'name' =>'已取消',// 已取消
  29. 'state' =>'已取消',
  30. ],'5'=>[
  31. 'id' =>5,
  32. 'name' =>'退款中',// 退款中
  33. 'state' =>'退款中',
  34. ],'6'=>[
  35. 'id' =>6,
  36. 'name' =>'已退款',// 已退款
  37. 'state' =>'已退款',
  38. ],'7'=>[
  39. 'id' =>7,
  40. 'name' =>'已关闭',// 已关闭
  41. 'state' =>'已关闭',
  42. ],'8'=>[
  43. 'id' =>8,
  44. 'name' =>'已完成',// 已收货
  45. 'state' =>'已完成',
  46. ],'9'=>[
  47. 'id' =>9,
  48. 'name' =>'回执审核',// 回执审核
  49. 'state' =>'回执审核',
  50. ]];
  51. /**
  52. * 交易类型列表
  53. *
  54. */
  55. public function getStatusList(){
  56. // 返回数据
  57. return $this->statusList;
  58. }
  59. /**
  60. * 获取交易类型
  61. *
  62. * @param int $status 交易状态
  63. * @param string $field 字段
  64. *
  65. */
  66. public function getState($status,$field=''){
  67. // 获取交易类型
  68. $status = isset($this->statusList[$status]) ? $this->statusList[$status] : [];
  69. // 如果存在需要的字段
  70. if( $field ) return isset($status[$field]) ? $status[$field] : null;
  71. // 返回结果
  72. return $status;
  73. }
  74. /**
  75. * 获取交易类型
  76. *
  77. * @param string getWeibanStatus 交易状态
  78. *
  79. */
  80. public function getWeibanStatus($weibanStatus){
  81. // 状态列表
  82. $list = ['待付款'=>0,'待发货'=>2,'待收货'=>3,'已完成'=>8,'已退款'=>6,'取消交易'=>4];
  83. // 返回结果
  84. return isset($list[$weibanStatus]) ? $list[$weibanStatus] : 0;
  85. }
  86. }