ApplyController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace hd\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.huaml.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.huaml.com/ghs/home/deserve.png",
  26. ];
  27. util::success($data);
  28. }
  29. //我的代理 ssh 2019.12.26
  30. public function actionList()
  31. {
  32. $get = Yii::$app->request->get();
  33. $where = [];
  34. $where['introSjId'] = $this->sjId;
  35. $status = $get['status'] ?? 0;
  36. $style = $get['style'] ?? SjClass::STYLE_RETAIL;
  37. if (!empty($status)) {
  38. $where['status'] = $status;
  39. }
  40. $where['style'] = $style;
  41. $data = ApplyService::getApplyList($where);
  42. util::success($data);
  43. }
  44. //申请试用 ssh 2020.1.11
  45. public function actionRegister()
  46. {
  47. $post = Yii::$app->request->post();
  48. $post['adminId'] = $this->adminId;
  49. $admin = $this->admin->attributes;
  50. if (isset($admin['currentShopId']) && !empty($admin['currentShopId'])) {
  51. util::fail('您已经是门店员工');
  52. }
  53. $post['adminName'] = $admin['name'] ?? '';
  54. $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
  55. $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
  56. $post['from'] = ApplyClass::FROM_RETAIL;
  57. $post['style'] = SjClass::STYLE_RETAIL;
  58. $name = $post['name'] ?? '';
  59. if (empty($name)) {
  60. util::fail('名称不能为空');
  61. }
  62. if (stringUtil::getWordNum($name) > 8) {
  63. util::fail('名称不能超过8个汉字');
  64. }
  65. $has = SjClass::getByCondition(['name' => $name, 'style' => ApplyClass::FROM_RETAIL]);
  66. if (!empty($has)) {
  67. util::fail('名称已经存在');
  68. }
  69. $connection = Yii::$app->db;
  70. $transaction = $connection->beginTransaction();
  71. try {
  72. //增加或更新申请
  73. ApplyService::replaceRetail($post);
  74. $transaction->commit();
  75. } catch (\Exception $exception) {
  76. $transaction->rollBack();
  77. Yii::info("申请报错:" . $exception->getMessage());
  78. util::fail('提交失败');
  79. }
  80. util::complete();
  81. }
  82. //申请状态
  83. public function actionApplyStatus()
  84. {
  85. //-1申请试用 0审核中 1审核通过、试用中 2审核未通过 3已付费,立即订购 4试用到期失效,待付款,立即订购,价格不显示
  86. $status = -1;
  87. util::success(['status' => $status]);
  88. }
  89. //地图相关信息 ssh 2020.1.14
  90. public function actionRegionRelate()
  91. {
  92. $regionTree = RegionService::tree();
  93. $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
  94. $out = ['region' => $regionTree, 'txMapKey' => $mapKey];
  95. util::success($out);
  96. }
  97. //获取申请的验证码 ssh 2020.2.23
  98. public function actionGetValidateCode()
  99. {
  100. $mobile = Yii::$app->request->get('mobile');
  101. util::success(['code' => rand(1111, 9999)]);
  102. }
  103. }