| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace addons\Happiness\client\controllers;
- use addons\Happiness\common\service\ClerkService;
- use Yii;
- use Exception;
- class ClerkController extends BaseController
- {
- public $enableCsrfValidation = false;
- //核销员管理
- public function actionIndex()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['user_id', 'page', 'limit'], 'integer'],
- [['keyword'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $get['store_id'] = $this->store_id;
- $list = (new ClerkService(['mall_id' => $this->mall_id]))->getClerkMemberList($get);
- return $this->success('获取成功', $list);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- return $this->render($this->action->id);
- }
- public function actionSearchUser()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['keyword'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $list = (new ClerkService(['mall_id' => $this->mall_id]))->searchUser($get);
- return $this->success('获取成功', $list);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //添加核销员
- public function actionEdit()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- if ($request->isPost) {
- try {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['id', 'user_id'], 'integer'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $post['store_id'] = $this->store_id;
- $res = (new ClerkService(['mall_id' => $this->mall_id]))->addClerk($post);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- }
- //删除核销员
- public function actionDelete()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isPost) {
- try {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['id'], 'integer']
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $res = (new ClerkService(['mall_id' => $this->mall_id]))->deleteClerk($post);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //核销明细
- public function actionClerkLog()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- if ($request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['page', 'limit'], 'integer'],
- [['clerk_id', 'user_id', 'order_no'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $list = (new ClerkService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->storeClerkLog($get);
- return $this->success('获取成功', $list);
- } catch (\Exception $e) {
- $this->error($e->getMessage());
- }
- }
- }
- return $this->render($this->action->id);
- }
- public function actionChangeClerkStatus()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isPost) {
- try {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['id', 'status'], 'integer'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $res = (new ClerkService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]))->changeClerkStatus($post);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
-
- }
|