ApplyController.php 2.0 KB

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