ApplyController.php 4.8 KB

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