| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace api\modules\v1\controllers;
- use api\controllers\OnAuthController;
- use common\enums\ClerkEnum;
- use common\enums\StatusEnum;
- use common\globals\GlobalInvoke;
- use common\models\common\ClerkLog;
- use common\models\user\User;
- class ClerkController extends OnAuthController
- {
- public $enableCsrfValidation = false;
- public $modelClass = '';
- public function actionClerk()
- {
- try {
- $request = \Yii::$app->request;
- if ($request->isGet) {
- $params = $request->get();
- $params['method'] = 'get';
- $params['platform'] = $this->platform;
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $result = GlobalInvoke::exec(GlobalInvoke::INVOKE_CLERK, $this->mall_id, $params);
- if (empty($result)) return $this->error('获取数据失败');
- return $this->success('操作成功', $result);
- }
- if ($request->isPost) {
- $params = $request->post();
- $params['method'] = 'post';
- $params['platform'] = $this->platform;
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $result = GlobalInvoke::exec(GlobalInvoke::INVOKE_CLERK, $this->mall_id, $params);
- if (empty($result)) return $this->error('核销失败');
- return $this->success('操作成功', $result);
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- public function actionClerkLog()
- {
- $params = \Yii::$app->request->get();
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['user_id' => $this->user_id];
- $where[] = ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
- $params['where'] = $where;
- $params['order'] = 'id DESC';
- $params['select'] = 'id,mall_id,user_id,name,pic,mall_logo,mall_name,clerk_code,type,extra,created_at';
- $pageData = ClerkLog::getPageLists($params);
- return $this->success('操作成功', $pageData);
- }
- public function actionClerkLogDetail()
- {
- try {
- $params = \Yii::$app->request->get();
- $res = \Yii::$app->services->validate->validate($params, [
- [['clerk_log_id', 'type'], 'required'],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $params['platform'] = $this->platform;
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $result = GlobalInvoke::exec(GlobalInvoke::INVOKE_CLERK_DETAIL, $this->mall_id, $params);
- if (empty($result)) return $this->error('获取数据失败');
- return $this->success('操作成功', $result);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
|