Browse Source

用户充值记录增加账户属性隔离

zqwang 1 year ago
parent
commit
e9a6cd4174

+ 6 - 1
modules/Channel/Http/Controllers/OrdersController.php

@@ -31,7 +31,12 @@ class OrdersController extends CatchController
     {
         $param = $request->all();
         $userContext = $this->getUserContext(null);
-
+        if (getProp($param, 'puser_id')) {
+            $param['puser_id'] = $param['puser_id'];
+        }
+        if (getProp($param, 'user_id')) {
+            $param['user_id'] = $param['user_id'];
+        }
         // 公司账户处理
         if ($userContext['loginUserRoles']->contains('company')) {
             $param['puser_id'] = $userContext['operateUser']->id;

+ 12 - 2
modules/Channel/Http/Controllers/WechatMinprogramUserController.php

@@ -13,10 +13,11 @@ use Catch\Base\CatchController;
 use Illuminate\Http\Request;
 use Catch\Exceptions\FailedException;
 use Modules\Channel\Services\WechatMinprogram\WechatMinprogramUserService;
+use Modules\User\Http\Controllers\UserTrait;
 
 class WechatMinprogramUserController extends CatchController
 {
-
+    use UserTrait;
     /***
      *  获取用户信息
      * name: userInfoDetail
@@ -49,8 +50,17 @@ class WechatMinprogramUserController extends CatchController
         if ($uid <  1){
             $this->errorMsg("用户参数必填");
         }
+        $userContext = $this->getUserContext(null);
+        // 公司账户处理
+        if ($userContext['loginUserRoles']->contains('company')) {
+            $param['puser_id'] = $userContext['operateUser']->id;
+        }
 
-        return WechatMinprogramUserService::getUserOrderList($uid);
+        // 投手处理
+        if ($userContext['loginUserRoles']->contains('optimizer')) {
+            $param['user_id'] = $userContext['operateUser']->id;
+        }
+        return WechatMinprogramUserService::getUserOrderList($uid,$param);
 
     }
 

+ 10 - 3
modules/Channel/Services/WechatMinprogram/WechatMinprogramUserService.php

@@ -83,7 +83,7 @@ class WechatMinprogramUserService
      * @param int $uid
      * date 2023/05/19 14:57
      */
-    public static function getUserOrderList(int $uid)
+    public static function getUserOrderList(int $uid, $param)
     {
         $pool = [
             'MONTH' => '包月',
@@ -93,8 +93,15 @@ class WechatMinprogramUserService
         $list = Order::join('pay_products', 'pay_products.id', '=', 'orders.pay_product_id')
             ->select('orders.price', 'orders.trade_no', "orders.video_id", 'orders.pay_end_at', 'pay_products.type', 'pay_products.price as product_price', 'pay_products.given')
             ->where('orders.status', 'PAID')
-            ->where('orders.uid', $uid)
-            ->orderBy('orders.id', 'desc')
+            ->where('orders.uid', $uid);
+        if (getProp($param, 'puser_id', 0) > 0) {
+            $list->where('orders.puser_id', $param['puser_id']);
+        }
+        if (getProp($param, 'user_id', 0) > 0) {
+            $list->where('orders.user_id', $param['user_id']);
+        }
+        
+        $list->orderBy('orders.id', 'desc')
             ->paginate(15);
 
         foreach ($list as $item) {