You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppointmentModel.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\model\store\appointment;
  3. use app\model\store\project\ProjectModel;
  4. use app\model\user\User;
  5. use crmeb\basic\BaseModel;
  6. use crmeb\traits\ModelTrait;
  7. class AppointmentModel extends BaseModel
  8. {
  9. use ModelTrait;
  10. protected $name = 'store_appointment';
  11. protected $pk = 'appointment_id';
  12. public function project()
  13. {
  14. return $this->hasOne(ProjectModel::class, 'project_id', 'project_id');
  15. }
  16. public function member()
  17. {
  18. return $this->hasOne(User::class, 'uid', 'member_id');
  19. }
  20. public function technician()
  21. {
  22. return $this->hasOne(TechnicianModel::class, 'technician_id', 'technician_id');
  23. }
  24. public function getStatusMeansAttr($value, $data)
  25. {
  26. $status_means = [
  27. 1 => '待确定',
  28. 4 => '待到店',
  29. 8 => '已完成',
  30. -1 => '已取消',
  31. ];
  32. return $status_means[$data['status']] ?? '';
  33. }
  34. public function getOperateTypeMeansAttr($value, $data)
  35. {
  36. $operate_type_means = [
  37. 0 => '用户',
  38. 1 => '员工',
  39. 2 => '管理员'
  40. ];
  41. return $operate_type_means[$data['operate_type']] ?? '';
  42. }
  43. public function getArrivalTimeFormatAttr($value, $data)
  44. {
  45. return $data['arrival_time'] > 0 ? date('Y-m-d H:i:s', $data['arrival_time']) : '-';
  46. }
  47. public function getCancelTimeFormatAttr($value, $data)
  48. {
  49. return $data['cancel_time'] > 0 ? date('Y-m-d H:i:s', $data['cancel_time']) : '-';
  50. }
  51. public function getCancelTimeSmallFormatAttr($value, $data)
  52. {
  53. return $data['cancel_time'] > 0 ? date('m月d日', $data['cancel_time']) : '-';
  54. }
  55. public function getAppointmentTimeFormatAttr($value, $data)
  56. {
  57. $weekarray = array('日', '一', '二', '三', '四', '五', '六');
  58. if (false === $day_unix = strtotime($data['day'] . ' 00:00:00')) return '-';
  59. return date('m月d日', $day_unix) . '(周' . $weekarray[date('w', $day_unix)] . ')';
  60. }
  61. }