hrjy 2 anos atrás
pai
commit
f59238f8b1

+ 38 - 0
app/admin/controller/user/User.php

@@ -790,6 +790,44 @@ class User extends AuthController
         return Json::successful(UserModel::getSpreadList($uid, (int)$page, (int)$limit));
     }
 
+    /*
+     * 获取某个用户的推广下线
+     * */
+    public function getSpreadList1($uid, $page = 1, $limit = 20)
+    {
+        $list = \app\admin\model\user\User::where('spread_uid',$uid)->field('uid,nickname,now_money,integral,add_time')
+            ->order('uid desc')->page((int)$page, (int)$limit)->select();
+        count($list) && $list = $list->toArray();
+        foreach ($list as &$item) {
+            $item['price'] = StoreOrder::where('uid', $item['uid'])->where('paid', 1)->sum('pay_price');
+            $item['count'] = StoreOrder::where('uid', $item['uid'])->where('paid', 1)->sum('total_num');
+            $item['add_time'] = date('Y-m-d H', $item['add_time']);
+        }
+        return Json::successful($list);
+    }
+
+    /*
+     * 获取某个用户的推广下线
+     * */
+    public function getSpreadList2($uid, $page = 1, $limit = 20)
+    {
+        $uids = \app\admin\model\user\User::where('spread_uid', $uid)->column('uid');
+        if (count($uids) > 0){
+            $list = \app\admin\model\user\User::where('spread_uid', 'in', $uids)->field('uid,nickname,now_money,integral,add_time')
+                ->order('uid desc')->page((int)$page, (int)$limit)->select();
+        }else{
+            $list = [];
+        }
+
+        count($list) > 0 ? $list = $list->toArray() : $list = [];
+        foreach ($list as &$item) {
+            $item['price'] = StoreOrder::where('uid', $item['uid'])->where('paid', 1)->sum('pay_price');
+            $item['count'] = StoreOrder::where('uid', $item['uid'])->where('paid', 1)->sum('total_num');
+            $item['add_time'] = date('Y-m-d H', $item['add_time']);
+        }
+        return Json::successful($list);
+    }
+
     /**
      * 获取某用户的订单列表
      */

+ 7 - 2
app/admin/model/user/User.php

@@ -757,8 +757,11 @@ class User extends BaseModel
             ->where('type', 'in', 'system_add,pay_product,extract,pay_product_refund,system_sub')
             ->count();
         $coupon_count = StoreCouponUser::where('uid', $uid)->count();
