feat: 添加 TextController,实现手机号在线历史归类功能
This commit is contained in:
parent
2e4e9a9e31
commit
d85ae3931e
|
@ -0,0 +1,45 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue