65 lines
2.2 KiB
PHP
65 lines
2.2 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | 麦沃德科技赋能开发者,助力中小企业发展
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2017~2024 www.wdadmin.cn All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Wdadmin系统产品软件并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||
// +----------------------------------------------------------------------
|
||
// | Author: MY WORLD Team <bd@maiwd.cn> 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());
|
||
}
|
||
}
|
||
}
|