From ffdd451b1d9bccf511e2da8a1446aedc50b6c713 Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Fri, 21 Feb 2025 17:31:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=87=91=E9=A2=9D=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/api/v1/JobuserController.php | 33 ++++++++++++++++--- app/dao/UserRewardDao.php | 7 ++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/controller/admin/api/v1/JobuserController.php b/app/controller/admin/api/v1/JobuserController.php index ee076bb..f10717b 100644 --- a/app/controller/admin/api/v1/JobuserController.php +++ b/app/controller/admin/api/v1/JobuserController.php @@ -3,6 +3,7 @@ namespace app\controller\admin\api\v1; use app\dao\UserDao; +use app\dao\UserRewardDao; use support\Request; use App\Utils\ApiResponse; use App\model\Admin; @@ -186,7 +187,7 @@ class JobuserController // 获取请求数据 $data = $request->post(); - $user=User::where('username',$data['username'])->first(); + $user = User::where('username', $data['username'])->first(); // 查询用户的手机号 $UserPhone = UserPhone::where('user_id', $user->id)->get(); @@ -199,12 +200,36 @@ class JobuserController // 将手机号和总时间添加到结果数组中 $userPhonesWithTime[] = [ 'phone' => $v->phone, - 'total_time' => floor($time/60) + 'total_time' => floor($time / 60) ]; } - $res['user']=$user; - $res['userPhonesWithTime']=$userPhonesWithTime; + $res['user'] = $user; + $res['userPhonesWithTime'] = $userPhonesWithTime; // 返回计算结果 return ApiResponse::success(200, $res); } + /** + * @Apidoc\Title("1.0 增减用户积分") + * 减法传递 负数 正数增加 + * @Apidoc\Url("admin/api/v1/Jobuser/add_money") + * @Apidoc\Method("POST") + * @Apidoc\Param("id", type="int",require=true, desc="用户id") + * @Apidoc\Param("money", type="int",require=true, desc="金额") + * @Apidoc\Param("memo", type="string",require=true, desc="备注") + */ + public function add_money(Request $request) + { + // 获取请求数据 + $data = $request->post(); + ///用户id + $user_id = $data['id']; + //金额 + $money = $data['money']; + //备注 + $memo = $data['memo']; + UserRewardDao::sing($user_id, 30); + UserRewardDao::adjust($user_id, $money, $memo); + // 返回计算结果 + return ApiResponse::success(200, []); + } } diff --git a/app/dao/UserRewardDao.php b/app/dao/UserRewardDao.php index 79d5f71..c919718 100644 --- a/app/dao/UserRewardDao.php +++ b/app/dao/UserRewardDao.php @@ -53,6 +53,13 @@ class UserRewardDao { self::base($userid, 7, $money, '签到'); } + /** + * 人工调整 + */ + public static function adjust($userid, $money,$memo) + { + self::base($userid, 2, $money, $memo); + } /** * 转账函数 */