CenterController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <?php
  2. namespace mobile\controllers;
  3. use biz\goods\services\CategoryRelateService;
  4. use biz\goods\services\CategoryService;
  5. use biz\goods\services\UsageRelationService;
  6. use biz\promote\services\CouponModelService;
  7. use biz\promote\services\CouponRewardService;
  8. use biz\promote\services\CouponRightService;
  9. use biz\promote\services\CouponService;
  10. use biz\user\services\UserAssetService;
  11. use biz\user\services\UserOldDataService;
  12. use biz\user\services\UserService;
  13. use Yii;
  14. use yii\helpers\Json;
  15. use common\models\xhOrderGoods;
  16. use common\models\xhUserCapital;
  17. use common\models\xhUserIntegral;
  18. use common\components\qrCodeUtil;
  19. use common\components\stringUtil;
  20. use common\components\weixinUtil;
  21. use common\components\configDict;
  22. use common\components\util;
  23. use common\services\xhCommonService;
  24. use common\services\xhUserService;
  25. use common\services\xhGoodsService;
  26. use common\services\xhTrainStudentService;
  27. use common\services\xhMerchantExtendService;
  28. use common\services\xhUnionUserService;
  29. use common\services\xhOrderService;
  30. use common\services\xhUserAssetService;
  31. use common\services\xhCouponService;
  32. use common\services\xhTrainUserCourseService;
  33. use common\services\xhUserIntegralService;
  34. class CenterController extends MobileendController
  35. {
  36. public $layout = 'centerMain';
  37. public function actionIndex()
  38. {
  39. $id = $this->userId;
  40. CouponService::paySuccessGetCoupon();
  41. $userAsset = xhUserAssetService::getByUserId($id);
  42. return $this->render('index', ['user' => $this->user, 'userAsset' => $userAsset]);
  43. }
  44. public function actionOrder()
  45. {
  46. $order = xhOrderService::getAllByCondition(['userId' => $this->userId]);
  47. $payStatusName = configDict::getConfig('payStatusName');
  48. return $this->render('order', ['order' => $order, 'payStatusName' => $payStatusName]);
  49. }
  50. public function actionOrderDetail()
  51. {
  52. $get = Yii::$app->request->get();
  53. $id = isset($get['id']) ? $get['id'] : 0;
  54. $order = xhOrderService::getById($id);
  55. if ($order['userId'] != $this->userId) {
  56. util::stop('非法访问');
  57. }
  58. if ($order['sourceType'] == 0) {//0商城订单
  59. $goodsList = xhOrderGoods::getAllByCondition(['orderId' => $id]);
  60. foreach ($goodsList as $key => $good) {
  61. $goodsId = $good['goodsId'];
  62. $goodsData = xhGoodsService::getById($goodsId);
  63. if ($goodsData['goodsName'] != $good['title']) {
  64. $subTitle = $good['title'];
  65. $goodsList[$key]['title'] = $goodsData['goodsName'];
  66. $goodsList[$key]['subTitle'] = $subTitle;
  67. }
  68. }
  69. } else if ($order['sourceType'] == 1) {//1付款订单
  70. $goodsList = [];
  71. } else {
  72. util::stop('未知订单类型');
  73. }
  74. $payWayNameList = configDict::getConfig('payWayName');
  75. $payStatusName = configDict::getConfig('payStatusName');
  76. $sendStatus = configDict::getConfig('sendStatus');
  77. $sendStatusName = configDict::getConfig('sendStatusName');
  78. return $this->render('orderDetail', ['sendStatusName' => $sendStatusName, 'sendStatus' => $sendStatus, 'payStatusName' => $payStatusName, 'payWayNameList' => $payWayNameList, 'order' => $order, 'goodsList' => $goodsList]);
  79. }
  80. /**
  81. * 我的二维码
  82. */
  83. public function actionQrCode()
  84. {
  85. }
  86. public function actionStudentCard()
  87. {
  88. }
  89. /**
  90. * 获取集赞排行榜
  91. */
  92. public function actionGetPraiseRank()
  93. {
  94. $weekReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserWeek" . date("Y-W") . "PraiseNum", 0, 10, 'WITHSCORES']);
  95. $weekRank = [];
  96. if (!empty($weekReturn)) {
  97. $i = 0;
  98. $x = 0;
  99. foreach ($weekReturn as $key => $val) {
  100. $i++;
  101. if ($i % 2 == 0) {
  102. $weekRank[$x]['praiseNum'] = $val;
  103. $x++;
  104. } else {
  105. $userInfo = xhUserService::getById($val);
  106. unset($userInfo['payPassword']);
  107. unset($userInfo['password']);
  108. $weekRank[$x]['userInfo'] = $userInfo;
  109. }
  110. }
  111. }
  112. $monthReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserMonth" . date("Y-m") . "PraiseNum", 0, 10, 'WITHSCORES']);
  113. $monthRank = [];
  114. if (!empty($monthReturn)) {
  115. $i = 0;
  116. $x = 0;
  117. foreach ($monthReturn as $key => $val) {
  118. $i++;
  119. if ($i % 2 == 0) {
  120. $monthRank[$x]['praiseNum'] = $val;
  121. $x++;
  122. } else {
  123. $userInfo = xhUserService::getById($val);
  124. unset($userInfo['payPassword']);
  125. unset($userInfo['password']);
  126. $monthRank[$x]['userInfo'] = $userInfo;
  127. }
  128. }
  129. }
  130. return $this->renderPartial('getPraiseRank', ['weekRank' => $weekRank, 'monthRank' => $monthRank]);
  131. }
  132. /**
  133. * 支付密码设置
  134. * @return string
  135. */
  136. public function actionPassword()
  137. {
  138. return $this->render('password', ['user' => $this->user]);
  139. }
  140. /**
  141. * 修改支付密码
  142. */
  143. public function actionModifyPayPassword()
  144. {
  145. $post = Yii::$app->request->post();
  146. $prePassword = isset($post['prePassword']) ? $post['prePassword'] : '';
  147. $sqlpwd = $this->user['payPassword'];
  148. if (empty($sqlpwd) || md5($prePassword) == $sqlpwd) {
  149. xhUserService::updateById($this->userId, ['payPassword' => md5($post['password'])]);
  150. util::successInfo();
  151. }
  152. util::failInfo('没有修改成功');
  153. }
  154. /**
  155. * 我的资料
  156. */
  157. public function actionInfo()
  158. {
  159. $merchantAccount = $this->merchant['id'];
  160. return $this->render('info', ['user' => $this->user, 'merchantAccount' => $merchantAccount]);
  161. }
  162. /**
  163. * 用户修改个人信息,验证手机号
  164. */
  165. public function actionMobileNotUsed()
  166. {
  167. $get = Yii::$app->request->get();
  168. $mobile = isset($get['mobile']) ? $get['mobile'] : '';
  169. $status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
  170. if ($status) {
  171. util::successInfo('');
  172. }
  173. util::failInfo('');
  174. }
  175. /**
  176. * 修改用户信息,生成验证码
  177. */
  178. public function actionGenerateAuthCode()
  179. {
  180. $get = Yii::$app->request->get();
  181. if (isset($get['mobile'])) {
  182. $mobile = $_GET['mobile'];
  183. if (stringUtil::isMobieNumber($mobile) == false) {
  184. echo Json::encode(['code' => 'A0002', 'msg' => '手机号填写有误']);
  185. Yii::$app->end();
  186. }
  187. $status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
  188. if ($status == false) {
  189. echo Json::encode(['code' => 'A0002', 'msg' => '手机号已经被使用']);
  190. Yii::$app->end();
  191. }
  192. $now = time();
  193. if (isset(Yii::$app->session['modifyUserMobileAuthCode']) == false || ($now - Yii::$app->session['modifyUserMobileAuthCodeTime']) > 120) {
  194. $num = stringUtil::getRandNum(5);
  195. Yii::$app->session['modifyUserMobileAuthCode'] = $num;
  196. Yii::$app->session['modifyUserMobileAuthCodeTime'] = time();
  197. $msg = "您的验证码:" . $num;
  198. echo Json::encode(['code' => 'A0001', 'msg' => '', 'data' => '']);
  199. xhCommonService::sendMobileMsg($mobile, $msg, $this->merchant);
  200. }
  201. }
  202. }
  203. /**
  204. * 修改用户信息,检测验证码
  205. */
  206. public function actionCheckAuthCode()
  207. {
  208. $get = Yii::$app->request->get();
  209. if (isset($get['authCode']) && isset(Yii::$app->session['modifyUserMobileAuthCode'])) {
  210. if ($get['authCode'] == Yii::$app->session['modifyUserMobileAuthCode']) {
  211. echo Json::encode(['code' => 'A0001', 'msg' => '', 'data' => []]);
  212. Yii::$app->end();
  213. }
  214. echo Json::encode(['code' => 'A0002', 'msg' => '验证码不正确', 'data' => []]);
  215. }
  216. }
  217. /**
  218. * 更新用户信息
  219. */
  220. public function actionUpdateUserInfo()
  221. {
  222. $post = Yii::$app->request->post();
  223. $session = Yii::$app->session;
  224. if (isset($post['authCode']) == false || empty($post['authCode']) || isset($session['modifyUserMobileAuthCode']) == false) {
  225. echo Json::encode(['code' => 'A0002', 'msg' => '没有验证码参数或未生成验证码', 'data' => '']);
  226. Yii::$app->end();
  227. }
  228. if ($post['authCode'] != $session['modifyUserMobileAuthCode']) {
  229. echo Json::encode(['code' => 'A0002', 'msg' => '验证码不正确', 'data' => '']);
  230. Yii::$app->end();
  231. }
  232. if (isset($post['mobile']) == false || stringUtil::isMobieNumber($post['mobile'] == false)) {
  233. echo Json::encode(['code' => 'A0002', 'msg' => '没有手机号或不符合要求', 'data' => '']);
  234. Yii::$app->end();
  235. }
  236. $mobile = $post['mobile'];
  237. $status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
  238. if ($status == false) {
  239. util::failInfo('手机号已经被使用');
  240. }
  241. unset($post['_csrf']);
  242. unset($post['authCode']);
  243. unset($post['nickName']);
  244. $post['isMember'] = 1;
  245. $userId = $this->userId;
  246. /**升级成为会员**/
  247. UserService::upgradeToMember($userId,$this->merchantId, $post);
  248. util::successInfo('操作成功');
  249. }
  250. /**
  251. * 我的余额记录
  252. */
  253. public function actionMyBalance()
  254. {
  255. $capital = xhUserCapital::find()->where(['merchantId' => $this->merchantId, 'userId' => $this->userId])->orderBy('addTime desc')->all();
  256. return $this->render('myBalance', ['capital' => $capital]);
  257. }
  258. /**
  259. * 我的积分记录
  260. */
  261. public function actionMyIntegral()
  262. {
  263. $integral = xhUserIntegral::find()->where(['merchantId' => $this->merchantId, 'userId' => $this->userId])->orderBy('id desc')->all();
  264. $userAsset = xhUserAssetService::getByUserId($this->merchantId);
  265. $myIntegral = !empty($userAsset) ? $userAsset['integral'] : 0;
  266. return $this->render('myIntegral', ['integral' => $integral, 'myIntegral' => $myIntegral]);
  267. }
  268. public function actionMyIntegralDetail()
  269. {
  270. $get = Yii::$app->request->get();
  271. $id = isset($get['id']) ? $get['id'] : 0;
  272. $integral = xhUserIntegralService::getById($id);
  273. $order = [];
  274. $capitalList = configDict::getConfig('capitalType');
  275. $orderCapital = $capitalList['xhOrder']['id'];
  276. if ($integral['capitalType'] == $orderCapital) {
  277. $orderId = $integral['relateId'];
  278. if (!empty($orderId)) {
  279. $order = xhOrderService::getById($orderId);
  280. }
  281. }
  282. return $this->render('myIntegralDetail', ['integral' => $integral, 'order' => $order]);
  283. }
  284. /**
  285. * 用户聊天获取消息
  286. */
  287. public function actionGetMsg()
  288. {
  289. $merchantId = $this->merchantId;
  290. $userId = $this->userId;
  291. $get = Yii::$app->request->get();
  292. $content = Yii::$app->redis->executeCommand('RPOP', ["chat_user_get_{$merchantId}_{$userId}"]);
  293. echo Json::encode(['code' => 'A0001', 'msg' => 'success', 'data' => ['content' => $content]]);
  294. }
  295. /**
  296. * 用户聊天送消息
  297. */
  298. public function actionSendMsg()
  299. {
  300. $merchantId = $this->merchantId;
  301. $userId = $this->userId;
  302. $get = Yii::$app->request->get();
  303. if (isset($get['content']) && !empty($get['content'])) {
  304. $content = $get['content'];
  305. $now = time();
  306. Yii::$app->redis->executeCommand('LPUSH', ["chat_merchant_get_{$merchantId}_{$userId}", $now . '|' . $content]);
  307. //独立认证公众号,用户不需要使用网页接收消息,直接使用公众号聊天
  308. if (xhMerchantService::isAuth($merchantId) == false) {
  309. Yii::$app->redis->executeCommand('LPUSH', ["chat_user_get_{$merchantId}_{$userId}", $now . '|' . $content]);
  310. }
  311. }
  312. }
  313. public function actionRight()
  314. {
  315. $memberLevel = xhMerchantExtendService::getGradeList($this->merchantExtend);
  316. return $this->render('right', ['memberLevel' => $memberLevel]);
  317. }
  318. public function actionStudentRight()
  319. {
  320. $memberIntegral = configDict::getConfig('memberIntegral');
  321. return $this->render('studentRight', ['memberIntegral' => $memberIntegral]);
  322. }
  323. public function actionMyCourse()
  324. {
  325. $course = xhTrainUserCourseService::getAllByCondition(['userId' => $this->userId]);
  326. $numList = [];
  327. $time = time();
  328. foreach ($course as $key => $val) {
  329. $courseId = $val->id;
  330. $praiseNum = Yii::$app->redis->executeCommand('ZCOUNT', ["userCourse{$courseId}PraiseUser", 0, $time]);
  331. $numList[$courseId] = $praiseNum;
  332. }
  333. return $this->render('myCourse', ['course' => $course, 'numList' => $numList]);
  334. }
  335. public function actionMyCourseDetail()
  336. {
  337. $get = Yii::$app->request->get();
  338. $id = isset($get['id']) ? $get['id'] : 0;
  339. $course = xhTrainUserCourseService::getById($id);
  340. if (empty($course) || $course['userId'] != $this->userId) {
  341. echo '课程不存在或不是你的课程哦~';
  342. util::end();
  343. }
  344. return $this->render('myCourseDetail', ['course' => $course]);
  345. }
  346. public function actionUploadCourse()
  347. {
  348. $post = Yii::$app->request->post();
  349. $courseId = $post['courseId'];
  350. $mediaId = $post['mediaId'];
  351. $course = xhTrainUserCourseService::getById($courseId);
  352. if (empty($course) || $course['userId'] != $this->userId) {
  353. util::failInfo('非法课程');
  354. }
  355. $img = weixinUtil::downloadStudentWorksImg($this->merchant, $mediaId);//用mediaId从微信下载图片保存到服务器
  356. $now = time();
  357. $data = ['worksImg' => $img, 'status' => 1, 'attendTime' => $now, 'modTime' => $now, 'addTime' => $now];
  358. xhTrainUserCourseService::updateById($courseId, $data);
  359. util::successInfo('上传成功');
  360. }
  361. public function actionMyCourseShow()
  362. {
  363. $get = Yii::$app->request->get();
  364. $id = isset($get['id']) ? $get['id'] : 0;
  365. $course = xhTrainUserCourseService::getById($id);
  366. $largeImg = $course['worksImg'];
  367. $worksImgList = xhTrainUserCourseService::getWorksImgList($largeImg);
  368. $time = time();
  369. $praiseNum = Yii::$app->redis->executeCommand('ZCOUNT', ["userCourse{$id}PraiseUser", 0, $time]);//值在min和max之间的成员的数量
  370. return $this->render('myCourseShow', ['praiseNum' => $praiseNum, 'user' => $this->user, 'course' => $course, 'worksImgList' => $worksImgList]);
  371. }
  372. public function actionPraiseWorks()
  373. {
  374. $get = Yii::$app->request->get();
  375. $courseId = isset($get['courseId']) ? $get['courseId'] : 0;
  376. $course = xhTrainUserCourseService::getById($courseId);
  377. $courseUserId = $course['userId'];
  378. $userId = $this->userId;
  379. $time = time();
  380. $return = Yii::$app->redis->executeCommand('ZRANK', ["userCourse{$userCourseId}PraiseUser", "{$userId}"]);
  381. if (empty($courseUserId)) {
  382. util::failInfo('这个作品没有主人哦~');
  383. }
  384. if (isset($return)) {
  385. util::failInfo('您已经赞过了哦~');
  386. }
  387. //这个作品增加点赞用户,点赞时间
  388. Yii::$app->redis->executeCommand('ZADD', ["userCourse{$userCourseId}PraiseUser", $time, "{$userId}"]);
  389. //每个星期,用户的点赞数量+1
  390. Yii::$app->redis->executeCommand('ZINCRBY', ["merchant{$this->merchantId}UserWeek" . date("Y-W") . "PraiseNum", 1, "{$courseUserId}"]);
  391. //每个月,用户的点赞数量+1
  392. Yii::$app->redis->executeCommand('ZINCRBY', ["merchant{$this->merchantId}UserMonth" . date("Y-m") . "PraiseNum", 1, "{$courseUserId}"]);
  393. $student = xhTrainStudentService::getByUserId($courseUserId);
  394. $updatePraiseNum = $student['praiseNum'] + 1;
  395. xhTrainStudentService::updateByUserId($courseUserId, ['praiseNum' => $updatePraiseNum]);
  396. util::successInfo('+1');
  397. }
  398. /**
  399. * 获取所有点赞的人
  400. */
  401. public function actionGetPraiseUser()
  402. {
  403. $get = Yii::$app->request->get();
  404. $userCourseId = $get['userCourseId'];
  405. $userId = $this->userId;
  406. $time = time();
  407. $return = Yii::$app->redis->executeCommand('ZRANGE', ["userCourse{$userCourseId}PraiseUser", 0, 100, 'WITHSCORES']);
  408. $arr = [];
  409. $userList = [];
  410. if (!empty($return)) {
  411. $i = 0;
  412. $x = 0;
  413. foreach ($return as $key => $val) {
  414. $i++;
  415. if ($i % 2 == 0) {
  416. $arr[$x]['time'] = $val;
  417. $x++;
  418. } else {
  419. $arr[$x]['userId'] = $val;
  420. $userInfo = xhUserService::getById($val);
  421. unset($userInfo['payPassword']);
  422. unset($userInfo['password']);
  423. $userList[] = $userInfo;
  424. }
  425. }
  426. }
  427. $weekReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserWeek" . date("Y-W") . "PraiseNum", 0, 10, 'WITHSCORES']);
  428. $weekRank = [];
  429. if (!empty($weekReturn)) {
  430. $i = 0;
  431. $x = 0;
  432. foreach ($weekReturn as $key => $val) {
  433. $i++;
  434. if ($i % 2 == 0) {
  435. $weekRank[$x]['praiseNum'] = $val;
  436. $x++;
  437. } else {
  438. $userInfo = xhUserService::getById($val);
  439. unset($userInfo['payPassword']);
  440. unset($userInfo['password']);
  441. $weekRank[$x]['userInfo'] = $userInfo;
  442. }
  443. }
  444. }
  445. return $this->renderPartial('getPraiseUser', ['weekRank' => $weekRank, 'user' => $userList]);
  446. }
  447. /**
  448. * 代金劵
  449. */
  450. public function actionCoupon()
  451. {
  452. $coupon = xhCouponService::getUserCoupon($this->userId);
  453. return $this->render('coupon', ['coupon' => $coupon]);
  454. }
  455. /**
  456. * 生成代金劵的二维码地址
  457. */
  458. public function actionShowCouponQrcode()
  459. {
  460. $get = Yii::$app->request->get();
  461. $id = isset($get['id']) ? $get['id'] : 0;
  462. $number = isset($get['number']) ? $get['number'] : 0;
  463. $string = configDict::getQrKey('coupon') . $id;
  464. $logo = Yii::getAlias("@app") . '/../images' . $this->merchant['logo'];//取商家的logo
  465. $imgUrl = qrCodeUtil::generate($string, 'frontend_coupon_' . $this->merchantId . '_' . $id, $logo);
  466. $coupon = xhCouponService::getById($id);
  467. if (!empty($coupon)) {
  468. $id = $coupon['id'];
  469. $userId = $coupon['userId'];
  470. xhCouponService::updateById($id, $userId, ['urlQrCode' => $imgUrl]);
  471. }
  472. util::successInfo('success', 'A0001', ['url' => $imgUrl]);
  473. }
  474. //老带新优惠卷 shish 2019.8.21
  475. public function actionMyRight()
  476. {
  477. $userId = $this->userId;
  478. $respond = CouponRightService::getListData('*', ['userId' => $userId], 1, 100, 'addTime desc');
  479. $list = isset($respond['list']) ? $respond['list'] : [];
  480. $modelInfoList = [];
  481. if (!empty($list)) {
  482. $modelIds = array_column($list, 'modelId');
  483. $modelInfoList = CouponModelService::getByIds($modelIds, null, 'id');
  484. }
  485. $usageList = UsageRelationService::getMyUsage();
  486. $categoryList = CategoryRelateService::getCategoryData();
  487. return $this->renderPartial('myRight', ['list' => $list, 'usageList' => $usageList, 'categoryList' => $categoryList, 'modelInfoList' => $modelInfoList]);
  488. }
  489. //朋友已经领取,但没有使用的卷 shish 2019.9.1
  490. public function actionGetCoupon()
  491. {
  492. $userId = $this->userId;
  493. $respond = CouponService::getListData('*', ['introUserId' => $userId], 1, 100, 'addTime desc');
  494. $list = isset($respond['list']) ? $respond['list'] : [];
  495. $userInfoList = [];
  496. if (!empty($list)) {
  497. $time = time();
  498. $userIdList = array_column($list, 'userId');
  499. $userInfoList = UserService::getByIds($userIdList, null, 'id');
  500. foreach ($list as $key => $val) {
  501. if ($val['deadline'] < $time) {
  502. unset($list[$key]);
  503. }
  504. }
  505. }
  506. $usageList = UsageRelationService::getMyUsage();
  507. $categoryList = CategoryRelateService::getCategoryData();
  508. return $this->renderPartial('getCoupon', ['list' => $list, 'usageList' => $usageList, 'categoryList' => $categoryList, 'userInfoList' => $userInfoList]);
  509. }
  510. //朋友已使用的卷和奖励 shish 2019.9.1
  511. public function actionGetReward()
  512. {
  513. $userId = $this->userId;
  514. $respond = CouponRewardService::getListData('*', ['userId' => $userId], 1, 100, 'addTime desc');
  515. $list = isset($respond['list']) ? $respond['list'] : [];
  516. $userInfoList = [];
  517. if (!empty($list)) {
  518. $userIdList = array_column($list, 'invitedUserId');
  519. $userInfoList = UserService::getByIds($userIdList, null, 'id');
  520. }
  521. return $this->renderPartial('getReward', ['list' => $list, 'userInfoList' => $userInfoList]);
  522. }
  523. //我的优惠卷 shish 2019.8.27
  524. public function actionMyCoupon()
  525. {
  526. $status = Yii::$app->request->get('status', 0);
  527. $list = CouponService::getMyCoupon($status);
  528. $categoryList = CategoryRelateService::getCategoryData();
  529. $usageList = UsageRelationService::getMyUsage();
  530. return $this->renderPartial('myCoupon', ['list' => $list, 'usageList' => $usageList, 'categoryList' => $categoryList, 'status' => $status]);
  531. }
  532. //老带新优惠卷明细 shish 2019.8.25
  533. public function actionMyRightDetail()
  534. {
  535. $get = Yii::$app->request->get();
  536. $id = isset($get['id']) ? $get['id'] : 0;
  537. $info = CouponRightService::getRightDetail($id);
  538. $categoryList = CategoryRelateService::getCategoryData();
  539. $usageList = UsageRelationService::getMyUsage();
  540. return $this->renderPartial('myRightDetail', ['info' => $info, 'usageList' => $usageList, 'categoryList' => $categoryList]);
  541. }
  542. //老带新优惠卷情况 shish 2019.8.25
  543. public function actionCouponDetail()
  544. {
  545. $rightId = Yii::$app->request->get('rightId');
  546. $info = CouponRightService::getRightDetail($rightId);
  547. if ($info['merchantId'] != $this->merchantId) {
  548. util::fail('无效请求');
  549. }
  550. $userId = $info['userId'];
  551. $userInfo = UserService::getById($userId);
  552. $categoryList = CategoryRelateService::getCategoryData();
  553. $usageList = UsageRelationService::getMyUsage();
  554. return $this->renderPartial('couponDetail', ['info' => $info, 'usageList' => $usageList, 'categoryList' => $categoryList, 'userInfo' => $userInfo]);
  555. }
  556. //领取优惠卷 shish 2019.8.25
  557. public function actionGainCoupon()
  558. {
  559. $get = Yii::$app->request->get();
  560. CouponRightService::gainCoupon($get);
  561. util::success([], '成功领取');
  562. }
  563. }