- 18 张公共表更名(addon/attachment/configure/links/spider_log/spider_stat/sms/notice/ad/task/prop/medal/help/card -> common_*,member_wallets->member_wallet,score_rule/score_log -> member_*,addon_config->common_addonconf),模型全部对齐新表名,Db 直引用清零 - Attachment 模型补 表名绑定,修复富文本上传查 wxapp_attachment 1146 隐患 - install.sql + 迁移 SQL:backend_admin/backend_role delete_at 默认 0,修复软删除(NULL != 0)误过滤导致后台菜单为空 - AppService::boot() 支持插件 info.php 声明 commands 自动注册插件命令(psr-4 自动加载,坏类名自动跳过) - 各插件(haonav/mqttbroker/wxchat/articles/blog/forum 等)字段与配置同步调整 - 框架版本 1.1.0 -> 1.1.1
113 lines
3.2 KiB
PHP
113 lines
3.2 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ywxapp<admin@ywxapp.cn>
|
|
// +----------------------------------------------------------------------
|
|
declare(strict_types=1);
|
|
|
|
namespace app\member\controller;
|
|
|
|
use ywxapp\model\Task as TaskModel;
|
|
use ywxapp\controller\MemberBase;
|
|
use ywxapp\model\BaseModel;
|
|
use think\facade\Db;
|
|
|
|
/**
|
|
* 会员任务中心
|
|
*/
|
|
class Task extends MemberBase
|
|
{
|
|
protected $noNeedLogin = [];
|
|
protected $noNeedVerify = ['*'];
|
|
|
|
protected function initialize() {}
|
|
|
|
/**
|
|
* 任务中心列表页
|
|
*/
|
|
public function index()
|
|
{
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 任务列表(AJAX):返回启用任务 + 当前用户已领取状态
|
|
*/
|
|
public function list()
|
|
{
|
|
$uid = (int) ($this->auth->model->uid ?? 0);
|
|
$tasks = TaskModel::getEnabledList();
|
|
$claimed = TaskModel::getClaimedTaskIds($uid);
|
|
|
|
$list = [];
|
|
foreach ($tasks as $t) {
|
|
$t = $t->toArray();
|
|
$list[] = [
|
|
'id' => $t['id'],
|
|
'title' => $t['title'],
|
|
'description' => $t['description'],
|
|
'reward_type' => $t['reward_type'],
|
|
'reward_type_text' => TaskModel::getRewardTypeText((int) $t['reward_type']),
|
|
'reward_num' => $t['reward_num'],
|
|
'claimed' => in_array($t['id'], $claimed, true),
|
|
];
|
|
}
|
|
$this->result->success($list);
|
|
}
|
|
|
|
/**
|
|
* 领取任务奖励(AJAX)
|
|
*/
|
|
public function claim()
|
|
{
|
|
if (! $this->request->isPost()) {
|
|
$this->result->error('请求方式错误');
|
|
}
|
|
$uid = (int) ($this->auth->model->uid ?? 0);
|
|
$taskId = (int) $this->request->param('task_id', 0);
|
|
if ($uid <= 0) {
|
|
$this->result->error('请先登录会员中心');
|
|
}
|
|
if ($taskId <= 0) {
|
|
$this->result->error('任务参数错误');
|
|
}
|
|
[$ok, $msg] = TaskModel::claim($uid, $taskId);
|
|
if ($ok) {
|
|
$this->result->success([], $msg);
|
|
}
|
|
$this->result->error($msg);
|
|
}
|
|
|
|
/**
|
|
* 我的道具页
|
|
*/
|
|
public function myProp()
|
|
{
|
|
return $this->view->fetch('task/myprop');
|
|
}
|
|
|
|
/**
|
|
* 我的道具列表(AJAX)
|
|
*/
|
|
public function myPropList()
|
|
{
|
|
$uid = (int) ($this->auth->model->uid ?? 0);
|
|
\ywxapp\model\CommonTask::ensureSchema(); // 确保 user_prop 关联表已就绪
|
|
if ($uid <= 0) {
|
|
$this->result->error('请先登录');
|
|
}
|
|
$list = Db::name('member_prop')
|
|
->alias('up')
|
|
->join('common_prop p', 'p.id = up.prop_id', 'left')
|
|
->where('up.uid', $uid)
|
|
->field('up.id, up.prop_id, up.num, up.create_at, p.title, p.icon')
|
|
->order('up.create_at', 'desc')
|
|
->select()
|
|
->toArray();
|
|
$this->result->success($list);
|
|
}
|
|
}
|