Эх сурвалжийг харах

本站用户和报名列表增加导出功能

linwu 1 жил өмнө
parent
commit
7da99fdadf

+ 18 - 3
app/common/Fun.php

@@ -69,11 +69,12 @@ class Fun
     /**
      * 是否手机号
      */
-    public static function isMobile($user_mobile){
+    public static function isMobile($user_mobile)
+    {
         $chars = "/^((\(\d{2,3}\))|(\d{3}\-))?1(3|4|5|6|7|8|9)\d{9}$/";
-        if (preg_match($chars, $user_mobile)){
+        if (preg_match($chars, $user_mobile)) {
             return true;
-        }else{
+        } else {
             return false;
         }
     }
@@ -103,4 +104,18 @@ class Fun
         }
         return $age;
     }
+
+    /**
+     * 获取加密姓名
+     */
+    public static function getEncodeName($name)
+    {
+        $len = mb_strlen($name,'utf-8');
+        $res = mb_substr($name,0,1);
+        for ($i = 1; $i < $len; $i++) {
+            $res .= '*';
+        }
+
+        return $res;
+    }
 }

+ 11 - 0
app/portal/controller/IndexController.php

@@ -17,6 +17,7 @@ use app\love\controller\LoveBaseController;
 use app\love\model\UserFriendModel;
 use app\love\model\UserInviteModel;
 use app\love\model\UserMatingModel;
+use app\love\model\UserSelectLogModel;
 use app\portal\model\UserModel;
 
 class IndexController extends LoveBaseController
@@ -81,6 +82,16 @@ class IndexController extends LoveBaseController
             ->count();
         $this->assign('unread_num', $unread_num + $invite_num);
 
+        //配对播报
+        $select = UserSelectLogModel::with(['user1','user2'])->order('id desc')->limit(3)->select();
+        if (!empty($select)) {
+            foreach ($select as $v) {
+                $v['name1'] = Fun::getEncodeName($v['user1']['realname']);
+                $v['name2'] = Fun::getEncodeName($v['user2']['realname']);
+            }
+        }
+        $this->assign('select',json_encode($select));
+
         return $this->fetch(':index');
     }
 

+ 63 - 8
app/user/controller/AdminIndexController.php

@@ -13,6 +13,8 @@ namespace app\user\controller;
 
 use api\user\model\UserLikeModel;
 use app\common\Constant;
+use app\common\Excel;
+use app\common\Fun;
 use app\love\model\ActiveApplyModel;
 use app\love\model\UserFriendModel;
 use app\love\model\UserGiftModel;
@@ -95,10 +97,6 @@ class AdminIndexController extends AdminBaseController
                     $query->where('sex', $data['sex']);
                 }
 
-                if (!empty($data['is_complete'])) {
-                    $query->where('is_complete', $data['is_complete']);
-                }
-
                 if (!empty($data['check_status'])) {
                     $query->where('check_status', $data['check_status']);
                 }
@@ -124,10 +122,6 @@ class AdminIndexController extends AdminBaseController
                     $query->where('sex', $data['sex']);
                 }
 
-                if (!empty($data['is_complete'])) {
-                    $query->where('is_complete', $data['is_complete']);
-                }
-
                 if (!empty($data['check_status'])) {
                     $query->where('check_status', $data['check_status']);
                 }
@@ -276,4 +270,65 @@ class AdminIndexController extends AdminBaseController
             $this->error('数据传入失败!');
         }
     }
+
+    /**
+     * 导出
+     */
+    public function export()
+    {
+        $data = $this->request->param();
+
+        $where = [
+            ['user_type', '=', 2],
+            ['is_complete', '=', 1],
+        ];
+
+        if (!empty($data['uid'])) {
+            $where[] = ['id', '=', intval($data['uid'])];
+        }
+
+        if (!empty($data['keyword'])) {
+            $where[] = ['realname', 'like', "%{$data['keyword']}%"];
+        }
+
+        if (!empty($data['sex'])) {
+            $where[] = ['sex', '=', $data['sex']];
+        }
+
+        if (!empty($data['check_status'])) {
+            $where[] = ['check_status', '=', $data['check_status']];
+        }
+
+        $list  = UserModel::where($where)->order("check_status asc,create_time DESC")->select();
+        $data = [];
+        foreach ($list as $v) {
+            $data[] = [
+                'name' => $v['realname'],
+                'sex' => $v['sex_text'],
+                'age' => Fun::getAgeByBirth($v['birthday']),
+                'mobile' => $v['mobile'],
+                'company' => $v['company'],
+                'id_type' => $v['id_type'],
+                'native' => $v['native'],
+                'marry' => $v['marry'],
+            ];
+        }
+
+        if (empty($data)) {
+            return '暂无数据';
+        }
+
+        $excel = new Excel();
+        $title = [
+            ['name','姓名'],
+            ['sex','性别'],
+            ['age','年龄'],
+            ['mobile','电话'],
+            ['company','单位'],
+            ['id_type','身份类型'],
+            ['native','籍贯'],
+            ['marry','婚姻状况'],
+        ];
+        $excel->export('本站用户',$title,$data,['mobile']);
+    }
 }

+ 11 - 0
public/themes/admin_simpleboot3/user/admin_index/index.html

@@ -34,6 +34,9 @@
         <input type="submit" class="btn btn-primary" value="搜索"/>
         <a class="btn btn-danger" href="{:url('user/adminIndex/index')}">清空</a>
     </form>
+    <div class="table-actions">
+        <button class="btn btn-primary btn-sm export">导出</button>
+    </div>
     <form method="post" class="js-ajax-form">
         <table class="table table-hover table-bordered">
             <thead>
@@ -190,6 +193,14 @@
     function detail(id) {
         parent.openIframeLayer("/user/admin_index/show/id/"+id+".html",'详情',{});
     }
+
+    $('.export').click(function(){
+        window.open(
+            '{:url("export")}?'+$(".well").serialize(),
+            '_blank'
+        );
+
+    });
 </script>
 </body>
 </html>

+ 13 - 0
public/themes/simpleboot3/portal/index.html

@@ -10,6 +10,8 @@
             padding-top:0;
         }
         .no-image {width:100%;}
+        .ad {display:flex;justify-content:center;align-items:center}
+        .ad .ad-text {margin-left:5px;color:#666;}
     </style>
 </block>
 <block name="body">
@@ -26,6 +28,16 @@
         </van-swipe-item>
     </van-swipe>
 
+    <van-swipe style="height: 30px;background:white;" vertical :autoplay="3000" v-if="select.length > 0">
+        <van-swipe-item class="ad" v-for="(p, index) in select" :key="index">
+            <van-icon name="volume-o" color="#FF589B"></van-icon>
+            <span class="ad-text">恭喜{{p.name1}}和{{p.name2}}配对成功</span>
+        </van-swipe-item>
+        <template #indicator>
+            <div class="custom-indicator"></div>
+        </template>
+    </van-swipe>
+
     <div class="split-block"></div>
 
     <!--推荐嘉宾-->
@@ -94,6 +106,7 @@
                     images: {$images},
                     active: 0,
                     list: {$list},
+                    select: {$select},
                     unread_num: {$unread_num},
                 };
             },

+ 6 - 0
vendor/thinkcmf/cmf-app/src/user/model/UserModel.php

@@ -19,6 +19,12 @@ class UserModel extends Model
         'more' => 'array',
     ];
 
+    public function getSexTextAttr($value, $data)
+    {
+        $sex = ['保密', '男', '女'];
+        return $sex[$data['sex']];
+    }
+
     public function doMobile($user)
     {
         $result = $this->where('mobile', $user['mobile'])->find();