ApplyController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. $name = $get['name'] ?? '';
  34. $where = [];
  35. if (!empty($status)) {
  36. $where['status'] = $status;
  37. }
  38. if (!empty($name)) {
  39. if (is_numeric($name)) {
  40. $where['mobile'] = ['like', $name];
  41. } else {
  42. $where['name'] = ['like', $name];
  43. }
  44. }
  45. $list = ApplyService::getApplyList($where);
  46. util::success($list);
  47. }
  48. //审核
  49. public function actionCheck()
  50. {
  51. ini_set('memory_limit', '2045M');
  52. set_time_limit(0);
  53. $id = Yii::$app->request->post('id');
  54. $status = Yii::$app->request->post('status', 0);
  55. $remark = Yii::$app->request->post('remark', '');
  56. $apply = ApplyService::getById($id);
  57. if (empty($apply)) {
  58. util::fail('找不到申请记录');
  59. }
  60. if (isset($apply['status']) && $apply['status'] == 2) {
  61. util::fail('已经审过了');
  62. }
  63. if (isset($apply['style']) && $apply['style'] != dict::getDict('ptStyle', 'ghs')) {
  64. util::fail('暂时只支持审核批发商的申请');
  65. }
  66. $connection = Yii::$app->db;
  67. $transaction = $connection->beginTransaction();
  68. try {
  69. ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
  70. if ($status == 1) {
  71. \bizGhs\apply\services\ApplyService::pass($id);
  72. }
  73. $transaction->commit();
  74. if ($status == 1) {
  75. $mobile = $apply['mobile'] ?? '';
  76. $cf = '15280215347';
  77. if (getenv('YII_ENV') == 'production') {
  78. //sms::freeSend($mobile . ',' . $cf, '恭喜,开店申请审核通过了,登录后请及时修改密码,如有疑问请联系 {$var}');
  79. }
  80. }
  81. } catch (\Exception $exception) {
  82. $transaction->rollBack();
  83. Yii::info("审核操作报错:" . $exception->getMessage());
  84. util::fail('操作失败');
  85. }
  86. util::complete();
  87. }
  88. }