AdminForm.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\client\models\v1\worker;
  8. use app\models\User;
  9. use app\modules\client\models\ApiModel;
  10. use Exception;
  11. use app\models\WorkerOrderExt;
  12. use app\models\OrderComment;
  13. use app\models\OrderDetail;
  14. use app\models\SaasUser;
  15. class AdminForm extends ApiModel
  16. {
  17. public $store_id;
  18. public $worker_id;
  19. public $user_id;
  20. public $name;
  21. public $score;
  22. public $begin;
  23. public $end;
  24. public $orderby;
  25. public function commentList()
  26. {
  27. $worker_id = $this->worker_id;
  28. $score = $this->score;
  29. $name = $this->name;
  30. $orderby = $this->orderby;
  31. $begin = $this->begin;
  32. $end = $this->end;
  33. $queryOrder = WorkerOrderExt::find()->where(['worker_id' => $worker_id])->select('order_id');
  34. $query = OrderComment::find()->alias('oc')->leftJoin([
  35. 'woe' => WorkerOrderExt::tableName()
  36. ], 'oc.order_id = woe.order_id')->leftJoin([
  37. 'od' => OrderDetail::tableName()
  38. ], 'oc.order_id = od.order_id')->leftJoin([
  39. 'u' => User::tableName()
  40. ], 'oc.user_id = u.id')->leftJoin([
  41. 'su' => SaasUser::tableName()
  42. ], 'su.mobile = u.binding')->where([
  43. 'oc.order_id' => $queryOrder,
  44. 'oc.is_hide' => 0,
  45. 'oc.is_delete' => OrderComment::IS_DELETE_FALSE,
  46. ])->groupBy('oc.id');
  47. if($name){
  48. $query->andWhere(['like', 'od.goods_name', $name]);
  49. }
  50. if($score > 0){
  51. if($score == 3){
  52. $query->andWhere(['>=', 'oc.score', $score]);
  53. }else{
  54. $query->andWhere(['oc.score' => $score]);
  55. }
  56. }
  57. if($begin){
  58. $query->andWhere(['>=', 'oc.created_at', $begin]);
  59. }
  60. if($end){
  61. $query->andWhere(['<=', 'oc.created_at', $end]);
  62. }
  63. $queryOrderBy = 'oc.id DESC';
  64. if($orderby == 1){
  65. $queryOrderBy = 'oc.id DESC';
  66. }else if($orderby == 2){
  67. $queryOrderBy = 'oc.id ASC';
  68. }
  69. $query->orderBy($queryOrderBy);
  70. $query->select('oc.*, od.goods_name, su.name su_name, su.avatar su_avatar');
  71. $data = pagination_make($query);
  72. foreach($data['list'] as &$item){
  73. $item['pic_list'] = json_decode($item['pic_list']);
  74. if (intval($item['is_virtual'])) {
  75. $item['su_name'] = $item['virtual_user'];
  76. $item['su_avatar'] = $item['virtual_avatar'];
  77. }
  78. }
  79. $res = [
  80. 'code' => 0,
  81. 'msg' => 'success',
  82. 'data' => $data,
  83. ];
  84. return $res;
  85. }
  86. }