ApplyController.php 2.9 KB

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