request; if ($retuest->isGet) { $where = []; $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=', 'status', StatusEnum::ENABLED]; $countWhere = compact('where'); $where[] = new Expression("FIND_IN_SET({$this->user['level']}, member_level)"); $order = 'id desc'; $params = array('where' => $where, 'order'=>$order, 'limit' => 5); $list = Certificate::listPage($params, false, true); // 如果后台有新建证书,但是用户的等级一个都看不了,则给提示。如果后台没证书则不理 if($list['row_count'] == 0) { $countQuery = Certificate::find(); Certificate::paramPack($countWhere, $countQuery); if ($countQuery->count() > 0) { return $this->error('授权证书目前仅对指定等级开放,请升级后重试'); } } $user['number'] = $this->user_id.substr($this->user['mobile'],-4); $level = UserLevel::getOne([['mall_id' => $this->mall_id,'status' =>StatusEnum::ENABLED,'level'=>$this->user['level'] ]],true); $user['level'] = $level['name']; $list['user'] = $user; $sign = $this->mall['mall_sign']; if($list['list']){ foreach($list['list'] as $k => $v){ $list['list'][$k]['qrcode_url'] = DiyEnum::HOME_PAGE_PATH . "?sign={$sign}&pid=".$this->user_id; } } $list['qrcode_id'] = CertificateEnum::SHARE_TYPE; $this->success('获取成功', $list); } } /** * 认领证书 * @Author: ltm * @DateTime: 2022/5/8 0021 11:29 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionCodeDetail() { $retuest = Yii::$app->request; if ($retuest->isGet) { $params = Yii::$app->request->get(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($params,[ [['id'], 'safe'] ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['user_id'] = $this->user_id; $params['mall_id'] = $this->mall_id; $params['mobile'] = $this->user['mobile']; $res = CertificateClaim::setData($params); if ($res === false) throw new Exception(CertificateClaim::getStaticError()); return $this->success('操作成功'); } } /** * 认领证书 * @Author: ltm * @DateTime: 2022/5/8 0021 11:29 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionClaim() { $retuest = Yii::$app->request; if ($retuest->isGet) { $params = Yii::$app->request->get(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($params,[ [['id'], 'safe'] ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['user_id'] = $this->user_id; $params['mall_id'] = $this->mall_id; $params['mobile'] = $this->user['mobile']; $res = CertificateClaim::setData($params); if ($res === false) throw new Exception(CertificateClaim::getStaticError()); return $this->success('操作成功'); } } }