ApplyController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. $cf = '15280215347';
  47. sms::freeSend($mobile. ',' . $cf , '恭喜,开店申请审核通过了,登录后请及时修改密码,如有疑问请联系 {$var}');
  48. }
  49. } catch (\Exception $exception) {
  50. $transaction->rollBack();
  51. Yii::info("审核操作报错:" . $exception->getMessage());
  52. util::fail('操作失败');
  53. }
  54. util::complete();
  55. }
  56. }