ApplyController.php 2.9 KB

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