Wenzhenorder.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. 'comefrom_text'
  27. ];
  28. public function getOrdertypeList()
  29. {
  30. return ['1' => __('Ordertype 1'), '2' => __('Ordertype 2')];
  31. }
  32. public function getStatusList()
  33. {
  34. 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')];
  35. }
  36. public function getRefundStatusList()
  37. {
  38. return ['0' => __('Refund_status 0'), '1' => __('Refund_status 1'), '2' => __('Refund_status 2'), '3' => __('Refund_status 3')];
  39. }
  40. public function getComefromList()
  41. {
  42. return ['1' => __('Comefrom 1'), '2' => __('Comefrom 2')];
  43. }
  44. public function getOrdertypeTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['ordertype']) ? $data['ordertype'] : '');
  47. $list = $this->getOrdertypeList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. public function getBookTimeTextAttr($value, $data)
  51. {
  52. $value = $value ? $value : (isset($data['book_time']) ? $data['book_time'] : '');
  53. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  54. }
  55. public function getStatusTextAttr($value, $data)
  56. {
  57. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  58. $list = $this->getStatusList();
  59. return isset($list[$value]) ? $list[$value] : '';
  60. }
  61. public function getCancelTimeTextAttr($value, $data)
  62. {
  63. $value = $value ? $value : (isset($data['cancel_time']) ? $data['cancel_time'] : '');
  64. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  65. }
  66. public function getPayTimeTextAttr($value, $data)
  67. {
  68. $value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
  69. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  70. }
  71. public function getAcceptTimeTextAttr($value, $data)
  72. {
  73. $value = $value ? $value : (isset($data['accept_time']) ? $data['accept_time'] : '');
  74. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  75. }
  76. public function getVideoTimeTextAttr($value, $data)
  77. {
  78. $value = $value ? $value : (isset($data['video_time']) ? $data['video_time'] : '');
  79. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  80. }
  81. public function getFinishTimeTextAttr($value, $data)
  82. {
  83. $value = $value ? $value : (isset($data['finish_time']) ? $data['finish_time'] : '');
  84. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  85. }
  86. public function getFeedbackTimeTextAttr($value, $data)
  87. {
  88. $value = $value ? $value : (isset($data['feedback_time']) ? $data['feedback_time'] : '');
  89. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  90. }
  91. public function getRefundStatusTextAttr($value, $data)
  92. {
  93. $value = $value ? $value : (isset($data['refund_status']) ? $data['refund_status'] : '');
  94. $list = $this->getRefundStatusList();
  95. return isset($list[$value]) ? $list[$value] : '';
  96. }
  97. protected function setBookTimeAttr($value)
  98. {
  99. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  100. }
  101. protected function setCancelTimeAttr($value)
  102. {
  103. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  104. }
  105. protected function setPayTimeAttr($value)
  106. {
  107. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  108. }
  109. protected function setAcceptTimeAttr($value)
  110. {
  111. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  112. }
  113. protected function setVideoTimeAttr($value)
  114. {
  115. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  116. }
  117. protected function setFinishTimeAttr($value)
  118. {
  119. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  120. }
  121. protected function setFeedbackTimeAttr($value)
  122. {
  123. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  124. }
  125. public function getComefromTextAttr($value, $data)
  126. {
  127. $value = $value ? $value : (isset($data['comefrom']) ? $data['comefrom'] : '');
  128. $list = $this->getComefromList();
  129. return isset($list[$value]) ? $list[$value] : '';
  130. }
  131. public function user()
  132. {
  133. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  134. }
  135. public function doctor()
  136. {
  137. return $this->belongsTo('Doctor', 'doctor_id', 'id', [], 'LEFT')->setEagerlyType(0);
  138. }
  139. }