$userId]); } //分销商工程师 return $this->where($where) ->where($where) ->order(['create_time' => 'desc']) ->paginate($listRows); } /** * @notes:订单详情 * @param int $recoveryId * @return BaseRecoveryOrder|array|null * @throws BaseException * @author: wanghousheng */ public function getDetails(int $recoveryId) { $where['recovery_id'] = $recoveryId; $where['user_id'] = UserService::getCurrentLoginUserId(); return static::detail($where, ['images.file']); } /** * @notes:添加记录 * @param array $data * @param array $imageIds * @return bool * @throws BaseException * @author: wanghousheng */ public function add(array $data, array $imageIds = []): bool { $data['order_no'] = OrderService::createOrderNo(); $data['user_id'] = UserService::getCurrentLoginUserId(); $data['store_id'] = self::$storeId; $data['create_time'] = time(); $data['update_time'] = $data['create_time']; $insertId = $this->insertGetId($data); if ($insertId) { if ($imageIds) { RecoveryImage::increased($insertId, $imageIds); } return true; } return false; } /** * @notes:更新 * @param array $data * @param int $recoveryId * @param array $imageIds * @return bool * @author: wanghousheng */ public function edit(array $data, int $recoveryId, array $imageIds = []): bool { if ($this->where(['recovery_id' => $recoveryId])->save($data)) { if ($imageIds) { RecoveryImage::updates($recoveryId, $imageIds); } return true; } return false; } /** * @notes:取消 * @param int $recoveryId * @return bool * @throws BaseException * @author: wanghousheng */ public function cancel(int $recoveryId): bool { $where['recovery_id'] = $recoveryId; // 当前用户ID $userId = UserService::getCurrentLoginUserId(); if (!UserService::isStore()) { $where['user_id'] = $userId; } $info = static::detail($where); if (!$info->isEmpty() && $info['order_status'] == RecoveryStatusEnum::ACCEPTED) { $this->where(['recovery_id' => $recoveryId])->save(['order_status' => RecoveryStatusEnum::CANCEL]); return true; } return false; } }