ApplyController.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace saas\controllers;
  3. use bizTy\sj\classes\MerchantClass;
  4. use biz\saas\services\ApplyService;
  5. use common\components\util;
  6. use Yii;
  7. use yii\web\Controller;
  8. class ApplyController extends BaseController
  9. {
  10. //申请列表
  11. public function actionList()
  12. {
  13. $get = Yii::$app->request->get();
  14. $style = $get['style'] ?? MerchantClass::STYLE_RETAIL;
  15. $status = $get['status'] ?? 0;
  16. $where = [];
  17. if (!empty($status)) {
  18. $where['status'] = $status;
  19. }
  20. $where['style'] = $style;
  21. $list = ApplyService::getApplyList($where);
  22. util::success($list);
  23. }
  24. //审核
  25. public function actionCheck()
  26. {
  27. $id = Yii::$app->request->post('id');
  28. $status = Yii::$app->request->post('status', 0);
  29. $remark = Yii::$app->request->post('remark', '');
  30. $apply = ApplyService::getById($id);
  31. if (empty($apply)) {
  32. util::fail('找不到申请记录');
  33. }
  34. if ($apply['status'] != 1) {
  35. util::fail('已经审过了');
  36. }
  37. $connection = Yii::$app->db;
  38. $transaction = $connection->beginTransaction();
  39. try {
  40. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  41. if ($status == 1) {
  42. ApplyService::pass($id);
  43. }
  44. $transaction->commit();
  45. } catch (\Exception $exception) {
  46. $transaction->rollBack();
  47. Yii::info("审核操作报错:" . $exception->getMessage());
  48. util::fail('操作失败');
  49. }
  50. util::complete();
  51. }
  52. //申请试用登记 shish 2020.1.11
  53. public function actionRegister()
  54. {
  55. $post = Yii::$app->request->post();
  56. $rand = rand(0, 1);
  57. $data = ['focus' => 1, 'qrCode' => ''];
  58. if ($rand == 0) {
  59. $data = ['focus' => 0, 'qrCode' => 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3602624501,870193918&fm=26&gp=0.jpg'];
  60. }
  61. util::success($data);
  62. }
  63. //申请状态
  64. public function actionApplyStatus()
  65. {
  66. $status = rand(0, 4);
  67. util::success(['status' => $status]);
  68. }
  69. }