12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
-
- namespace app\model\store\appointment;
-
- use app\model\store\project\ProjectModel;
- use app\model\user\User;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
-
- class AppointmentModel extends BaseModel
- {
-
- use ModelTrait;
-
- protected $name = 'store_appointment';
- protected $pk = 'appointment_id';
-
- public function project()
- {
- return $this->hasOne(ProjectModel::class, 'project_id', 'project_id');
- }
-
- public function member()
- {
- return $this->hasOne(User::class, 'uid', 'member_id');
- }
-
- public function technician()
- {
- return $this->hasOne(TechnicianModel::class, 'technician_id', 'technician_id');
- }
-
- public function getStatusMeansAttr($value, $data)
- {
- $status_means = [
- 1 => '待确定',
- 4 => '待到店',
- 8 => '已完成',
- -1 => '已取消',
- ];
- return $status_means[$data['status']] ?? '';
- }
-
- public function getOperateTypeMeansAttr($value, $data)
- {
- $operate_type_means = [
- 0 => '用户',
- 1 => '员工',
- 2 => '管理员'
- ];
- return $operate_type_means[$data['operate_type']] ?? '';
- }
-
- public function getArrivalTimeFormatAttr($value, $data)
- {
- return $data['arrival_time'] > 0 ? date('Y-m-d H:i:s', $data['arrival_time']) : '-';
- }
-
- public function getCancelTimeFormatAttr($value, $data)
- {
- return $data['cancel_time'] > 0 ? date('Y-m-d H:i:s', $data['cancel_time']) : '-';
- }
-
- public function getCancelTimeSmallFormatAttr($value, $data)
- {
- return $data['cancel_time'] > 0 ? date('m月d日', $data['cancel_time']) : '-';
- }
-
- public function getAppointmentTimeFormatAttr($value, $data)
- {
- $weekarray = array('日', '一', '二', '三', '四', '五', '六');
- if (false === $day_unix = strtotime($data['day'] . ' 00:00:00')) return '-';
- return date('m月d日', $day_unix) . '(周' . $weekarray[date('w', $day_unix)] . ')';
- }
-
- }
|