Hyorder.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace addons\ddrive\model;
  3. use think\Model;
  4. class Hyorder extends Model
  5. {
  6. // 表名
  7. protected $name = 'ddrive_hy_order';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'status_text',
  17. 'comment_status_text',
  18. 'appointment_time_text',
  19. 'pay_type_text'
  20. ];
  21. public function getStatusList()
  22. {
  23. return ['-2' => __('Status -2'),'-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'),'5' => __('Status 5'), '99' => __('Status 99')];
  24. }
  25. public function getCommentStatusList()
  26. {
  27. return ['0' => __('Comment_status 0'), '1' => __('Comment_status 1')];
  28. }
  29. public function getTypeList()
  30. {
  31. return ['1' => __('Type 1'), '2' => __('Type 2')];
  32. }
  33. public function getDemand()
  34. {
  35. return ['1' => __('Demand 1'),'2' => __('Demand 2'), '3' => __('Demand 3'), '4' => __('Demand 4'), '5' => __('Demand 5'), '6' => __('Demand 6'), '7' => __('Demand 7')];
  36. }
  37. public function getStatusTextAttr($value, $data)
  38. {
  39. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  40. $list = $this->getStatusList();
  41. return isset($list[$value]) ? $list[$value] : '';
  42. }
  43. public function getCommentStatusTextAttr($value, $data)
  44. {
  45. $value = $value ? $value : (isset($data['comment_status']) ? $data['comment_status'] : '');
  46. $list = $this->getCommentStatusList();
  47. return isset($list[$value]) ? $list[$value] : '';
  48. }
  49. public function getTypeTextAttr($value, $data)
  50. {
  51. $value = $value ? $value : (isset($data['Type']) ? $data['Type'] : '');
  52. $list = $this->getTypeList();
  53. return isset($list[$value]) ? $list[$value] : '';
  54. }
  55. public function getAppointmentTimeTextAttr($value, $data)
  56. {
  57. $value = $value ? $value : (isset($data['appointment_time']) ? $data['appointment_time'] : '');
  58. return is_numeric($value) ? ($value ? date("m-d H:i", $value) : '') : $value;
  59. }
  60. public function getPayTypeTextAttr($value, $data)
  61. {
  62. $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
  63. $list = ['1' => '余额', '2' => '微信', '3' => '支付宝'];
  64. return isset($list[$value]) ? $list[$value] : '';
  65. }
  66. public function user()
  67. {
  68. return $this->belongsTo('\\app\\admin\\model\\User', 'user_id', 'id', [], 'LEFT')->field('avatar,mobile,group_id,id,username,nickname,email,prevtime,logintime,jointime')->setEagerlyType(0);
  69. }
  70. public function driver()
  71. {
  72. return $this->belongsTo('\\app\\admin\\model\\User', 'cargo_driver_id', 'id', [], 'LEFT')->field('avatar,mobile,group_id,id,username,nickname,email,prevtime,logintime,jointime')->setEagerlyType(0);
  73. }
  74. public function shaddress()
  75. {
  76. return $this->hasMany('Hyaddress', 'order_id', 'id');
  77. }
  78. }