| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace api\services;
- use common\models\user\User;
- use common\models\user\UserReport;
- /**
- * 会员举报
- * @package api\services
- */
- class UserReportService extends BaseService
- {
- /**
- * 查询分页列表
- *
- * @param array $params
- * @return array
- */
- public function getPageList(array $params = [])
- {
- return UserReport::getPageList($this->mall_id, $this->getPage($params), $this->getLimit($params), function ($query) use ($params) {
- $query->with(['user' => function ($query) {
- $query->select(['id', 'nickname', 'mobile', 'avatar_url']);
- }]);
- if (!empty($params['user_id'])) {
- $query->andWhere(['user_id' => $params['user_id']]);
- }
-
- if (!empty($params['user_keyword'])) {
- $query->andWhere([
- 'user_id' => User::getUserIdsByKeyword($this->mall_id, $params['user_keyword'])
- ]);
- }
- });
- }
- /**
- * 添加举报内容
- *
- * @param integer $user_id
- * @param array $data 举报内容
- * @return boolean
- */
- public function addReport(int $user_id, array $data)
- {
- $model = UserReport::addReport(
- $user_id, $this->mall_id, $data['title'], $data['content']
- );
- return $model === true
- ? true
- : $this->error($model->getErrorMessage());
- }
- }
|