render('index',[ ]); } /** * 打卡申请列表 * @Author: lun * @DateTime: 2023/7/26 0026 9:42 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionApply() { $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','is_pass','limit'], 'integer'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where = []; $where[] = ['=', 'status', StatusEnum::ENABLED]; $where[] = ['=', 'mall_id', $this->mall_id]; !empty($get['user_id']) && $where[] = ['=', 'user_id', $get['user_id']]; isset($get['is_pass']) && $where[] = ['=', 'is_pass', $get['is_pass']]; if (!empty($get['mobile'])) { $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id, 'mobile' => $get['mobile'], 'status' => StatusEnum::ENABLED])->scalar(); if (empty($user_id)) return $this->error('查无此用户!'); $where[] = ['=', 'user_id', $user_id]; } $with = ['user']; $order = 'id desc,created_at desc'; $params = array('where' => $where, 'order'=>$order, 'with' => $with, 'limit' => $get['limit'] ?? 20); $list = ClockinApply::listPage($params, false, true); foreach ($list['list'] as &$item) { $item['pic'] = json_decode($item['pic'], true); } // 获取配置 $config = Yii::$app->services->setting->addons->get($this->mall_id, 'Clockin', 'basic'); $config['default_score'] = json_decode($config['default_score'], true); $this->success('获取成功', compact('list', 'config')); } } else { return $this->render($this->action->id); } } /** * 拒绝申请 * @Author: lun * @DateTime: 2023/7/26 0026 15:26 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|void */ public function actionApplyAgree() { $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params,[ [['id'], 'integer'], [['reward'], 'safe'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 保存 $params['is_pass'] = 1; $res = ClockinApply::changeStatus($this->mall_id, $params); if ($res == false) return $this->error(ClockinApply::getStaticError()); return $this->success('操作成功'); } } /** * 拒绝申请 * @Author: lun * @DateTime: 2023/7/26 0026 15:26 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|void */ public function actionApplyReject() { $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params,[ [['id'], 'integer'], [['reason'], 'string'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 保存 $params['is_pass'] = -1; $res = ClockinApply::changeStatus($this->mall_id, $params); if ($res == false) return $this->error('操作失败:' . ClockinApply::getStaticError()); return $this->success('操作成功'); } } /** * 删除 * @Author: lun * @DateTime: 2023/7/27 0027 15:23 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|void */ public function actionApplyDel() { $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params,[ [['id'], 'integer'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 保存 $params['status'] = -1; $res = ClockinApply::changeStatus($this->mall_id, $params); if ($res == false) return $this->error('操作失败:' . ClockinApply::getStaticError()); return $this->success('操作成功'); } } /** * 获取基础设置 * @Author: lun * @DateTime: 2023/7/26 0026 10:37 * @Copyright: copyright (c) 2021 广东七件事集团 * @return string */ public function actionSetting() { $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isGet) { // 获取配置 $config = Yii::$app->services->setting->addons->get($this->mall_id, 'Clockin', 'basic'); if ($config['seniority']) $config['seniority'] = json_decode($config['seniority'], true); if (!isset($config['is_show_reward_limit'])) $config['is_show_reward_limit'] = 1; if ($config['default_score']){ $config['default_score'] = json_decode($config['default_score'], true); if(empty($config['default_score'] )){ $config['default_score'] = []; } }else{ $config['default_score'] = ['100', '200', '300', '400', '500']; } // 获取会员等级 $levels = UserLevel::getUserListByUpgrade(['mall_id' => $this->mall_id]); array_unshift($levels, ['level' => 0, 'name' => '普通会员']); $this->success('获取成功', compact('config','levels')); } return $this->render($this->action->id); } /** * 基础设置提交 * @Author: lun * @DateTime: 2023/7/26 0026 10:38 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|void */ public function actionSettingSubmit() { $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params,[ [['is_enable','is_seniority','is_reward','reward_limit','upload_limit','is_show_reward_limit'], 'integer'], [['seniority','default_score'], 'safe'], [['reward_limit'], 'double'], [['explain'], 'string'] ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 保存配置 $params['default_score'] = json_encode($params['default_score']); $params['seniority'] = json_encode($params['seniority']); $config = Yii::$app->services->setting->addons->set($this->mall_id, 'Clockin', ['basic' => $params]); $this->success('保存成功', $config); } } /** * 奖励用户 * @Author: lun * @DateTime: 2023/7/27 0027 9:33 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionUser() { $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','limit'], 'integer'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where = []; $where[] = ['=', 'status', StatusEnum::ENABLED]; $where[] = ['=', 'mall_id', $this->mall_id]; !empty($get['user_id']) && $where[] = ['=', 'user_id', $get['user_id']]; if (!empty($get['mobile'])) { $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id, 'mobile' => $get['mobile'], 'status' => StatusEnum::ENABLED])->scalar(); if (empty($user_id)) return $this->error('查无此用户!'); $where[] = ['=', 'user_id', $user_id]; } $with = ['user']; $order = 'id desc,created_at desc'; $params = array('where' => $where, 'order'=>$order, 'with' => $with, 'limit' => $get['limit'] ?? 20); $list = ClockinUser::listPage($params, false, true); $this->success('获取成功', compact('list')); } } else { return $this->render($this->action->id); } } /** * 获取用户奖励记录 * @Author: lun * @DateTime: 2023/7/27 0027 9:35 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|void */ public function actionRewardLogs() { $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isGet) { $get = Yii::$app->request->get(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($get,[ [['user_id','limit'], 'integer'], [['user_id'], 'required'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where = []; $where[] = ['=', 'status', StatusEnum::ENABLED]; $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=', 'user_id', $get['user_id']]; $order = 'id desc,created_at desc'; $params = array('where' => $where, 'order'=>$order, 'limit' => $get['limit'] ?? 20); $list = ClockinRewardLog::listPage($params, false, true); $this->success('获取成功', $list); } } }