-        $spread_count = self::where('spread_uid', $uid)->count();
-        return compact('order_count', 'integral_count', 'sign_count', 'balanceChang_count', 'coupon_count', 'spread_count');
+        $spread_count = count(get_downline(self::select(), $uid));
+        $spread_count1 = self::where('spread_uid',$uid)->count();
+        $uids = self::where('spread_uid',$uid)->column('uid');
+        $spread_count2 = count($uids) > 0 ?self::where('spread_uid', 'in', $uids)->count() : 0;
+        return compact('order_count', 'integral_count', 'sign_count', 'balanceChang_count', 'coupon_count', 'spread_count', 'spread_count1', 'spread_count2');
     }
 
     /*
@@ -1161,6 +1164,8 @@ class User extends BaseModel
             ->order('uid desc')->page((int)$page, (int)$limit)->select();
         count($list) && $list = $list->toArray();
         foreach ($list as &$item) {
+            $item['price'] = StoreOrder::where('uid', $item['uid'])->where('paid', 1)->sum('pay_price');
+            $item['count'] = StoreOrder::where('uid', $item['uid'])->where('paid', 1)->sum('total_num');
             $item['add_time'] = date('Y-m-d H', $item['add_time']);
         }
         return $list;

+ 116 - 2
app/admin/view/user/user/see.php

@@ -89,6 +89,8 @@
                             <li>持有优惠劵</li>
                             <li>余额变动记录</li>
                             <li>推广下线明细</li>
+                            <li>推广一级</li>
+                            <li>推广二级</li>
                         </ul>
                         <div class="layui-tab-content" id="content">
                             <div class="layui-tab-item layui-show">
@@ -247,6 +249,8 @@
                                         <th>昵称</th>
                                         <th>余额</th>
                                         <th>积分</th>
+                                        <th>消费</th>
+                                        <th>购买数量</th>
                                         <th>加入时间</th>
                                     </tr>
                                     </thead>
@@ -260,9 +264,11 @@
                                         </td>
                                         <td>{{item.now_money}}</td>
                                         <td>{{item.integral}}</td>
+                                        <td>{{item.price}}</td>
+                                        <td>{{item.count}}</td>
                                         <td>{{item.add_time}}</td>
                                     </tr>
-                                    <tr v-show="balanceChangList.length<=0" style="text-align: center">
+                                    <tr v-show="SpreadList.length<=0" style="text-align: center">
                                         <td colspan="4">暂无数据</td>
                                     </tr>
                                     </tbody>
@@ -270,6 +276,76 @@
                                 <div ref="spread_page" v-show="count.spread_count > limit" style="text-align: right;"></div>
                             </div>
                             <!--end-->
+                            <!--推广人-->
+                            <div class="layui-tab-item">
+                                <table class="layui-table" v-cloak="">
+                                    <thead>
+                                    <tr>
+                                        <th>昵称</th>
+                                        <th>余额</th>
+                                        <th>积分</th>
+                                        <th>消费</th>
+                                        <th>购买数量</th>
+                                        <th>加入时间</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr v-for="item in SpreadList1">
+                                        <td>
+                                            {{item.nickname}}
+                                            <p v-show="item.is_vip">
+                                                <span class="layui-badge layui-bg-orange" v-text="item.vip_name"></span>
+                                            </p>
+                                        </td>
+                                        <td>{{item.now_money}}</td>
+                                        <td>{{item.integral}}</td>
+                                        <td>{{item.price}}</td>
+                                        <td>{{item.count}}</td>
+                                        <td>{{item.add_time}}</td>
+                                    </tr>
+                                    <tr v-show="SpreadList1.length<=0" style="text-align: center">
+                                        <td colspan="4">暂无数据</td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                                <div ref="spread_page1" v-show="count.spread_count1 > limit" style="text-align: right;"></div>
+                            </div>
+                            <!--end-->
+                            <!--推广人-->
+                            <div class="layui-tab-item">
+                                <table class="layui-table" v-cloak="">
+                                    <thead>
+                                    <tr>
+                                        <th>昵称</th>
+                                        <th>余额</th>
+                                        <th>积分</th>
+                                        <th>消费</th>
+                                        <th>购买数量</th>
+                                        <th>加入时间</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr v-for="item in SpreadList2">
+                                        <td>
+                                            {{item.nickname}}
+                                            <p v-show="item.is_vip">
+                                                <span class="layui-badge layui-bg-orange" v-text="item.vip_name"></span>
+                                            </p>
+                                        </td>
+                                        <td>{{item.now_money}}</td>
+                                        <td>{{item.integral}}</td>
+                                        <td>{{item.price}}</td>
+                                        <td>{{item.count}}</td>
+                                        <td>{{item.add_time}}</td>
+                                    </tr>
+                                    <tr v-show="SpreadList2.length<=0" style="text-align: center">
+                                        <td colspan="4">暂无数据</td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                                <div ref="spread_page2" v-show="count.spread_count1 > limit" style="text-align: right;"></div>
+                            </div>
+                            <!--end-->
                         </div>
                     </div>
                 </div>
@@ -293,6 +369,8 @@
                 CouponsList:[],
                 balanceChangList:[],
                 SpreadList:[],
+                SpreadList1:[],
+                SpreadList2:[],
                 count:count,
                 page:{
                     order_page:1,
@@ -301,6 +379,8 @@
                     copons_page:1,
                     balancechang_page:1,
                     spread_page:1,
+                    spread_page1:1,
+                    spread_page2:1,
                 },
             },
             watch:{
@@ -321,12 +401,24 @@
                 },
                 'page.spread_page':function () {
                     this.getSpreadList();
-                }
+                },
+                'page.spread_page1':function () {
+                    this.getSpreadList1();
+                },
+                'page.spread_page2':function () {
+                    this.getSpreadList2();
+                },
             },
             methods:{
                 getSpreadList:function(){
                     this.request('getSpreadList',this.page.spread_page,'SpreadList');
                 },
+                getSpreadList1:function(){
+                    this.request('getSpreadList1',this.page.spread_page1,'SpreadList1');
+                },
+                getSpreadList2:function(){
+                    this.request('getSpreadList2',this.page.spread_page2,'SpreadList2');
+                },
                 getOneorderList:function () {
                     this.request('getOneorderList',this.page.order_page,'orderList');
                 },
@@ -356,6 +448,8 @@
                 this.getOneCouponsList();
                 this.getOneBalanceChangList();
                 this.getSpreadList();
+                this.getSpreadList1();
+                this.getSpreadList2();
                 var that=this;
                 layList.laypage.render({
                     elem: that.$refs.page_order
@@ -412,6 +506,26 @@
                         that.page.spread_page=obj.curr;
                     }
                 });
+
+                layList.laypage.render({
+                    elem: that.$refs.spread_page1
+                    ,count:that.count.spread_count1
+                    ,limit:that.limit
+                    ,theme: '#1E9FFF',
+                    jump:function(obj){
+                        that.page.spread_page1 = obj.curr;
+                    }
+                });
+
+                layList.laypage.render({
+                    elem: that.$refs.spread_page2
+                    ,count:that.count.spread_count2
+                    ,limit:that.limit
+                    ,theme: '#1E9FFF',
+                    jump:function(obj){
+                        that.page.spread_page2 =obj.curr;
+                    }
+                });
             }
         });
     });