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); + } /** * 转账函数 */