| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace addons\BusinessActivity\api\modules\v1\controllers;
- use addons\BusinessActivity\common\service\SettingService;
- use addons\BusinessActivity\common\service\SignInService;
- use api\controllers\OnAuthController;
- use Yii;
- class SignInController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [];
- /**
- * @return mixed|null
- */
- public function actionIndex() {
- $data = Yii::$app->request->get();
- if (!Yii::$app->services->validate->validate($data, [
- [['page', 'limit'], 'integer'],
- ])) {
- return $this->error(Yii::$app->services->validate->getErrorMessage());
- }
- $ret = (new SignInService())->page($this->mall_id, $this->user_id);
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- /**
- * 用户签到
- * @return mixed|null
- */
- public function actionSignIn()
- {
- $data = Yii::$app->request->post();
- if (!Yii::$app->services->validate->validate($data, [
- [['id'], 'integer'],
- [['id'], 'required'],
- ])) {
- return $this->error(Yii::$app->services->validate->getErrorMessage());
- }
- $config = (new SettingService())->get($this->mall_id);
- if (empty($config['is_enable'])) return $this->error("插件未启用", [], 999);
- $ret = (new SignInService())->create($this->mall_id, $data['id'], $this->user_id);
- return is_string($ret) ? $this->error($ret) : $this->success('签到成功');
- }
-
- }
|