ApplyController.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace pt\controllers;
  3. use bizGhs\apply\classes\ApplyClass;
  4. use bizHd\saas\services\ApplyService;
  5. use common\components\dict;
  6. use common\components\sms;
  7. use common\components\util;
  8. use Yii;
  9. class ApplyController extends BaseController
  10. {
  11. //修改全品和单品 ssh 20240416
  12. public function actionChangeAll()
  13. {
  14. $get = Yii::$app->request->get();
  15. $id = $get['id'] ?? 0;
  16. $apply = ApplyClass::getById($id, true);
  17. if (empty($apply)) {
  18. util::fail('没有找到申请记录');
  19. }
  20. if ($apply->status != 1) {
  21. util::fail('不是审核状态');
  22. }
  23. $new = $apply->all == 1 ? 0 : 1;
  24. $apply->all = $new;
  25. $apply->save();
  26. util::complete();
  27. }
  28. //申请列表
  29. public function actionList()
  30. {
  31. $get = Yii::$app->request->get();
  32. $status = $get['status'] ?? 0;
  33. $where = [];
  34. if (!empty($status)) {
  35. $where['status'] = $status;
  36. }
  37. $list = ApplyService::getApplyList($where);
  38. util::success($list);
  39. }
  40. //审核
  41. public function actionCheck()
  42. {
  43. ini_set('memory_limit', '2045M');
  44. set_time_limit(0);
  45. $id = Yii::$app->request->post('id');
  46. $status = Yii::$app->request->post('status', 0);
  47. $remark = Yii::$app->request->post('remark', '');
  48. $apply = ApplyService::getById($id);
  49. if (empty($apply)) {
  50. util::fail('找不到申请记录');
  51. }
  52. if (isset($apply['status']) && $apply['status'] == 2) {
  53. util::fail('已经审过了');
  54. }
  55. if (isset($apply['style']) && $apply['style'] != dict::getDict('ptStyle', 'ghs')) {
  56. util::fail('暂时只支持审核批发商的申请');
  57. }
  58. $connection = Yii::$app->db;
  59. $transaction = $connection->beginTransaction();
  60. try {
  61. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  62. if ($status == 1) {
  63. \bizGhs\apply\services\ApplyService::pass($id);
  64. }
  65. $transaction->commit();
  66. if ($status == 1) {
  67. $mobile = $apply['mobile'] ?? '';
  68. $cf = '15280215347';
  69. if (getenv('YII_ENV') == 'production') {
  70. //sms::freeSend($mobile . ',' . $cf, '恭喜,开店申请审核通过了,登录后请及时修改密码,如有疑问请联系 {$var}');
  71. }
  72. }
  73. } catch (\Exception $exception) {
  74. $transaction->rollBack();
  75. Yii::info("审核操作报错:" . $exception->getMessage());
  76. util::fail('操作失败');
  77. }
  78. util::complete();
  79. }
  80. }