ApplyController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. util::fail('操作失败');
  48. }
  49. util::success('操作成功');
  50. }
  51. //申请试用登记 shish 2020.1.11
  52. public function actionRegister()
  53. {
  54. $post = Yii::$app->request->post();
  55. $rand = rand(0, 1);
  56. $data = ['focus' => 1, 'qrCode' => ''];
  57. if ($rand == 0) {
  58. $data = ['focus' => 0, 'qrCode' => 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3602624501,870193918&fm=26&gp=0.jpg'];
  59. }
  60. util::success($data);
  61. }
  62. //申请状态
  63. public function actionApplyStatus()
  64. {
  65. $status = rand(0, 4);
  66. util::success(['status' => $status]);
  67. }
  68. }