songxingwei před 2 roky
rodič
revize
56359bddb2
1 změnil soubory, kde provedl 64 přidání a 4 odebrání
  1. 64 4
      application/user/controller/Member.php

+ 64 - 4
application/user/controller/Member.php

@@ -15,6 +15,7 @@
 
 namespace app\user\controller;
 
+use app\common\library\PHPExcelService;
 use library\Controller;
 use think\Db;
 use function GuzzleHttp\Psr7\build_query;
@@ -45,8 +46,14 @@ class Member extends Controller
     public function index()
     {
         $this->title = '会员信息管理';
+        $coll_id = $this->request->get('coll_id');
         $query = $this->_query($this->table)->where('is_deleted',0)->like('name,phone')->equal('status,vip,group,is_open_official_DDC');
-        $query->dateBetween('create_at')->order('id desc')->page();
+        $query->dateBetween('create_at')
+            ->when($coll_id,function ($query) use ($coll_id){
+                $mids = Db::name('store_order_info')->where('c_id',$coll_id)->where('status','neq',2)->where('is_destruction',1)->column('mid');
+                $query->whereIn('id',$mids);
+            })
+            ->order('id desc')->page();
     }
     /**
      * 数据列表处理
@@ -65,6 +72,10 @@ class Member extends Controller
         }
         $this->group_list = Db::name('store_member_group')->select();
         $this->group_list = array_merge([['id'=>'','name'=>'全部会员']],$this->group_list);
+
+        //藏品列表
+        $this->coll_list = Db::name('store_collection')->field('id,name')->select();
+        $this->coll_list = array_merge([['id'=>'','name'=>'全部']],$this->coll_list);
     }
     //删除货主
     public function remove()
@@ -437,9 +448,58 @@ class Member extends Controller
     }
 
 
-    public function crystal(){
-        $this->title = '元石充值';
-        $this->_form($this->table, 'crystal');
+    /**
+     * 导出EXCL
+     * @remark 根据WHERE条件导出EXCL
+     * @param array $post 查询条件所需值
+     * @return array
+     */
+    public function get_excl()
+    {
+        set_time_limit(0);
+        $name = $this->request->get('name');
+        $phone = $this->request->get('phone');
+        $status = $this->request->get('status');
+        $coll_id = $this->request->get('coll_id');
+        $create_at = $this->request->get('create_at');
+
+        $model = Db::name('store_member')
+            ->where('is_deleted',0)
+            ->when($name,function ($query) use ($name){
+                $query->whereLike('name','%'.$name.'%');
+            })
+            ->when($phone,function ($query) use ($phone){
+                $query->whereLike('phone','%'.$phone.'%');
+            })
+            ->when($status,function ($query) use ($status){
+                $query->where('status',$status);
+            })
+            ->when($coll_id,function ($query) use ($coll_id){
+                $mids = Db::name('store_order_info')->where('c_id',$coll_id)->where('status','neq',2)->where('is_destruction',1)->column('mid');
+                $query->whereIn('id',$mids);
+            });
+        if (isset($create_at) && $create_at){
+            $time = explode(' - ',$_GET['create_at']);
+            $start_date_time = $time[0].' 00:00:00';
+            $end_date_time = $time[1].' 23:59:59';
+            $model->whereBetweenTime('a.create_at',$start_date_time,$end_date_time);
+        }
+        $list =$model->field('id,name,phone')
+            ->select();
+        $export = [];
+        if (is_array($list)) {
+            foreach ($list as $index => $item) {
+                $export[] = [
+                    $item['phone']
+                ];
+            }
+        }
+
+        PHPExcelService::setExcelHeader(['手机号'])
+            ->setExcelTile('手机号导出' . date('YmdHis', time()), '手机号信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+            ->setExcelContent($export)
+            ->ExcelSave();
+
     }
 
 }