ApplyController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace shop\controllers;
  3. use biz\saas\services\ApplyService;
  4. use biz\wx\services\WxBaseService;
  5. use biz\wx\services\WxOpenService;
  6. use Yii;
  7. use common\components\util;
  8. use biz\admin\services\AdminService;
  9. use biz\saas\classes\ApplyClass;
  10. use biz\saas\services\RegionService;
  11. use yii\web\Controller;
  12. class ApplyController extends BaseController
  13. {
  14. //我的代理 shish 2019.12.26
  15. public function actionList()
  16. {
  17. $status = Yii::$app->request->get('status', 0);
  18. $where = [];
  19. $where['introMerchantId'] = $this->merchantId;
  20. if ($status != -1) {
  21. $where['status'] = $status;
  22. }
  23. $data = ApplyService::getApplyList($where);
  24. util::success($data);
  25. }
  26. //审核
  27. public function actionCheck()
  28. {
  29. $id = Yii::$app->request->post('id');
  30. $status = Yii::$app->request->post('status', 0);
  31. $remark = Yii::$app->request->post('remark', '');
  32. $apply = ApplyService::getById($id);
  33. if (empty($apply)) {
  34. util::fail('找不到申请记录');
  35. }
  36. if ($apply['status'] != 0) {
  37. util::fail('已经审过了');
  38. }
  39. if ($status == 1) {
  40. ApplyService::pass($id);
  41. }
  42. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  43. util::success('操作成功');
  44. }
  45. //申请试用 shish 2020.1.11
  46. public function actionRegister()
  47. {
  48. $rand = rand(0, 1);
  49. $wxBase = WxBaseService::getWxBase();
  50. $wxAliasName = isset($wxBase['wxAliasName']) ? $wxBase['wxAliasName'] : 'ihuahuibao';
  51. $data = ['focus' => 1, 'wxAliasName' => $wxAliasName];
  52. if ($rand == 0) {
  53. $data = ['focus' => 0, 'wxAliasName' => $wxAliasName];
  54. }
  55. util::success($data);
  56. $get = Yii::$app->request->get();
  57. if (isset($get['oldId']) && !empty($get['oldId'])) {
  58. $get['introMerchantId'] = $get['oldId'];
  59. }
  60. $get['userId'] = $this->userId;
  61. $get['long'] = isset($get['longitude']) ? $get['longitude'] : '';
  62. $get['lat'] = isset($get['latitude']) ? $get['latitude'] : '';
  63. $cacheKey = 'OPEN_SHOP_APPLY_' . $this->userId;
  64. $cacheCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  65. if (isset($cacheCode) == false || empty($cacheCode)) {
  66. util::fail('没有验证码');
  67. }
  68. if ($get['code'] != $cacheCode) {
  69. util::fail('验证码错误');
  70. }
  71. $apply = ApplyClass::getByCondition(['userId' => $this->userId]);
  72. if (!empty($apply)) {
  73. util::fail('您已经申请过了');
  74. }
  75. $admin = AdminService::getByCondition(['platUserId' => $this->userId]);
  76. if (!empty($admin)) {
  77. util::fail('您已经开店了');
  78. }
  79. ApplyService::addApply($get);
  80. $rand = rand(0, 1);
  81. $wxBase = WxBaseService::getWxBase();
  82. $wxAliasName = isset($wxBase['wxAliasName']) ? $wxBase['wxAliasName'] : 'ihuahuibao';
  83. $data = ['focus' => 1, 'wxAliasName' => $wxAliasName];
  84. if ($rand == 0) {
  85. $data = ['focus' => 0, 'wxAliasName' => $wxAliasName];
  86. }
  87. util::success($data);
  88. }
  89. //申请状态
  90. public function actionApplyStatus()
  91. {
  92. //-1申请试用 0审核中 1审核通过、试用中 2审核未通过 3已付费,立即订购 4试用到期失效,待付款,立即订购,价格不显示
  93. $status = -1;
  94. util::success(['status' => $status]);
  95. }
  96. //地图相关信息 shish 2020.1.14
  97. public function actionRegionRelate()
  98. {
  99. $regionTree = RegionService::tree();
  100. $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
  101. $out = ['region' => $regionTree, 'txMapKey' => $mapKey];
  102. util::success($out);
  103. }
  104. //获取申请的验证码 shish 2020.2.23
  105. public function actionGetValidateCode()
  106. {
  107. $mobile = Yii::$app->request->get('mobile');
  108. util::success(['code' => rand(1111, 9999)]);
  109. }
  110. }