hrjy 2 years ago
parent
commit
083c3ce9f9

+ 4 - 0
app/admin/controller/ump/UserPoint.php

@@ -3,6 +3,7 @@
 namespace app\admin\controller\ump;
 
 use app\admin\controller\AuthController;
+use app\admin\model\user\UserBill;
 use crmeb\services\UtilService as Util;
 use app\admin\model\user\UserPoint AS UserPointModel;
 use think\facade\Route as Url;
@@ -27,6 +28,7 @@ class UserPoint extends AuthController
 //            'song_point'=>UserBill::where(['category'=>'integral','type'=>'sign'])->group('uid')->sum('number'),
             'is_layui' => true,
             'year' => get_month(),
+            'title' => UserBill::where('category', 'integral')->column('title')
         ]);
         return $this->fetch();
     }
@@ -49,6 +51,7 @@ class UserPoint extends AuthController
             ['nickname', ''],
             ['page', 1],
             ['limit', 10],
+            ['title']
         ]);
         return JsonService::successlayui(UserPointModel::getpointlist($where));
     }
@@ -60,6 +63,7 @@ class UserPoint extends AuthController
             ['start_time', ''],
             ['end_time', ''],
             ['nickname', ''],
+            ['title']
         ]);
         UserPointModel::SaveExport($where);
     }

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

@@ -311,6 +311,7 @@ class User extends AuthController
             ['sex', ''],
             ['level', ''],
             ['group_id', ''],
+            ['fl']
         ]);
         return Json::successlayui(UserModel::getUserList($where));
     }
@@ -773,6 +774,38 @@ class User extends AuthController
         return Json::successful(UserModel::getSpreadList($uid, (int)$page, (int)$limit));
     }
 
+    /*
+     * 获取某个用户的推广下线
+     * */
+    public function getSpread($uid, $page = 1, $limit = 20)
+    {
+        $uid = \app\models\user\User::where('spread_uid', $uid)->column('uid');
+        if (count($uid) > 0){
+            $list = \app\admin\model\user\User::where('spread_uid', 'in',$uid)->field('uid,nickname,now_money,integral,white_integral,add_time')
+                ->order('uid desc')->page((int)$page, (int)$limit)->select();
+            count($list) && $list = $list->toArray();
+            foreach ($list as &$item) {
+                $item['add_time'] = date('Y-m-d H', $item['add_time']);
+            }
+            return Json::successful($list);
+        }else{
+            return Json::successful([]);
+        }
+
+    }
+
+    /*
+    * 获取某个用户的推广下线
+    * */
+    public function getSpreadSx($uid, $page = 1, $limit = 20)
+    {
+        $user = \app\admin\model\user\User::select();
+        $list = get_downline_admin($user ,$uid);
+        foreach ($list as &$item) {
+            $item['add_time'] = date('Y-m-d H', $item['add_time']);
+        }
+        return Json::successful($list);
+    }
     /**
      * 获取某用户的订单列表
      */

+ 11 - 3
app/admin/model/user/User.php

@@ -143,6 +143,10 @@ class User extends BaseModel
     public static function getUserList($where)
     {
         $model = self::setWherePage(self::setWhere($where), $where, ['w.sex', 'w.province', 'w.city', 'u.status', 'u.is_promoter'], ['u.nickname', 'u.uid', 'u.phone']);
+        if ($where['fl'] == 1){
+            $model = $model->where('white_integral', '>', 0);
+            $where[] = ['white_integral', '>', 0];
+        }
         $list = $model->alias('u')
             ->join('WechatUser w', 'u.uid=w.uid')
             ->field('u.*,w.country,w.province,w.city,w.sex,w.unionid,w.openid,w.routine_openid,w.groupid,w.tagid_list,w.subscribe,w.subscribe_time')
@@ -180,8 +184,12 @@ class User extends BaseModel
                     else if (time() > $levelinfo['valid_time']) $item['vip_name'] = SystemUserLevel::where('id', $levelinfo['level_id'])->value('name');
                 }
             });//->toArray();
