ApplyController.php 4.2 KB

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