'待审核',20=>'已拒绝',30=>'已通过',40=>'已缴费',50=>'已锁定']; return $status[$data['status']]; } return '待审核'; } public function user(): \think\model\relation\HasOne { return $this->hasOne('\app\common\model\Users', 'id', 'user_id') ->field('id,nickname,partnership'); } /** * @desc 摩的代理统计数据 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function stats() { $user = $this->where('status', '>', 20) ->select(); $agent_num = count($user); $total_num = 0; $total_amount = 0; if ($user) { $area_ids = []; foreach ($user as $item) { $area_ids[] = $item->area_id; } $TaxiOrder = new TaxiOrder(); $taxi_order = $TaxiOrder->whereIn('area_id', $area_ids)->whereNotIn('status', [1])->column('price', 'id'); $total_num += count($taxi_order); $total_amount += array_sum($taxi_order); } return [ 'agent_num' => $agent_num, 'total_num' => $total_num, 'total_amount' => $total_amount, ]; } public function authority($RoleId, $roleName) { $Role = new Role(); $Access = new Access(); $Permission = new Permission(); $PermissionRole = new PermissionRole(); // 获取角色信息 $role = $Role::get($RoleId); if ($role){ $admin = $PermissionRole::where('role_id', 2)->find(); $PermissionRole::create([ 'role_id' => $RoleId, 'permission_idx' => $admin['permission_idx'] ]); $access = $Access->where('v0', 'motor_agent_173') ->select(); foreach ($access as $item) { $item->v0 = $roleName; $item->hidden = ['id']; } $Access->allowField(true)->saveAll($access->toArray()); } } }