ApplyController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace addons\Agent\backend\controllers;
  3. use addons\Agent\common\models\AgentApply;
  4. use common\enums\RabbitMqEnum;
  5. use Yii;
  6. class ApplyController extends BaseController{
  7. public $enableCsrfValidation = false;
  8. /**
  9. * Notes:列表
  10. * User: LD
  11. * Date: 2024/4/11
  12. * Time: 10:55
  13. */
  14. public function actionIndex(){
  15. if (\Yii::$app->request->isAjax) {
  16. if (\Yii::$app->request->isGet) {
  17. $params = \Yii::$app->request->get();
  18. $get['mall_id'] = $this->mall_id;
  19. $params['where'] = [['mall_id'=>$this->mall_id]];
  20. $params['with'] = ['user'];
  21. $params['order'] = 'id desc';
  22. $params['limit'] = 10;
  23. $pageData = AgentApply::listPage($params, false);
  24. if ($pageData === false) return $this->error(AgentApply::getStaticError());
  25. return $this->success('操作成功', $pageData);
  26. }
  27. }
  28. return $this->render('index', []);
  29. }
  30. /**
  31. * Notes:审核
  32. * User: LD
  33. * Date: 2024/4/11
  34. * Time: 14:04
  35. * @return mixed|void
  36. */
  37. public function actionCheck()
  38. {
  39. if (\Yii::$app->request->isAjax) {
  40. if (\Yii::$app->request->isPost) {
  41. $params = \Yii::$app->request->post();
  42. $res = Yii::$app->services->validate->validate($params, [
  43. [['id', 'check_status'], 'required'],
  44. [['check_remark'], 'safe'],
  45. ]);
  46. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  47. $params['mall_id'] = $this->mall_id;
  48. if ($params['check_status'] == AgentApply::CHECK_STATUS_FAIL && empty($params['check_remark'])) return $this->error('请填写审核不通过的原因');
  49. $res = AgentApply::setData($params);
  50. if ($res === false) return $this->error(AgentApply::getStaticError());
  51. if($params['check_status'] == AgentApply::CHECK_STATUS_SUCCESS){
  52. //推送队列进行升级
  53. \Yii::$app->services->rabbitMq->push(RabbitMqEnum::EXCHANGE_TASK, RabbitMqEnum::TASK_QUEUE, ['mall_id' => $this->mall_id, 'user_id' => $res->user_id], AgentApply::class, 'upgradeLevel');
  54. }
  55. return $this->success('操作成功');
  56. }
  57. }
  58. }
  59. }