ApplyController.php 2.9 KB

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