www.wdadmin.cn // +---------------------------------------------------------------------- namespace app\api\controller\wdsxh\points; use app\admin\model\wdsxh\points\PointsConfig; use app\api\model\wdsxh\UserWechat; use app\common\controller\Api; use think\Exception; use think\exception\PDOException; use think\exception\ValidateException; class MyPoints extends Api { protected $noNeedLogin = ['']; protected $noNeedRight = ['*']; protected $wechat_id = null; public function _initialize() { parent::_initialize(); $this->wechat_id = (new UserWechat())->where('user_id', $this->auth->id)->value('id'); } /** * Desc 我的积分 * Create on 2025/11/14 * Create by Claude Code */ public function index() { if (!$this->request->isGet()) { $this->error('请求类型错误'); } try { $userWechat = (new UserWechat())->where('id', $this->wechat_id)->find(); if (!$userWechat) { $this->error('用户信息不存在'); } // 获取用户积分 $points = $userWechat['points'] ?? 0; $data = [ 'my_points' => $points, 'points_description' => (new PointsConfig())->where('id', 1)->value('points_description') ?? '', ]; $this->success('请求成功', $data); } catch (ValidateException|PDOException|Exception $e) { $this->error($e->getMessage()); } } }