ApplyController.php 3.4 KB

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