ApplyController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace pt\controllers;
  3. use bizHd\saas\services\ApplyService;
  4. use common\components\dict;
  5. use common\components\sms;
  6. use common\components\util;
  7. use Yii;
  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 (isset($apply['status']) && $apply['status'] == 2) {
  33. util::fail('已经审过了');
  34. }
  35. if (isset($apply['style']) && $apply['style'] != dict::getDict('ptStyle', 'ghs')) {
  36. util::fail('暂时只支持审核批发商的申请');
  37. }
  38. $connection = Yii::$app->db;
  39. $transaction = $connection->beginTransaction();
  40. try {
  41. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  42. if ($status == 1) {
  43. \bizGhs\apply\services\ApplyService::pass($id);
  44. }
  45. $transaction->commit();
  46. if ($status == 1) {
  47. $mobile = $apply['mobile'] ?? '';
  48. $cf = '15280215347';
  49. sms::freeSend($mobile . ',' . $cf, '恭喜,开店申请审核通过了,登录后请及时修改密码,如有疑问请联系 {$var}');
  50. }
  51. } catch (\Exception $exception) {
  52. $transaction->rollBack();
  53. Yii::info("审核操作报错:" . $exception->getMessage());
  54. util::fail('操作失败');
  55. }
  56. util::complete();
  57. }
  58. }