'充电工单', self::TYPE_WATCH => '查看工单', self::TYPE_POWER_FAILURE => '断电工单', // self::TYPE_GPS_FAILURE => 'GPS故障工单', self::TYPE_ALERT => '警报工单', self::TYPE_STEAL => '偷盗工单', self::TYPE_HEADMAN => '组长工单', self::TYPE_TROUBLE => '故障工单', self::TYPE_HELP => '道路救援工单', self::TYPE_OTHER => '其他工单', self::TYPE_LOW_SPARE_BATTERY => '备用电池电量低报警', self::TYPE_OFFLINE => '离线工单', self::TYPE_BIKE_LOCATION_ERROR => '车辆定位出现问题', ]; public static $typeWarningMaps = [ self::TYPE_CHARGE => WarningLog::TYPE_BATTERY_LOW, self::TYPE_WATCH => 0, self::TYPE_POWER_FAILURE => WarningLog::TYPE_WARNING_CLOSE_ELECTRIC, // self::TYPE_GPS_FAILURE => 'GPS故障工单', self::TYPE_ALERT => WarningLog::TYPE_WARNING_BIKE_SHOCK, self::TYPE_STEAL => WarningLog::TYPE_WARNING_BIKE_OPEN, self::TYPE_HEADMAN => 0, self::TYPE_TROUBLE => WarningLog::TYPE_WARNING_BIKE_TROUBLE, self::TYPE_HELP => 0, self::TYPE_OTHER => 0, self::TYPE_LOW_SPARE_BATTERY => WarningLog::TYPE_WARNING_BATTERY_LOW, self::TYPE_OFFLINE => WarningLog::TYPE_BIKE_OFF_LINE, self::TYPE_BIKE_LOCATION_ERROR => WarningLog::TYPE_BIKE_LOCATION_ERROR, ]; const PLANNED_STATUS_MEET = 1; const PLANNED_STATUS_WORK = 2; const PLANNED_STATUS_WORKED = 3; const PLANNED_STATUS_OVER = 4; public static $plannedMaps = [ self::PLANNED_STATUS_MEET => '待接单', self::PLANNED_STATUS_WORK => '处理中', self::PLANNED_STATUS_WORKED => '已处理', self::PLANNED_STATUS_OVER => '已完成', ]; const STATUS_OK = 1; const STATUS_NO = 0; public static $statusMaps = [ self::STATUS_NO => '未确认', self::STATUS_OK => '已确认' ]; const SOURCE_SYSTEM = 1; const SOURCE_ADMIN = 2; const SOURCE_REPAIR = 3; public static $sourceMaps = [ self::SOURCE_SYSTEM => '系统生成', self::SOURCE_ADMIN => '管理员创建', self::SOURCE_REPAIR=>'地勤报修' ]; public static $warningMaps = [ 'battery' => '电池锁故障', 'bluetooth' => '蓝牙设备故障', 'ecu' => 'ECU通信故障', 'yixianzhi' => '一线制通信故障', 'wheel_lock' => '后轮锁故障', 'bms' => 'BMS故障', 'voice' => '语音喇叭故障', 'default' => '保留', ]; public static function makeWorkNo(){ // 订单流水号前缀 $prefix = config('bike.no_tag') . self::NO_TAG . date('YmdHis'); for ($i = 0; $i < 10; $i++) { // 随机生成 6 位的数字 $no = $prefix . str_pad(random_int(0, 999999), 6, '0', STR_PAD_LEFT); // 判断是否已经存在 if (!static::query()->where('work_no', $no)->exists()) { return $no; } } Log::warning('find order no failed'); return false; } public function worker(){ // 实际接单人员 return $this->belongsTo(AdminUser::class,'worker_id','id'); } public function workerOver(){ // 实际维修人员 return $this->belongsTo(AdminUser::class,'work_over_id','id'); } public function bike(){ return $this->belongsTo(Bike::class,'bike_id','id'); } // public function user(){ // return $this->belongsTo(User::class,'user_id','id'); // } public function area(){ return $this->belongsTo(Area::class,'area_id','id'); } public function area_worker(){ // 故障区域 所有维修人员 return $this->hasMany(AdminUser::class,'area_id','area_id'); } }