ManagerController.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace addons\Purchase\backend\controllers;
  3. use addons\Purchase\common\models\PurchaseManager;
  4. use common\enums\StatusEnum;
  5. use Yii;
  6. /**
  7. * 默认控制器
  8. *
  9. * Class DefaultController
  10. * @package addons\Purchase\backend\controllers
  11. */
  12. class ManagerController extends BaseController
  13. {
  14. public $enableCsrfValidation = false;
  15. /**
  16. * 会员列表
  17. *
  18. * @return string
  19. */
  20. public function actionIndex()
  21. {
  22. $retuest = Yii::$app->request;
  23. if ($retuest->isAjax) {
  24. if ($retuest->isGet) {
  25. $get = Yii::$app->request->get();
  26. // 检查提交的参数
  27. $res = Yii::$app->services->validate->validate($get,[
  28. [['user_id','mobile'], 'integer'],
  29. [['manager_status'], 'string']
  30. ]);
  31. if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  32. $where[] = ['=', 'mall_id', $this->mall_id];
  33. $is_poss = $get['manager_status'] === 'normal' ? StatusEnum::ENABLED : StatusEnum::DISABLED;
  34. $where[] = ['=', 'is_poss', $is_poss];
  35. !empty($get['user_id']) && $where[] = ['=', 'user_id', $get['user_id']];
  36. !empty($get['mobile']) && $where[] = ['=', 'mobile', $get['mobile']];
  37. $where[] = ['=', 'status', StatusEnum::ENABLED];
  38. $with = ['user'];
  39. $order = 'created_at desc';
  40. $params = array('where' => $where, 'order'=>$order, 'with' => $with, 'limit' => $get['limit']);
  41. $list = PurchaseManager::listPage($params, false, true);
  42. echo PurchaseManager::getStaticError();
  43. $this->success('获取成功', $list);
  44. }
  45. } else {
  46. return $this->render($this->action->id, ['managerStatus' => 'normal']);
  47. }
  48. }
  49. /**
  50. * @notes:审核列表
  51. * @return string
  52. * @author: lun
  53. * @Time: 2022/10/22 18:18
  54. */
  55. public function actionExamine()
  56. {
  57. return $this->render('index', ['managerStatus' => 'examine']);
  58. }
  59. /**
  60. * @notes:同意、拒绝、删除
  61. * @return mixed|void|null
  62. * @author: lun
  63. * @Time: 2022/10/24 13:59
  64. */
  65. public function actionHandle()
  66. {
  67. $retuest = Yii::$app->request;
  68. if ($retuest->isAjax) {
  69. if ($retuest->isPost) {
  70. $post = Yii::$app->request->post();
  71. // 检查提交的参数
  72. $res = Yii::$app->services->validate->validate($post,[
  73. [['id','status'], 'required'],
  74. [['id','status','is_poss'], 'integer'],
  75. [['reason'], 'string'],
  76. ]);
  77. if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  78. $res = PurchaseManager::handle($this->mall_id, $post);
  79. if ($res === false) return $this->error('操作失败:' . PurchaseManager::getStaticError());
  80. return $this->success('操作成功');
  81. }
  82. }
  83. }
  84. }