ApplyController.php 3.1 KB

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