-        $count = self::setWherePage(self::setWhere($where), $where, ['w.sex', 'w.province', 'w.city', 'u.status', 'u.is_promoter'], ['u.nickname', 'u.uid'])->alias('u')->join('WechatUser w', 'u.uid=w.uid')->count();
-        return ['count' => $count, 'data' => $list];
+        if ($where['fl'] == 1){
+            $count = self::setWherePage(self::setWhere($where), $where, ['w.sex', 'w.province', 'w.city', 'u.status', 'u.is_promoter'], ['u.nickname', 'u.uid'])->where('white_integral', '>', 0)->alias('u')->join('WechatUser w', 'u.uid=w.uid')->count();
+        }else{
+            $count = self::setWherePage(self::setWhere($where), $where, ['w.sex', 'w.province', 'w.city', 'u.status', 'u.is_promoter'], ['u.nickname', 'u.uid'])->alias('u')->join('WechatUser w', 'u.uid=w.uid')->count();
+
+        }        return ['count' => $count, 'data' => $list];
     }
 
     /**
@@ -1156,7 +1164,7 @@ class User extends BaseModel
 
     public static function getSpreadList($uid, $page, $limit)
     {
-        $list = self::where('spread_uid', $uid)->field('uid,nickname,now_money,integral,add_time')
+        $list = self::where('spread_uid', $uid)->field('uid,nickname,white_integral,now_money,integral,add_time')
             ->order('uid desc')->page((int)$page, (int)$limit)->select();
         count($list) && $list = $list->toArray();
         foreach ($list as &$item) {

+ 3 - 0
app/admin/model/user/UserPoint.php

@@ -93,6 +93,9 @@ class UserPoint extends BaseModel
         if ($where['nickname'] != '') {
             $model = $model->where('b.nickname|b.uid', 'like', $where['nickname']);
         }
+        if ($where['title'] != ''){
+            $model = $model->where('a.title', 'like', $where['title']);
+        }
         return $model;
     }
 

+ 12 - 0
app/admin/view/ump/user_point/index.php

@@ -14,6 +14,17 @@
                                     <input type="text" name="nickname" class="layui-input">
                                 </div>
                             </div>
+                            <div class="layui-inline">
+                                <label class="layui-form-label">筛选类型</label>
+                                <div class="layui-input-block">
+                                    <select name="title">
+                                        <option value="">全部</option>
+                                        {volist name='title' id='val'}
+                                        <option value="{$val}">{$val}</option>
+                                        {/volist}
+                                    </select>
+                                </div>
+                            </div>
                             <div class="layui-inline">
                                 <label class="layui-form-label">时间范围</label>
                                 <div class="layui-input-inline" style="width: 200px;">
@@ -121,6 +132,7 @@
                     q.start_time=where.start_time || '';
                     q.end_time=where.end_time || '';
                     q.nickname=where.nickname || '';
+                    q.title=where.title || '';
                     location.href=layList.U({c:'ump.user_point',a:'export',q:q});
                 })
             }

+ 9 - 0
app/admin/view/user/user/index.php

@@ -89,6 +89,15 @@
                                 </select>
                             </div>
                         </div>
+                        <div class="layui-inline">
+                            <label class="layui-form-label">肥     料:</label>
+                            <div class="layui-input-inline">
+                                <select name="fl" lay-verify="fl">
+                                    <option value="">全部</option>
+                                    <option value="1">有</option>
+                                </select>
+                            </div>
+                        </div>
                         <div class="layui-inline">
                             <label class="layui-form-label">性  别:</label>
                             <div class="layui-input-inline">

+ 113 - 1
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">
@@ -244,14 +246,17 @@
                                 <table class="layui-table" v-cloak="">
                                     <thead>
                                     <tr>
+                                        <th>uid</th>
                                         <th>昵称</th>
                                         <th>余额</th>
                                         <th>积分</th>
+                                        <th>肥料</th>
                                         <th>加入时间</th>
                                     </tr>
                                     </thead>
                                     <tbody>
                                     <tr v-for="item in SpreadList">
+                                        <td>{{item.uid}}</td>
                                         <td>
                                             {{item.nickname}}
                                             <p v-show="item.is_vip">
@@ -260,6 +265,7 @@
                                         </td>
                                         <td>{{item.now_money}}</td>
                                         <td>{{item.integral}}</td>
+                                        <td>{{item.white_integral}}</td>
                                         <td>{{item.add_time}}</td>
                                     </tr>
                                     <tr v-show="balanceChangList.length<=0" style="text-align: center">
@@ -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>uid</th>
+                                        <th>昵称</th>
+                                        <th>余额</th>
+                                        <th>阳光</th>
+                                        <th>肥料</th>
+                                        <th>加入时间</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr v-for="item in Spread_list">
+                                        <td>{{item.uid}}</td>
+                                        <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.white_integral}}</td>
+                                        <td>{{item.add_time}}</td>
+                                    </tr>
+                                    <tr v-show="balanceChangList.length<=0" style="text-align: center">
+                                        <td colspan="4">暂无数据</td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                                <div ref="spread" v-show="count.spreadCount > limit" style="text-align: right;"></div>
+                            </div>
+                            <!--end-->
+                            <!--全部-->
+                            <div class="layui-tab-item">
+                                <table class="layui-table" v-cloak="">
+                                    <thead>
+                                    <tr>
+                                        <th>uid</th>
+                                        <th>昵称</th>
+                                        <th>余额</th>
+                                        <th>阳光</th>
+                                        <th>肥料</th>
+                                        <th>加入时间</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr v-for="item in Spread_list_sx">
+                                        <td>{{item.uid}}</td>
+                                        <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.white_integral}}</td>
+                                        <td>{{item.add_time}}</td>
+                                    </tr>
+                                    <tr v-show="balanceChangList.length<=0" style="text-align: center">
+                                        <td colspan="4">暂无数据</td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                                <div ref="sxhy" v-show="count.sxhyCount > limit" style="text-align: right;"></div>
+                            </div>
+                            <!--end-->
                         </div>
                     </div>
                 </div>
@@ -285,7 +361,7 @@
         new Vue({
             el: "#content",
             data: {
-                limit:10,
+                limit:100,
                 uid:$uid,
                 orderList:[],
                 integralList:[],
@@ -293,6 +369,8 @@
                 CouponsList:[],
                 balanceChangList:[],
                 SpreadList:[],
+                Spread_list:[],
+                Spread_list_sx:[],
                 count:count,
                 page:{
                     order_page:1,
@@ -301,6 +379,8 @@
                     copons_page:1,
                     balancechang_page:1,
                     spread_page:1,
+                    spread:1,
+                    sxhy:1,
                 },
             },
             watch:{
@@ -321,12 +401,24 @@
                 },
                 'page.spread_page':function () {
                     this.getSpreadList();
+                },
+                'page.spread':function () {
+                    this.getSpread();
+                },
+                'page.sxhy':function () {
+                    this.getSpreadSx();
                 }
             },
             methods:{
                 getSpreadList:function(){
                     this.request('getSpreadList',this.page.spread_page,'SpreadList');
                 },
+                getSpread:function(){
+                    this.request('getSpread',this.page.spread,'Spread_list');
+                },
+                getSpreadSx:function(){
+                    this.request('getSpreadSx',this.page.spread,'Spread_list_sx');
+                },
                 getOneorderList:function () {
                     this.request('getOneorderList',this.page.order_page,'orderList');
                 },
@@ -356,6 +448,8 @@
                 this.getOneCouponsList();
                 this.getOneBalanceChangList();
                 this.getSpreadList();
+                this.getSpread();
+                this.getSpreadSx();
                 var that=this;
                 layList.laypage.render({
                     elem: that.$refs.page_order
@@ -412,6 +506,24 @@
                         that.page.spread_page=obj.curr;
                     }
                 });
+                layList.laypage.render({
+                    elem: that.$refs.spread
+                    ,count:that.count.spreadCount
+                    ,limit:that.limit
+                    ,theme: '#1E9FFF',
+                    jump:function(obj){
+                        that.page.spread=obj.curr;
+                    }
+                });
+                layList.laypage.render({
+                    elem: that.$refs.sxhy
+                    ,count:that.count.sxhyCount
+                    ,limit:that.limit
+                    ,theme: '#1E9FFF',
+                    jump:function(obj){
+                        that.page.sxhy=obj.curr;
+                    }
+                });
             }
         });
     });

+ 2 - 1
app/api/controller/many/ManyController.php

@@ -75,6 +75,7 @@ class ManyController
             ['id'],
             ['price']
         ]);
+        Db::startTrans();
         $many = Many::where('id', $data['id'])->lock(true)->find();
         $surplus = $this->surplus($data['id'], $request->uid(),1);
         $user = User::where('uid', $request->uid())->find();
@@ -85,7 +86,7 @@ class ManyController
         if (($many['number']+$data['price']) > $many['money']) return app('json')->fail('还能最大种树'.($many['money']-$many['number']));
         if ($data['price'] > $many['single']) return app('json')->fail('单次最大可以种树'.$many['single']);
         if ($surplus < $data['price']) return app('json')->fail('超过最大可种树额度');
-        Db::startTrans();
+        if (ManyOrder::where('many_id', $many['id'])->where('uid', $user['uid'])->where('stage', $many['stage'])->count() >= 3) return app('json')->fail('超过单场最大抢购数');
         if ($many['add_time'] > time()){
             if ($many['add_time'] - 600 > time()) return app('json')->fail('只能提前十分钟进行,提前种树');
             $advance = SystemConfigService::get('advance');

+ 15 - 0
app/common.php

@@ -681,6 +681,21 @@ if (!function_exists('do_request')) {
         }
     }
 
+    if (!function_exists('get_downline_admin')){
+        //所有下级
+        function get_downline_admin($members,$id){
+            $arr=array();
+            foreach ($members as $key => $v) {
+                if($v['spread_uid']==$id){  //pid为0的是顶级分类
+                    $arr[]= ['uid' => $v['uid'], 'nickname' => $v['nickname'], 'white_integral' => $v['white_integral'],'now_money' => $v['now_money'], 'integral' => $v['integral'], 'add_time' =>$v['add_time']];
+                    $arr = array_merge($arr,get_downline_admin($members,$v['uid']));
+                }
+            }
+            return $arr;
+
+        }
+    }
+
     if (!function_exists('sing')){
         //查找所有上级
         function sing($data, $key){