ApplyController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace pt\controllers;
  3. use biz\sj\classes\MerchantClass;
  4. use bizHd\saas\services\ApplyService;
  5. use common\components\sms;
  6. use common\components\util;
  7. use Yii;
  8. use yii\web\Controller;
  9. class ApplyController extends BaseController
  10. {
  11. //申请列表
  12. public function actionList()
  13. {
  14. $get = Yii::$app->request->get();
  15. $status = $get['status'] ?? 0;
  16. $where = [];
  17. if (!empty($status)) {
  18. $where['status'] = $status;
  19. }
  20. $list = ApplyService::getApplyList($where);
  21. util::success($list);
  22. }
  23. //审核
  24. public function actionCheck()
  25. {
  26. $id = Yii::$app->request->post('id');
  27. $status = Yii::$app->request->post('status', 0);
  28. $remark = Yii::$app->request->post('remark', '');
  29. $apply = ApplyService::getById($id);
  30. if (empty($apply)) {
  31. util::fail('找不到申请记录');
  32. }
  33. if (isset($apply['status']) && $apply['status'] == 2) {
  34. util::fail('已经审过了');
  35. }
  36. $connection = Yii::$app->db;
  37. $transaction = $connection->beginTransaction();
  38. try {
  39. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  40. if ($status == 1) {
  41. ApplyService::pass($id);
  42. }
  43. $transaction->commit();
  44. if ($status == 1) {
  45. $mobile = $apply['mobile'] ?? '';
  46. sms::freeSend($mobile, '恭喜,开店申请审核通过了,登录后请及时修改密码');
  47. }
  48. } catch (\Exception $exception) {
  49. $transaction->rollBack();
  50. Yii::info("审核操作报错:" . $exception->getMessage());
  51. util::fail('操作失败');
  52. }
  53. util::complete();
  54. }
  55. }