InviteController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace backend\controllers;
  3. use common\services\xhInviteService;
  4. use common\components\util;
  5. use Yii;
  6. use yii\web\Controller;
  7. use yii\helpers\Json;
  8. use common\components\qrCodeUtil;
  9. use common\components\page;
  10. use common\models\xhInvite;
  11. class InviteController extends BackendController
  12. {
  13. /**
  14. * 二维码列表
  15. */
  16. public function actionList()
  17. {
  18. $get = Yii::$app->request->get();
  19. $query = xhInvite::find();
  20. $query->where(['merchantId' =>$this->merchantId]);
  21. $countQuery = clone $query;
  22. $count = $countQuery->count();
  23. $page = isset($get['page']) ? $get['page'] : 1;
  24. $pageSize = 20;
  25. $offset = ($page - 1) * $pageSize;
  26. $models = $query->offset($offset)->orderBy('id desc')->limit($pageSize)->asArray()->all();
  27. $page = new page($count,$page,$pageSize);
  28. $paging = $page->fpage();
  29. $now = time();
  30. return $this->render('list', ['models' => $models,'paging' => $paging]);
  31. }
  32. /**
  33. * 生成二维码
  34. */
  35. public function actionGenerate()
  36. {
  37. if(empty($this->merchant['agentLevel'])){
  38. util::failInfo('您还不是代理商');
  39. }
  40. $return = xhInviteService::generate($this->merchantId);
  41. util::encode($return);
  42. }
  43. }