ApplyController.php 3.1 KB

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