ApplyController.php 3.5 KB

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