| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638 |
- <?php
- namespace mobile\controllers;
- use biz\goods\services\CategoryRelateService;
- use biz\goods\services\CategoryService;
- use biz\goods\services\UsageRelationService;
- use biz\tool\services\CouponModelService;
- use biz\tool\services\CouponRewardService;
- use biz\tool\services\CouponRightService;
- use biz\tool\services\CouponService;
- use biz\user\services\UserAssetService;
- use biz\user\services\UserOldDataService;
- use biz\user\services\UserService;
- use Yii;
- use yii\helpers\Json;
- use common\models\xhOrderGoods;
- use common\models\xhUserCapital;
- use common\models\xhUserIntegral;
- use common\components\qrCodeUtil;
- use common\components\stringUtil;
- use common\components\weixinUtil;
- use common\components\configDict;
- use common\components\util;
- use common\services\xhCommonService;
- use common\services\xhUserService;
- use common\services\xhGoodsService;
- use common\services\xhTrainStudentService;
- use common\services\xhMerchantExtendService;
- use common\services\xhUnionUserService;
- use common\services\xhOrderService;
- use common\services\xhUserAssetService;
- use common\services\xhCouponService;
- use common\services\xhTrainUserCourseService;
- use common\services\xhUserIntegralService;
- class CenterController extends MobileendController
- {
-
- public $layout = 'centerMain';
-
- public function actionIndex()
- {
- $id = $this->userId;
-
- CouponService::paySuccessGetCoupon();
-
- $userAsset = xhUserAssetService::getByUserId($id);
- return $this->render('index', ['user' => $this->user, 'userAsset' => $userAsset]);
- }
-
- public function actionOrder()
- {
- $order = xhOrderService::getAllByCondition(['userId' => $this->userId]);
- $payStatusName = configDict::getConfig('payStatusName');
- return $this->render('order', ['order' => $order, 'payStatusName' => $payStatusName]);
- }
-
- public function actionOrderDetail()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $order = xhOrderService::getById($id);
- if ($order['userId'] != $this->userId) {
- util::stop('非法访问');
- }
- if ($order['sourceType'] == 0) {//0商城订单
- $goodsList = xhOrderGoods::getAllByCondition(['orderId' => $id]);
- foreach ($goodsList as $key => $good) {
- $goodsId = $good['goodsId'];
- $goodsData = xhGoodsService::getById($goodsId);
- if ($goodsData['goodsName'] != $good['title']) {
- $subTitle = $good['title'];
- $goodsList[$key]['title'] = $goodsData['goodsName'];
- $goodsList[$key]['subTitle'] = $subTitle;
- }
- }
- } else if ($order['sourceType'] == 1) {//1付款订单
- $goodsList = [];
- } else {
- util::stop('未知订单类型');
- }
- $payWayNameList = configDict::getConfig('payWayName');
- $payStatusName = configDict::getConfig('payStatusName');
- $sendStatus = configDict::getConfig('sendStatus');
- $sendStatusName = configDict::getConfig('sendStatusName');
- return $this->render('orderDetail', ['sendStatusName' => $sendStatusName, 'sendStatus' => $sendStatus, 'payStatusName' => $payStatusName, 'payWayNameList' => $payWayNameList, 'order' => $order, 'goodsList' => $goodsList]);
- }
-
- /**
- * 我的二维码
- */
- public function actionQrCode()
- {
- $get = Yii::$app->request->get();
- $userAsset = xhUserAssetService::getByUserId($this->userId);
- $uniqueQrCode = $userAsset['uniqueQrCode'];
- $userId = $this->userId;
- $string = configDict::getQrKey('user') . $userId;
- $webRoot = Yii::getAlias('@webroot') . '/../../../../resource/images/';
- if (empty($uniqueQrCode) || file_exists($webRoot . $uniqueQrCode) == false) {
- $logo = !empty($this->merchant['logo']) ? $webRoot . $this->merchant['logo'] : '';
- $uniqueQrCode = qrCodeUtil::card($string, '', $logo);
- xhUserAssetService::updateByUserId($this->userId, ['uniqueQrCode' => $uniqueQrCode]);
- }
- //正在呼叫
- $discount = '';
- if (!empty($userAsset) && $userAsset['isMember'] == 1) {
- $gradeList = xhMerchantExtendService::getGradeList($this->merchantExtend, 'desc');
- $level = $userAsset['memberLevel'];
- $discount = $gradeList[$level]['discount'];
- }
- return $this->render('qrCode', ['uniqueQrCode' => $uniqueQrCode, 'userAsset' => $userAsset, 'user' => $this->user, 'discount' => $discount]);
- }
-
- public function actionStudentCard()
- {
- $student = xhTrainStudentService::getByUserId($this->userId);
- $uniqueQrCode = $userAsset['uniqueQrCode'];
- $string = configDict::getQrKey('xhStudent') . $this->userId;
- $unique = $string;
- if (empty($uniqueQrCode)) {
- $webRoot = Yii::getAlias('@webroot') . '/../../../resource/images/';
- $logo = !empty($this->merchant['logo']) ? $webRoot . $this->merchant['logo'] : '';
- $uniqueQrCode = qrCodeUtil::generate($string, $unique, $logo);
- xhTrainStudentService::updateByUserId($this->userId, ['uniqueQrCode' => $uniqueQrCode]);
- }
- return $this->render('studentCard', ['uniqueQrCode' => $uniqueQrCode, 'student' => $student, 'user' => $this->user]);
- }
-
- /**
- * 获取集赞排行榜
- */
- public function actionGetPraiseRank()
- {
- $weekReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserWeek" . date("Y-W") . "PraiseNum", 0, 10, 'WITHSCORES']);
- $weekRank = [];
- if (!empty($weekReturn)) {
- $i = 0;
- $x = 0;
- foreach ($weekReturn as $key => $val) {
- $i++;
- if ($i % 2 == 0) {
- $weekRank[$x]['praiseNum'] = $val;
- $x++;
- } else {
- $userInfo = xhUserService::getById($val);
- unset($userInfo['payPassword']);
- unset($userInfo['password']);
- $weekRank[$x]['userInfo'] = $userInfo;
- }
- }
- }
- $monthReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserMonth" . date("Y-m") . "PraiseNum", 0, 10, 'WITHSCORES']);
- $monthRank = [];
- if (!empty($monthReturn)) {
- $i = 0;
- $x = 0;
- foreach ($monthReturn as $key => $val) {
- $i++;
- if ($i % 2 == 0) {
- $monthRank[$x]['praiseNum'] = $val;
- $x++;
- } else {
- $userInfo = xhUserService::getById($val);
- unset($userInfo['payPassword']);
- unset($userInfo['password']);
- $monthRank[$x]['userInfo'] = $userInfo;
- }
- }
- }
- return $this->renderPartial('getPraiseRank', ['weekRank' => $weekRank, 'monthRank' => $monthRank]);
- }
-
- /**
- * 支付密码设置
- * @return string
- */
- public function actionPassword()
- {
- return $this->render('password', ['user' => $this->user]);
- }
-
- /**
- * 修改支付密码
- */
- public function actionModifyPayPassword()
- {
- $post = Yii::$app->request->post();
- $prePassword = isset($post['prePassword']) ? $post['prePassword'] : '';
- $sqlpwd = $this->user['payPassword'];
- if (empty($sqlpwd) || md5($prePassword) == $sqlpwd) {
- xhUserService::updateById($this->userId, ['payPassword' => md5($post['password'])]);
- util::successInfo();
- }
- util::failInfo('没有修改成功');
- }
-
- /**
- * 我的资料
- */
- public function actionInfo()
- {
- $merchantAccount = $this->merchant['id'];
- return $this->render('info', ['user' => $this->user, 'merchantAccount' => $merchantAccount]);
- }
-
- /**
- * 用户修改个人信息,验证手机号
- */
- public function actionMobileNotUsed()
- {
- $get = Yii::$app->request->get();
- $mobile = isset($get['mobile']) ? $get['mobile'] : '';
- $status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
- if ($status) {
- util::successInfo('');
- }
- util::failInfo('');
- }
-
- /**
- * 修改用户信息,生成验证码
- */
- public function actionGenerateAuthCode()
- {
- $get = Yii::$app->request->get();
- if (isset($get['mobile'])) {
- $mobile = $_GET['mobile'];
- if (stringUtil::isMobieNumber($mobile) == false) {
- echo Json::encode(['code' => 'A0002', 'msg' => '手机号填写有误']);
- Yii::$app->end();
- }
- $status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
- if ($status == false) {
- echo Json::encode(['code' => 'A0002', 'msg' => '手机号已经被使用']);
- Yii::$app->end();
- }
- $now = time();
- if (isset(Yii::$app->session['modifyUserMobileAuthCode']) == false || ($now - Yii::$app->session['modifyUserMobileAuthCodeTime']) > 120) {
- $num = stringUtil::getRandNum(5);
- Yii::$app->session['modifyUserMobileAuthCode'] = $num;
- Yii::$app->session['modifyUserMobileAuthCodeTime'] = time();
- $msg = "您的验证码:" . $num;
- echo Json::encode(['code' => 'A0001', 'msg' => '', 'data' => '']);
- xhCommonService::sendMobileMsg($mobile, $msg, $this->merchant);
- }
- }
- }
-
- /**
- * 修改用户信息,检测验证码
- */
- public function actionCheckAuthCode()
- {
- $get = Yii::$app->request->get();
- if (isset($get['authCode']) && isset(Yii::$app->session['modifyUserMobileAuthCode'])) {
- if ($get['authCode'] == Yii::$app->session['modifyUserMobileAuthCode']) {
- echo Json::encode(['code' => 'A0001', 'msg' => '', 'data' => []]);
- Yii::$app->end();
- }
- echo Json::encode(['code' => 'A0002', 'msg' => '验证码不正确', 'data' => []]);
- }
- }
-
- /**
- * 更新用户信息
- */
- public function actionUpdateUserInfo()
- {
- $post = Yii::$app->request->post();
- $session = Yii::$app->session;
- if (isset($post['authCode']) == false || empty($post['authCode']) || isset($session['modifyUserMobileAuthCode']) == false) {
- echo Json::encode(['code' => 'A0002', 'msg' => '没有验证码参数或未生成验证码', 'data' => '']);
- Yii::$app->end();
- }
- if ($post['authCode'] != $session['modifyUserMobileAuthCode']) {
- echo Json::encode(['code' => 'A0002', 'msg' => '验证码不正确', 'data' => '']);
- Yii::$app->end();
- }
- if (isset($post['mobile']) == false || stringUtil::isMobieNumber($post['mobile'] == false)) {
- echo Json::encode(['code' => 'A0002', 'msg' => '没有手机号或不符合要求', 'data' => '']);
- Yii::$app->end();
- }
- $mobile = $post['mobile'];
- $status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
- if ($status == false) {
- util::failInfo('手机号已经被使用');
- }
- unset($post['_csrf']);
- unset($post['authCode']);
- unset($post['nickName']);
- $post['isMember'] = 1;
- $userId = $this->userId;
- /**升级成为会员**/
- UserService::upgradeToMember($userId,$this->merchantId, $post);
- util::successInfo('操作成功');
- }
-
- /**
- * 我的余额记录
- */
- public function actionMyBalance()
- {
- $capital = xhUserCapital::find()->where(['merchantId' => $this->merchantId, 'userId' => $this->userId])->orderBy('addTime desc')->all();
- return $this->render('myBalance', ['capital' => $capital]);
- }
-
- /**
- * 我的积分记录
- */
- public function actionMyIntegral()
- {
- $integral = xhUserIntegral::find()->where(['merchantId' => $this->merchantId, 'userId' => $this->userId])->orderBy('id desc')->all();
- $userAsset = xhUserAssetService::getByUserId($this->merchantId);
- $myIntegral = !empty($userAsset) ? $userAsset['integral'] : 0;
- return $this->render('myIntegral', ['integral' => $integral, 'myIntegral' => $myIntegral]);
- }
-
-
- public function actionMyIntegralDetail()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $integral = xhUserIntegralService::getById($id);
- $order = [];
- $capitalList = configDict::getConfig('capitalType');
- $orderCapital = $capitalList['xhOrder']['id'];
- if ($integral['capitalType'] == $orderCapital) {
- $orderId = $integral['relateId'];
- if (!empty($orderId)) {
- $order = xhOrderService::getById($orderId);
- }
- }
- return $this->render('myIntegralDetail', ['integral' => $integral, 'order' => $order]);
- }
-
- /**
- * 用户聊天获取消息
- */
- public function actionGetMsg()
- {
- $merchantId = $this->merchantId;
- $userId = $this->userId;
- $get = Yii::$app->request->get();
- $content = Yii::$app->redis->executeCommand('RPOP', ["chat_user_get_{$merchantId}_{$userId}"]);
- echo Json::encode(['code' => 'A0001', 'msg' => 'success', 'data' => ['content' => $content]]);
- }
-
- /**
- * 用户聊天送消息
- */
- public function actionSendMsg()
- {
- $merchantId = $this->merchantId;
- $userId = $this->userId;
- $get = Yii::$app->request->get();
- if (isset($get['content']) && !empty($get['content'])) {
- $content = $get['content'];
- $now = time();
- Yii::$app->redis->executeCommand('LPUSH', ["chat_merchant_get_{$merchantId}_{$userId}", $now . '|' . $content]);
- //独立认证公众号,用户不需要使用网页接收消息,直接使用公众号聊天
- if (xhMerchantService::isAuth($merchantId) == false) {
- Yii::$app->redis->executeCommand('LPUSH', ["chat_user_get_{$merchantId}_{$userId}", $now . '|' . $content]);
- }
- }
- }
-
- public function actionRight()
- {
- $memberLevel = xhMerchantExtendService::getGradeList($this->merchantExtend);
- return $this->render('right', ['memberLevel' => $memberLevel]);
- }
-
- public function actionStudentRight()
- {
- $memberIntegral = configDict::getConfig('memberIntegral');
- return $this->render('studentRight', ['memberIntegral' => $memberIntegral]);
- }
-
- public function actionMyCourse()
- {
- $course = xhTrainUserCourseService::getAllByCondition(['userId' => $this->userId]);
- $numList = [];
- $time = time();
- foreach ($course as $key => $val) {
- $courseId = $val->id;
- $praiseNum = Yii::$app->redis->executeCommand('ZCOUNT', ["userCourse{$courseId}PraiseUser", 0, $time]);
- $numList[$courseId] = $praiseNum;
- }
- return $this->render('myCourse', ['course' => $course, 'numList' => $numList]);
- }
-
- public function actionMyCourseDetail()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $course = xhTrainUserCourseService::getById($id);
- if (empty($course) || $course['userId'] != $this->userId) {
- echo '课程不存在或不是你的课程哦~';
- util::end();
- }
- return $this->render('myCourseDetail', ['course' => $course]);
- }
-
- public function actionUploadCourse()
- {
- $post = Yii::$app->request->post();
- $courseId = $post['courseId'];
- $mediaId = $post['mediaId'];
- $course = xhTrainUserCourseService::getById($courseId);
- if (empty($course) || $course['userId'] != $this->userId) {
- util::failInfo('非法课程');
- }
- $img = weixinUtil::downloadStudentWorksImg($this->merchant, $mediaId);//用mediaId从微信下载图片保存到服务器
- $now = time();
- $data = ['worksImg' => $img, 'status' => 1, 'attendTime' => $now, 'modTime' => $now, 'addTime' => $now];
- xhTrainUserCourseService::updateById($courseId, $data);
- util::successInfo('上传成功');
- }
-
- public function actionMyCourseShow()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $course = xhTrainUserCourseService::getById($id);
- $largeImg = $course['worksImg'];
- $worksImgList = xhTrainUserCourseService::getWorksImgList($largeImg);
- $time = time();
- $praiseNum = Yii::$app->redis->executeCommand('ZCOUNT', ["userCourse{$id}PraiseUser", 0, $time]);//值在min和max之间的成员的数量
- return $this->render('myCourseShow', ['praiseNum' => $praiseNum, 'user' => $this->user, 'course' => $course, 'worksImgList' => $worksImgList]);
- }
-
- public function actionPraiseWorks()
- {
- $get = Yii::$app->request->get();
- $courseId = isset($get['courseId']) ? $get['courseId'] : 0;
- $course = xhTrainUserCourseService::getById($courseId);
- $courseUserId = $course['userId'];
- $userId = $this->userId;
- $time = time();
- $return = Yii::$app->redis->executeCommand('ZRANK', ["userCourse{$userCourseId}PraiseUser", "{$userId}"]);
- if (empty($courseUserId)) {
- util::failInfo('这个作品没有主人哦~');
- }
- if (isset($return)) {
- util::failInfo('您已经赞过了哦~');
- }
- //这个作品增加点赞用户,点赞时间
- Yii::$app->redis->executeCommand('ZADD', ["userCourse{$userCourseId}PraiseUser", $time, "{$userId}"]);
- //每个星期,用户的点赞数量+1
- Yii::$app->redis->executeCommand('ZINCRBY', ["merchant{$this->merchantId}UserWeek" . date("Y-W") . "PraiseNum", 1, "{$courseUserId}"]);
- //每个月,用户的点赞数量+1
- Yii::$app->redis->executeCommand('ZINCRBY', ["merchant{$this->merchantId}UserMonth" . date("Y-m") . "PraiseNum", 1, "{$courseUserId}"]);
-
- $student = xhTrainStudentService::getByUserId($courseUserId);
- $updatePraiseNum = $student['praiseNum'] + 1;
- xhTrainStudentService::updateByUserId($courseUserId, ['praiseNum' => $updatePraiseNum]);
- util::successInfo('+1');
- }
-
- /**
- * 获取所有点赞的人
- */
- public function actionGetPraiseUser()
- {
- $get = Yii::$app->request->get();
- $userCourseId = $get['userCourseId'];
- $userId = $this->userId;
- $time = time();
- $return = Yii::$app->redis->executeCommand('ZRANGE', ["userCourse{$userCourseId}PraiseUser", 0, 100, 'WITHSCORES']);
- $arr = [];
- $userList = [];
- if (!empty($return)) {
- $i = 0;
- $x = 0;
- foreach ($return as $key => $val) {
- $i++;
- if ($i % 2 == 0) {
- $arr[$x]['time'] = $val;
- $x++;
- } else {
- $arr[$x]['userId'] = $val;
- $userInfo = xhUserService::getById($val);
- unset($userInfo['payPassword']);
- unset($userInfo['password']);
- $userList[] = $userInfo;
- }
- }
- }
- $weekReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserWeek" . date("Y-W") . "PraiseNum", 0, 10, 'WITHSCORES']);
- $weekRank = [];
- if (!empty($weekReturn)) {
- $i = 0;
- $x = 0;
- foreach ($weekReturn as $key => $val) {
- $i++;
- if ($i % 2 == 0) {
- $weekRank[$x]['praiseNum'] = $val;
- $x++;
- } else {
- $userInfo = xhUserService::getById($val);
- unset($userInfo['payPassword']);
- unset($userInfo['password']);
- $weekRank[$x]['userInfo'] = $userInfo;
- }
- }
- }
- return $this->renderPartial('getPraiseUser', ['weekRank' => $weekRank, 'user' => $userList]);
- }
-
- /**
- * 代金劵
- */
- public function actionCoupon()
- {
- $coupon = xhCouponService::getUserCoupon($this->userId);
- return $this->render('coupon', ['coupon' => $coupon]);
- }
-
- /**
- * 生成代金劵的二维码地址
- */
- public function actionShowCouponQrcode()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $number = isset($get['number']) ? $get['number'] : 0;
- $string = configDict::getQrKey('coupon') . $id;
- $logo = Yii::getAlias("@app") . '/../images' . $this->merchant['logo'];//取商家的logo
- $imgUrl = qrCodeUtil::generate($string, 'frontend_coupon_' . $this->merchantId . '_' . $id, $logo);
- $coupon = xhCouponService::getById($id);
- if (!empty($coupon)) {
- $id = $coupon['id'];
- $userId = $coupon['userId'];
- xhCouponService::updateById($id, $userId, ['urlQrCode' => $imgUrl]);
- }
- util::successInfo('success', 'A0001', ['url' => $imgUrl]);
- }
-
- //老带新优惠卷 shish 2019.8.21
- public function actionMyRight()
- {
- $userId = $this->userId;
- $respond = CouponRightService::getListData('*', ['userId' => $userId], 1, 100, 'addTime desc');
- $list = isset($respond['list']) ? $respond['list'] : [];
- $modelInfoList = [];
- if (!empty($list)) {
- $modelIds = array_column($list, 'modelId');
- $modelInfoList = CouponModelService::getByIds($modelIds, null, 'id');
- }
- $usageList = UsageRelationService::getMyUsage();
- $categoryList = CategoryRelateService::getCategoryData();
- return $this->renderPartial('myRight', ['list' => $list, 'usageList' => $usageList, 'categoryList' => $categoryList, 'modelInfoList' => $modelInfoList]);
- }
-
- //朋友已经领取,但没有使用的卷 shish 2019.9.1
- public function actionGetCoupon()
- {
- $userId = $this->userId;
- $respond = CouponService::getListData('*', ['introUserId' => $userId], 1, 100, 'addTime desc');
- $list = isset($respond['list']) ? $respond['list'] : [];
- $userInfoList = [];
- if (!empty($list)) {
- $time = time();
- $userIdList = array_column($list, 'userId');
- $userInfoList = UserService::getByIds($userIdList, null, 'id');
- foreach ($list as $key => $val) {
- if ($val['deadline'] < $time) {
- unset($list[$key]);
- }
- }
- }
- $usageList = UsageRelationService::getMyUsage();
- $categoryList = CategoryRelateService::getCategoryData();
- return $this->renderPartial('getCoupon', ['list' => $list, 'usageList' => $usageList, 'categoryList' => $categoryList, 'userInfoList' => $userInfoList]);
- }
-
- //朋友已使用的卷和奖励 shish 2019.9.1
- public function actionGetReward()
- {
- $userId = $this->userId;
- $respond = CouponRewardService::getListData('*', ['userId' => $userId], 1, 100, 'addTime desc');
- $list = isset($respond['list']) ? $respond['list'] : [];
- $userInfoList = [];
- if (!empty($list)) {
- $userIdList = array_column($list, 'invitedUserId');
- $userInfoList = UserService::getByIds($userIdList, null, 'id');
- }
- return $this->renderPartial('getReward', ['list' => $list, 'userInfoList' => $userInfoList]);
- }
-
- //我的优惠卷 shish 2019.8.27
- public function actionMyCoupon()
- {
- $status = Yii::$app->request->get('status', 0);
- $list = CouponService::getMyCoupon($status);
- $categoryList = CategoryRelateService::getCategoryData();
- $usageList = UsageRelationService::getMyUsage();
- return $this->renderPartial('myCoupon', ['list' => $list, 'usageList' => $usageList, 'categoryList' => $categoryList, 'status' => $status]);
- }
-
- //老带新优惠卷明细 shish 2019.8.25
- public function actionMyRightDetail()
- {
-
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $info = CouponRightService::getRightDetail($id);
- $categoryList = CategoryRelateService::getCategoryData();
- $usageList = UsageRelationService::getMyUsage();
- return $this->renderPartial('myRightDetail', ['info' => $info, 'usageList' => $usageList, 'categoryList' => $categoryList]);
- }
-
- //老带新优惠卷情况 shish 2019.8.25
- public function actionCouponDetail()
- {
- $rightId = Yii::$app->request->get('rightId');
- $info = CouponRightService::getRightDetail($rightId);
- if ($info['merchantId'] != $this->merchantId) {
- util::fail('无效请求');
- }
- $userId = $info['userId'];
- $userInfo = UserService::getById($userId);
- $categoryList = CategoryRelateService::getCategoryData();
- $usageList = UsageRelationService::getMyUsage();
- return $this->renderPartial('couponDetail', ['info' => $info, 'usageList' => $usageList, 'categoryList' => $categoryList, 'userInfo' => $userInfo]);
- }
-
- //领取优惠卷 shish 2019.8.25
- public function actionGainCoupon()
- {
- $get = Yii::$app->request->get();
- CouponRightService::gainCoupon($get);
- util::success([], '成功领取');
- }
-
- }
|