quanwei
2025-12-04 12913c1069347ea4b1f6ab87f480da0f8d8c646a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
 
namespace app\api\controller\plus\sign;
 
use app\api\controller\Controller;
use app\api\model\settings\Setting as SettingModel;
use app\api\model\plus\sign\Sign as SignModel;
 
/**
 * 用户签到控制器
 */
class Sign extends Controller
{
    /**
     * 添加用户签到
     */
    public function add()
    {
        $model = new SignModel();
        $msg = $model->add($this->getUser());
        if ($msg != '') {
            return $this->renderSuccess('', compact('msg'));
        }
        return $this->renderError($model->getError() ?: '签到失败,请重试');
    }
 
    /**
     * 签到页面
     */
    public function index()
    {
        $user = $this->getUser();   // 用户信息
        $model = new SignModel();
        $list = $model->getListByUserId($user['user_id']);
 
        //获取签到配置
        $sign_conf = SettingModel::getItem('sign');
 
        $day_arr = [];
        if (isset($sign_conf['reward_data'])) {
            $day_arr = array_column($sign_conf['reward_data'], 'day');
        }
        $arr = [];
        $point = [];
        foreach ($day_arr as $key => $val) {
            if ($day_arr[$key] - $list[1] > 0) {
                array_push($arr, $val - $list[1]);
                $point[$val - $list[1]] = isset($sign_conf['reward_data'][$key]['point'])?$sign_conf['reward_data'][$key]['point']:0;
            }
        }
        return $this->renderSuccess('', compact('list', 'arr', 'point'));
 
    }
 
    /**
     * 获取签到规则
     */
    public function getSign()
    {
        // 获取签到配置
        $sign_conf = SettingModel::getItem('sign');
        $detail = isset($sign_conf['content']) ? $sign_conf['content'] : '';
        return $this->renderSuccess('', compact('detail'));
    }
 
}