Status.php 3.4 KB

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