| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- namespace hd\controllers;
- use bizHd\ll\classes\LlEventClass;
- use common\components\imgUtil;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- class LlEventController extends BaseController
- {
- public $guestAccess = [];
- public function actionAddMobile()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $mobile = $post['mobile'] ?? '';
- if (empty($mobile)) {
- util::fail('没有手机号');
- }
- if (!stringUtil::isMobile($mobile)) {
- util::fail('手机号错误');
- }
- $event = LlEventClass::getById($id, true);
- if (empty($event)) {
- util::fail('没有找到');
- }
- $shopId = $this->shopId;
- if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
- util::fail('不是你提交的');
- }
- LlEventClass::addMobile($event, $mobile);
- util::complete('添加成功');
- }
- //添加微信
- public function actionAddWx()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $wx = $post['mobile'] ?? '';
- if (empty($wx)) {
- util::fail('没有微信');
- }
- $event = LlEventClass::getById($id, true);
- if (empty($event)) {
- util::fail('没有找到');
- }
- $shopId = $this->shopId;
- if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
- util::fail('不是你提交的');
- }
- LlEventClass::addWx($event, $wx);
- util::complete('添加成功');
- }
- //添加身份证号
- public function actionAddNo()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $no = $post['no'] ?? '';
- if (empty($no)) {
- util::fail('没有身份证号');
- }
- $event = LlEventClass::getById($id, true);
- if (empty($event)) {
- util::fail('没有找到');
- }
- $shopId = $this->shopId;
- if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
- util::fail('不是你提交的');
- }
- LlEventClass::addNo($event, $no);
- util::complete('添加成功');
- }
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $event = LlEventClass::getById($id);
- if (empty($event)) {
- util::fail('没有找到');
- }
- $shopId = $this->shopId;
- if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
- util::fail('不是你提交的');
- }
- $proveJson = $event['prove'] ?? '';
- $proveData = json_decode($proveJson, true);
- $proveShort = [];
- $proveBig = [];
- $proveSmall = [];
- if (!empty($proveData)) {
- foreach ($proveData as $url) {
- $proveShort[] = $url;
- $small = imgUtil::groupImg($url) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
- $big = imgUtil::groupImg($url) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
- $proveBig[] = $big;
- $proveSmall[] = $small;
- }
- }
- $event['proveShort'] = $proveShort;
- $event['proveBig'] = $proveBig;
- $event['proveSmall'] = $proveSmall;
- util::success(['event' => $event]);
- }
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $requestType = $get['requestType'] ?? '';
- $where = [];
- $sensitive = true;
- if ($requestType == 'my') {
- $shopId = $this->shopId;
- $where['launchShopId'] = $shopId;
- $sensitive = false;
- }
- $respond = LlEventClass::getEventList($where, $sensitive);
- util::success($respond);
- }
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $name = $post['name'] ?? '';
- if (empty($name)) {
- util::fail('请填写店名或姓名');
- }
- $no = $post['no'] ?? '';
- if (!empty($no)) {
- $pattern = '/^(?:\d{15}|\d{17}[\dxX])$/';
- $valid = preg_match($pattern, $no);
- if ($valid == false) {
- util::fail('身份证号错误');
- }
- }
- $mobile = $post['mobile'] ?? '';
- $wx = $post['wx'] ?? '';
- if (empty($wx) && empty($mobile) && empty($no)) {
- util::fail('手机号、微信号、身份证必填一项');
- }
- $prove = $post['prove'] ?? [];
- if (empty($prove)) {
- util::fail('证据最少要一张');
- }
- $shop = $this->shop;
- $respond = LlEventClass::addEvent($post, $shop);
- util::success($respond);
- }
- }
|