ApplyController.php 2.1 KB

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