| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace addons\OperationCenter\common\services;
- use addons\OperationCenter\common\models\ApplyList;
- use addons\OperationCenter\common\models\MallUser;
- use addons\OperationCenter\common\models\UserCenter;
- /**
- * CenterService
- * @package addons\OperationCenter\common\services
- */
- class CenterService extends BaseService
- {
- /**
- * 获取分页列表
- *
- * @param array $params
- * @return array
- */
- public function getPageList(array $params = [])
- {
- $name = $params['name'] ?? '';
- $mobile = $params['mobile'] ?? '';
- $user_id = $params['user_id'] ?? '';
- $user_keyword = $params['user_keyword'] ?? '';
- return UserCenter::getPageList(
- $this->getPage($params), $this->getLimit($params), function ($query)
- use ($name, $mobile, $user_id, $user_keyword)
- {
- $query->andWhere(['mall_id' => $this->mall_id]);
- // 会员ID
- if (!empty($user_id)) {
- $query->andWhere(['user_id' => $user_id]);
- }
- // 会员名称
- if (!empty($name)) {
- $query->andWhere(['user_id' => ApplyList::getUserIdByName(
- $this->mall_id, $name
- )]);
- }
- // 联系电话
- if (!empty($mobile)) {
- $query->andWhere(['user_id' => ApplyList::getUserIdByMobile(
- $this->mall_id, $mobile
- )]);
- }
- // 会员信息查询
- if (!empty($user_keyword)) {
- $query->andWhere(['user_id' => MallUser::getUserIdByUserKeyWord(
- $this->mall_id, $user_keyword
- )]);
- }
- $query->with([
- 'user' => function ($query) {
- $query->select(['id', 'nickname', 'username', 'mobile', 'avatar_url']);
- },
- 'level' => function ($query) {
- $query->select(['id', 'mall_id', 'name', 'level']);
- },
- 'applyInfo' => function ($query) {
- $query->select(['id', 'user_id', 'mobile', 'name', 'center_name', 'operation_address', 'idcard_front', 'idcard_reverse']);
- },
- ]);
- }
- );
- }
- /**
- * 删除会员
- *
- * @param integer $id
- * @return boolean
- */
- public function delUser(int $id)
- {
- $user = UserCenter::getCenterById($this->mall_id, $id);
- if (empty($user)) return $this->error('运营中心不存在');
- $user->delete();
- return true;
- }
- }
|