ApplyController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\sj\classes\SjClass;
  4. use bizHd\saas\services\ApplyService;
  5. use Yii;
  6. use common\components\util;
  7. use bizHd\saas\classes\ApplyClass;
  8. use bizHd\saas\services\RegionService;
  9. class ApplyController extends BaseController
  10. {
  11. public $guestAccess = ['register'];
  12. //邀请开店列表 ssh 2021.1.28
  13. public function actionList()
  14. {
  15. $get = Yii::$app->request->get();
  16. $where = [];
  17. $where['introSjId'] = $this->sjId;
  18. $status = $get['status'] ?? 0;
  19. if (!empty($status)) {
  20. $where['status'] = $status;
  21. }
  22. $data = ApplyService::getApplyList($where);
  23. util::success($data);
  24. }
  25. //申请试用,花店添加新客户 ssh 2021.1.8
  26. public function actionRegister()
  27. {
  28. $post = Yii::$app->request->post();
  29. $post['adminId'] = $this->adminId;
  30. $admin = $this->admin;
  31. if (isset($admin['currentShopId']) && !empty($admin['currentShopId'])) {
  32. util::fail('您已经是门店员工');
  33. }
  34. $post['adminName'] = $admin['name'] ?? '';
  35. $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
  36. $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
  37. $post['from'] = ApplyClass::FROM_GHS;
  38. $name = $post['name'] ?? '';
  39. if (empty($name)) {
  40. util::fail('名称不能为空');
  41. }
  42. $has = SjClass::getByCondition(['name' => $name, 'style' => ApplyClass::FROM_GHS]);
  43. if (!empty($has)) {
  44. util::fail('名称已经存在');
  45. }
  46. $connection = Yii::$app->db;
  47. $transaction = $connection->beginTransaction();
  48. try {
  49. //新申请
  50. ApplyService::replaceGhs($post);
  51. $transaction->commit();
  52. } catch (\Exception $exception) {
  53. $transaction->rollBack();
  54. Yii::info("申请报错:" . $exception->getMessage());
  55. util::fail('提交失败');
  56. }
  57. util::complete();
  58. }
  59. //申请状态
  60. public function actionApplyStatus()
  61. {
  62. //-1申请试用 0审核中 1审核通过、试用中 2审核未通过 3已付费,立即订购 4试用到期失效,待付款,立即订购,价格不显示
  63. $status = -1;
  64. util::success(['status' => $status]);
  65. }
  66. //地图相关信息 ssh 2020.1.14
  67. public function actionRegionRelate()
  68. {
  69. $regionTree = RegionService::tree();
  70. $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
  71. $out = ['region' => $regionTree, 'txMapKey' => $mapKey];
  72. util::success($out);
  73. }
  74. //获取申请的验证码 ssh 2020.2.23
  75. public function actionGetValidateCode()
  76. {
  77. $mobile = Yii::$app->request->get('mobile');
  78. util::success(['code' => rand(1111, 9999)]);
  79. }
  80. }