Status.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. ]];
  47. /**
  48. * 交易类型列表
  49. *
  50. */
  51. public function getStatusList(){
  52. // 返回数据
  53. return $this->statusList;
  54. }
  55. /**
  56. * 获取交易类型
  57. *
  58. * @param int $status 交易状态
  59. * @param string $field 字段
  60. *
  61. */
  62. public function getState($status,$field=''){
  63. // 获取交易类型
  64. $status = isset($this->statusList[$status]) ? $this->statusList[$status] : [];
  65. // 如果存在需要的字段
  66. if( $field ) return isset($status[$field]) ? $status[$field] : null;
  67. // 返回结果
  68. return $status;
  69. }
  70. /**
  71. * 获取交易类型
  72. *
  73. * @param string getWeibanStatus 交易状态
  74. *
  75. */
  76. public function getWeibanStatus($weibanStatus){
  77. // 状态列表
  78. $list = ['待付款'=>0,'待发货'=>2,'待收货'=>3,'已完成'=>8,'已退款'=>6,'取消交易'=>4];
  79. // 返回结果
  80. return isset($list[$weibanStatus]) ? $list[$weibanStatus] : 0;
  81. }
  82. }