ApplyController.php 3.1 KB

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