<?php

namespace app\controller\api;

use support\Request;

use App\Utils\ApiResponseApp;


use App\model\Dictionary;
use App\model\Message;
use App\model\ExchangeRate;
use app\model\User;
use app\model\UserReward;
use hg\apidoc\annotation as Apidoc;
use support\Db;
use support\Log;

/**
 * @Apidoc\Title("?")
 */

class TextController
{
    protected $noNeedLogin = ['get_projectdetailed', 'get_projectdetailed', 'get_mechanism_list'];

    /**
     * @Apidoc\Title("1.0 手机号在线历史归类函数")
     * @Apidoc\Url("api/text/classifyPhoneOnlineHistory")
     * @Apidoc\Method("POST")
     */
    public function classifyPhoneOnlineHistory(Request $request)
    {
        $result = Db::table('your_table')  // 这里的 'your_table' 应该是你存储用户积分的表名
            ->select('username', Db::raw('SUM(amount) as total_points'))  // 计算每个用户名的积分总数
            ->groupBy('username')  // 按用户名分组
            ->get();
        foreach ($result as $v) {
            $user = User::where('username', $v->username)->first();
            $user->money += $v->total_points;
            $user->save();
            break;
        }
    }
}