ReserveOrderCommentController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace addons\Store\client\controllers;
  3. use addons\ReservationService\common\models\ReservationServiceUser;
  4. use addons\Store\common\services\ReserveCommentService;
  5. use common\enums\StatusEnum;
  6. class ReserveOrderCommentController extends BaseController
  7. {
  8. /**
  9. * 评价列表
  10. * @return mixed|null
  11. */
  12. public function actionIndex()
  13. {
  14. if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
  15. $data = \Yii::$app->request->get();
  16. $rules = [
  17. [['tech_id', 'page', 'limit', 'id'], 'integer'],
  18. ];
  19. $res = \Yii::$app->services->validate->validate($data, $rules);
  20. if (!$res) return $this->error(\Yii::$app->services->validate->getErrorMessage());
  21. $ret = (new ReserveCommentService(['store_id' => $this->store_id, 'mall_id' => $this->mall_id]))->page($data);
  22. $reservation_service_user = ReservationServiceUser::find()->where(['mall_id' => $this->mall_id, 'user_id' => $data['id'], 'status' => StatusEnum::ENABLED])->one();
  23. $ret['service_rating'] = $reservation_service_user['store_service_rating'] ?? 0;
  24. return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
  25. }
  26. return $this->render('index');
  27. }
  28. }