Wenzhenorder.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Wenzhenorder extends Model
  5. {
  6. // 表名
  7. protected $table = 'wenzhen_order';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'ordertype_text',
  17. 'book_time_text',
  18. 'status_text',
  19. 'cancel_time_text',
  20. 'pay_time_text',
  21. 'accept_time_text',
  22. 'video_time_text',
  23. 'finish_time_text',
  24. 'feedback_time_text',
  25. 'refund_status_text'
  26. ];
  27. public function getOrdertypeList()
  28. {
  29. return ['1' => __('Ordertype 1'), '2' => __('Ordertype 2')];
  30. }
  31. public function getStatusList()
  32. {
  33. return ['0' => __('Status 0'), '3' => __('Status 3'), '10' => __('Status 10'), '13' => __('Status 13'), '16' => __('Status 16'), '18' => __('Status 18'), '20' => __('Status 20'), '22' => __('Status 22'), '25' => __('Status 25'), '30' => __('Status 30')];
  34. }
  35. public function getRefundStatusList()
  36. {
  37. return ['0' => __('Refund_status 0'), '1' => __('Refund_status 1'), '2' => __('Refund_status 2'), '3' => __('Refund_status 3')];
  38. }
  39. public function getOrdertypeTextAttr($value, $data)
  40. {
  41. $value = $value ? $value : (isset($data['ordertype']) ? $data['ordertype'] : '');
  42. $list = $this->getOrdertypeList();
  43. return isset($list[$value]) ? $list[$value] : '';
  44. }
  45. public function getBookTimeTextAttr($value, $data)
  46. {
  47. $value = $value ? $value : (isset($data['book_time']) ? $data['book_time'] : '');
  48. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  49. }
  50. public function getStatusTextAttr($value, $data)
  51. {
  52. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  53. $list = $this->getStatusList();
  54. return isset($list[$value]) ? $list[$value] : '';
  55. }
  56. public function getCancelTimeTextAttr($value, $data)
  57. {
  58. $value = $value ? $value : (isset($data['cancel_time']) ? $data['cancel_time'] : '');
  59. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  60. }
  61. public function getPayTimeTextAttr($value, $data)
  62. {
  63. $value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
  64. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  65. }
  66. public function getAcceptTimeTextAttr($value, $data)
  67. {
  68. $value = $value ? $value : (isset($data['accept_time']) ? $data['accept_time'] : '');
  69. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  70. }
  71. public function getVideoTimeTextAttr($value, $data)
  72. {
  73. $value = $value ? $value : (isset($data['video_time']) ? $data['video_time'] : '');
  74. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  75. }
  76. public function getFinishTimeTextAttr($value, $data)
  77. {
  78. $value = $value ? $value : (isset($data['finish_time']) ? $data['finish_time'] : '');
  79. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  80. }
  81. public function getFeedbackTimeTextAttr($value, $data)
  82. {
  83. $value = $value ? $value : (isset($data['feedback_time']) ? $data['feedback_time'] : '');
  84. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  85. }
  86. public function getRefundStatusTextAttr($value, $data)
  87. {
  88. $value = $value ? $value : (isset($data['refund_status']) ? $data['refund_status'] : '');
  89. $list = $this->getRefundStatusList();
  90. return isset($list[$value]) ? $list[$value] : '';
  91. }
  92. protected function setBookTimeAttr($value)
  93. {
  94. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  95. }
  96. protected function setCancelTimeAttr($value)
  97. {
  98. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  99. }
  100. protected function setPayTimeAttr($value)
  101. {
  102. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  103. }
  104. protected function setAcceptTimeAttr($value)
  105. {
  106. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  107. }
  108. protected function setVideoTimeAttr($value)
  109. {
  110. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  111. }
  112. protected function setFinishTimeAttr($value)
  113. {
  114. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  115. }
  116. protected function setFeedbackTimeAttr($value)
  117. {
  118. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  119. }
  120. public function user()
  121. {
  122. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  123. }
  124. public function doctor()
  125. {
  126. return $this->belongsTo('Doctor', 'doctor_id', 'id', [], 'LEFT')->setEagerlyType(0);
  127. }
  128. }