ApplyController.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 $guestAccessAction = ['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. $get = Yii::$app->request->get();
  38. $admin = $this->admin;
  39. $get['adminId'] = $this->adminId;
  40. $get['adminName'] = $admin['adminName'] ?? '';
  41. $get['long'] = isset($get['longitude']) ? $get['longitude'] : '';
  42. $get['lat'] = isset($get['latitude']) ? $get['latitude'] : '';
  43. $get['from'] = ApplyClass::FROM_RETAIL;
  44. $get['style'] = SjClass::STYLE_RETAIL;
  45. $name = $get['name'] ?? '';
  46. if (empty($name)) {
  47. util::fail('名称不能为空');
  48. }
  49. $has = SjClass::getByCondition(['name' => $name]);
  50. if (!empty($has)) {
  51. util::fail('名称已经存在');
  52. }
  53. $connection = Yii::$app->db;
  54. $transaction = $connection->beginTransaction();
  55. try {
  56. //增加或更新申请
  57. ApplyService::replaceRetail($get);
  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. }