$userId]); } //分销商工程师 return $this ->where($where) ->order(['create_time' => 'desc']) ->paginate($listRows); } /** * @notes:订单详情 * @param int $orderId * @return BaseRecoveryOrder|array|null * @throws BaseException * @author: wanghousheng */ public function getDetails(int $orderId) { $where['order_id'] = $orderId; $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 $orderId * @param array $imageIds * @return bool * @author: wanghousheng */ public function edit(array $data, int $orderId, array $imageIds = []): bool { if ($this->where(['order_id' => $orderId])->save($data)) { if ($imageIds) { RecoveryImage::updates($orderId, $imageIds); } return true; } return false; } /** * @notes:取消 * @param int $orderId * @return bool * @throws BaseException * @author: wanghousheng */ public function cancel(int $orderId): bool { $where['order_id'] = $orderId; // 当前用户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(['order_id' => $orderId])->save(['order_status' => RecoveryStatusEnum::CANCEL]); return true; } return false; } }