| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace addons\Purchase\backend\controllers;
- use addons\Purchase\common\models\PurchaseManager;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\Purchase\backend\controllers
- */
- class ManagerController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 会员列表
- *
- * @return string
- */
- public function actionIndex()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isGet) {
- $get = Yii::$app->request->get();
- // 检查提交的参数
- $res = Yii::$app->services->validate->validate($get,[
- [['user_id','mobile'], 'integer'],
- [['manager_status'], 'string']
- ]);
- if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where[] = ['=', 'mall_id', $this->mall_id];
- $is_poss = $get['manager_status'] === 'normal' ? StatusEnum::ENABLED : StatusEnum::DISABLED;
- $where[] = ['=', 'is_poss', $is_poss];
- !empty($get['user_id']) && $where[] = ['=', 'user_id', $get['user_id']];
- !empty($get['mobile']) && $where[] = ['=', 'mobile', $get['mobile']];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $with = ['user'];
- $order = 'created_at desc';
- $params = array('where' => $where, 'order'=>$order, 'with' => $with, 'limit' => $get['limit']);
- $list = PurchaseManager::listPage($params, false, true);
- echo PurchaseManager::getStaticError();
- $this->success('获取成功', $list);
- }
- } else {
- return $this->render($this->action->id, ['managerStatus' => 'normal']);
- }
- }
- /**
- * @notes:审核列表
- * @return string
- * @author: lun
- * @Time: 2022/10/22 18:18
- */
- public function actionExamine()
- {
- return $this->render('index', ['managerStatus' => 'examine']);
- }
- /**
- * @notes:同意、拒绝、删除
- * @return mixed|void|null
- * @author: lun
- * @Time: 2022/10/24 13:59
- */
- public function actionHandle()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isPost) {
- $post = Yii::$app->request->post();
- // 检查提交的参数
- $res = Yii::$app->services->validate->validate($post,[
- [['id','status'], 'required'],
- [['id','status','is_poss'], 'integer'],
- [['reason'], 'string'],
- ]);
- if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $res = PurchaseManager::handle($this->mall_id, $post);
- if ($res === false) return $this->error('操作失败:' . PurchaseManager::getStaticError());
- return $this->success('操作成功');
- }
- }
- }
- }
|