Browse Source

对外接口增加用户详情,拆分赠送积分和余额

evoxwht 2 years ago
parent
commit
6ef5e6baa7

+ 70 - 0
crmeb/app/outapi/controller/User.php

@@ -97,6 +97,10 @@ class User extends AuthController
      * 赠送相关
      * @param int $uid
      * @return mixed
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function give($uid)
     {
@@ -114,4 +118,70 @@ class User extends AuthController
         }
         return app('json')->success(100010);
     }
+
+    /**
+     * 获取用户详情
+     * @param $uid
+     * @return \think\Response
+     * @author 吴汐
+     * @email 442384644@qq.com
+     * @date 2023/06/20
+     */
+    public function info($uid)
+    {
+        if (!$uid) return app('json')->fail(100100);
+        return app('json')->success($this->services->userInfo($uid));
+    }
+
+    /**
+     * 赠送余额
+     * @param int $uid
+     * @return mixed
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function giveBalance($uid)
+    {
+        $data = $this->request->postMore([
+            ['money_status', 0],
+            ['money', 0],
+            ['integration_status', 0],
+            ['integration', 0],
+            ['days', 0],
+            ['coupon', 0]
+        ]);
+        if (!$uid) return app('json')->fail(100100);
+        if (!$this->services->otherGive((int)$uid, $data)) {
+            return app('json')->fail(100005);
+        }
+        return app('json')->success(100010);
+    }
+
+    /**
+     * 赠送积分
+     * @param int $uid
+     * @return mixed
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function givePoint($uid)
+    {
+        $data = $this->request->postMore([
+            ['money_status', 0],
+            ['money', 0],
+            ['integration_status', 0],
+            ['integration', 0],
+            ['days', 0],
+            ['coupon', 0]
+        ]);
+        if (!$uid) return app('json')->fail(100100);
+        if (!$this->services->otherGive((int)$uid, $data)) {
+            return app('json')->fail(100005);
+        }
+        return app('json')->success(100010);
+    }
 }

+ 3 - 1
crmeb/app/outapi/route/route.php

@@ -83,9 +83,11 @@ Route::group(function () {
 
             //用户
             Route::get('user/list', 'User/lst')->option(['real_name' => '用户列表']);
+            Route::get('user/info/:uid', 'User/info')->option(['real_name' => '用户详情']);
             Route::post('user', 'User/save')->option(['real_name' => '新增用户']);
             Route::put('user/:uid', 'User/update')->option(['real_name' => '修改用户']);
-            Route::put('user/give/:uid', 'User/give')->option(['real_name' => '赠送积分/金额']);
+            Route::put('user/give_balance/:uid', 'User/giveBalance')->option(['real_name' => '赠送余额']);
+            Route::put('user/give_point/:uid', 'User/givePoint')->option(['real_name' => '赠送积分']);
         })->option(['mark' => 'user', 'mark_name' => '用户']);
 
     })->middleware(AuthTokenMiddleware::class);

+ 22 - 0
crmeb/app/services/user/OutUserServices.php

@@ -82,11 +82,29 @@ class OutUserServices extends BaseServices
         return compact('list', 'count');
     }
 
+    /**
+     * 获取用户详情
+     * @param $uid
+     * @return mixed
+     * @author 吴汐
+     * @email 442384644@qq.com
+     * @date 2023/06/20
+     */
+    public function userInfo($uid)
+    {
+        $fields = ['uid', 'real_name', 'mark', 'nickname', 'avatar', 'phone', 'now_money', 'brokerage_price', 'integral', 'exp', 'sign_num', 'user_type', 'status', 'level',
+            'agent_level', 'spread_open', 'spread_uid', 'spread_time', 'user_type', 'is_promoter', 'pay_count', 'is_ever_level', 'is_money_level', 'overdue_time', 'add_time'];
+        return app()->make(UserServices::class)->get($uid, $fields);
+    }
+
     /**
      * 添加/修改用户
      * @param int $uid
      * @param array $data
      * @return int
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function saveUser(int $uid, array $data): int
     {
@@ -151,6 +169,10 @@ class OutUserServices extends BaseServices
      * @param int $id
      * @param array $data
      * @return bool
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function otherGive(int $id, array $data): bool
     {