ApplyController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace pt\controllers;
  3. use bizTy\sj\classes\MerchantClass;
  4. use bizHd\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. $status = $get['status'] ?? 0;
  15. $where = [];
  16. if (!empty($status)) {
  17. $where['status'] = $status;
  18. }
  19. $list = ApplyService::getApplyList($where);
  20. util::success($list);
  21. }
  22. //审核
  23. public function actionCheck()
  24. {
  25. $id = Yii::$app->request->post('id');
  26. $status = Yii::$app->request->post('status', 0);
  27. $remark = Yii::$app->request->post('remark', '');
  28. $apply = ApplyService::getById($id);
  29. if (empty($apply)) {
  30. util::fail('找不到申请记录');
  31. }
  32. if ($apply['status'] != 1) {
  33. util::fail('已经审过了');
  34. }
  35. $connection = Yii::$app->db;
  36. $transaction = $connection->beginTransaction();
  37. try {
  38. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  39. if ($status == 1) {
  40. ApplyService::pass($id);
  41. }
  42. $transaction->commit();
  43. } catch (\Exception $exception) {
  44. $transaction->rollBack();
  45. Yii::info("审核操作报错:" . $exception->getMessage());
  46. util::fail('操作失败');
  47. }
  48. util::complete();
  49. }
  50. }