jun hai 5 meses
pai
achega
3681b215b5

+ 39 - 30
app/Console/Commands/Regiment.php

@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Facades\Servers\Logs\Log;
 use App\Models\Orders;
 use Illuminate\Console\Command;
 use App\Facades\Servers\Redis\RedisLock;
@@ -44,7 +45,7 @@ class Regiment extends Command
     public function handle()
     {
         // 执行任务
-        $this->run_task();
+        $this->run_regiment();
         return 0;
     }
 
@@ -52,43 +53,49 @@ class Regiment extends Command
      * 执行任务
      *
      * */
-    public function run_task(){
+    public function run_regiment(){
         // 实例化
+        Log::log('run_regiment','执行开始');
         $Model          = New Model();
         $time           = time();
         // 活动结束
         $activeList     =  $Model->query()->where([['end_time','<=',time()],['status','=',1]])->get();
-        $activeList     =  $activeList->toArray();
-        $activeList     =  array_column($activeList,null,'id');
         if ($activeList){
+            $activeList =  $activeList->toArray();
+            $activeList =  array_column($activeList,null,'id');
             $activeIds  =   array_column($activeList,'id');
-            $regiment   =   RegimentModel::query()->where('status','=',1)->whereIn('id',$activeIds)->get()->toArray();
-            var_dump($regiment);
+            $regiment   =   RegimentModel::query()->where('status','=',1)->whereIn('active_id',$activeIds)->get()->toArray();
             if ($regiment){
-                var_dump(222);exit();
                 foreach ($regiment as $v){
                         //虚拟成团
-                       if ($activeList[$v['active_id']]['virtually'] == 2){
-                           //修改状态
-                           RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>3]);
-                           RegimentRecord::query()->where('regiment_id','=',$v['id'])->update(['status'=>2]);
+                       if ($activeList[$v['active_id']]['virtually'] == 0 || $activeList[$v['active_id']]['number'] <= $v['people_number']){
                            //查询记录
-                           $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get();
-                           $regimentRecordListIds = array_column($regimentRecordList,'id');
-                           //修改订单
-                           $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>2]);
+                           $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get()->toArray();
+                           if ($regimentRecordList){
+                               $regimentRecordListIds = array_column($regimentRecordList,'order_id');
+                               //修改订单
+                               $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>2,'update_time'=>$time]);
+                               if (!$res)   Log::error('run_regiment','修改订单失败');
+                           }
+                           //修改状态
+                           $res         =   RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>2]);
+                           if (!$res)   Log::error('run_regiment','修改团状态失败');
+                           $res         =   RegimentRecord::query()->where('regiment_id','=',$v['id'])->update(['status'=>2]);
+                           if (!$res)   Log::error('run_regiment','修改团记录失败');
                        }else{
-                           RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>2]);
+                           RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>3]);
                            RegimentRecord::query()->where('regiment_id','=',$v['id'])->update(['status'=>3]);
                            //查询记录
-                           $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get();
-                           $regimentRecordListIds = array_column($regimentRecordList,'id');
-                           //修改订单
-                           $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
+                           $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get()->toArray();
+                           if ($regimentRecordList){
+                               $regimentRecordListIds = array_column($regimentRecordList,'order_id');
+                               //修改订单
+                               $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
+                           }
                        }
                 }
             }
-            $res    =   $Model->query()->whereIn('id',$activeIds)->update(['status'=>2]);
+            $res    =   $Model->query()->whereIn('id',$activeIds)->update(['status'=>2,'update_time'=>$time]);
         }
 
         //团过期
@@ -97,27 +104,29 @@ class Regiment extends Command
             foreach ($regimentList as $v){
                 $activeList = $Model->query()->where('id','=',$v['active_id'])->first();
                 //虚拟成团
-                if ($activeList['virtually'] == 2){
+                if ($activeList['virtually'] == 0 || $activeList['number'] <= $v['people_number']){
                     //修改状态
-                    $r = RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>3]);
+                    $r = RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>2]);
                     RegimentRecord::query()->where('regiment_id','=',$v['id'])->update(['status'=>2]);
                     //查询记录
-                    $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get();
-                    $regimentRecordListIds = array_column($regimentRecordList,'id');
-                    //修改订单
-                    $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>2]);
+                    $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get()->toArray();
+                    if ($regimentRecordList){
+                        $regimentRecordListIds = array_column($regimentRecordList,'order_id');
+                        //修改订单
+                        $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>1]);
+                    }
                 }else{
-                    $r = RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>2]);
+                    $r = RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>3]);
                     RegimentRecord::query()->where('regiment_id','=',$v['id'])->update(['status'=>3]);
                     //查询记录
                     $regimentRecordList  =   regimentRecord::query()->where('regiment_id','=',$v['id'])->get();
-                    $regimentRecordListIds = array_column($regimentRecordList,'id');
+                    $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                     //修改订单
                     $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
                 }
             }
         }
-
+        Log::log('run_regiment','执行完成');
     }
 
 }

+ 20 - 1
app/Http/Controllers/Admin/Regiment.php

@@ -27,11 +27,30 @@ class Regiment extends Auth{
      * */
     public function index(Model $Model,Product $Product,RegimentActive  $RegimentActive,Custom  $Custom){
         // 接收参数
+        $code					= request('code','');
         $name					= request('name','');
+        $productName			= request('product_name','');
+        $status			        = request('status','');
+        $start_time			    = request('start_time','');
+        $end_time			    = request('end_time','');
         // 查询条件
         $map 					= [];
         // 组合条件
-        if( $name )				$map[] = ['regiment.name','=',$name];
+        if( $name )				$map[] = ['regiment_active.name','=',$name];
+        if( $code ){
+            $id                 =   $Model->codeToId($code);
+            $map[] = ['regiment_active.id','=',$id];
+        }
+        if( $productName )		$map[] = ['product.name','=',$productName];
+        if( $status )			$map[] = ['regiment.status','=',$status];
+        if( $start_time )		{
+            $start_time         =   strtotime($start_time);
+            $map[] = ['regiment.start_time','>=',$start_time];
+        }
+        if( $end_time )		{
+            $end_time         =   strtotime($end_time);
+            $map[] = ['regiment.end_time','<=',$end_time];
+        }
         $select = [
             'regiment.*',
             'regiment_active.name as active_name',

+ 27 - 2
app/Http/Controllers/Admin/RegimentActive.php

@@ -27,11 +27,30 @@ class RegimentActive extends Auth{
      * */
     public function index(Model $Model){
         // 接收参数
+        $code					= request('code','');
         $name					= request('name','');
+        $productName			= request('product_name','');
+        $status			        = request('status','');
+        $start_time			    = request('start_time','');
+        $end_time			    = request('end_time','');
         // 查询条件
         $map 					= [];
         // 组合条件
         if( $name )				$map[] = ['regiment_active.name','=',$name];
+        if( $code ){
+            $id                 =   $Model->codeToId($code);
+            $map[] = ['regiment_active.id','=',$id];
+        }
+        if( $productName )		$map[] = ['product.name','=',$productName];
+        if( $status )			$map[] = ['regiment_active.status','=',$status];
+        if( $start_time )		{
+            $start_time         =   strtotime($start_time);
+            $map[] = ['regiment_active.start_time','>=',$start_time];
+        }
+        if( $end_time )		{
+            $end_time         =   strtotime($end_time);
+            $map[] = ['regiment_active.end_time','<=',$end_time];
+        }
         // 查询数据
         $list					= $Model->query()
                                 ->join('product','product.id','=','regiment_active.product_id')
@@ -85,6 +104,9 @@ class RegimentActive extends Auth{
             $product_res                    = $Model::query()->where([['status','=', 1],['product_id','=', $data['product_id']],['end_time','>=', time()]])->first();
             // 提示
             if ($product_res)               return json_send(['code'=>'error','msg'=>'该产品正在参加拼团活动']);
+            //核对产品价格
+            $productInfo                    =   $Product->getOne($data['product_id']);
+            if ($productInfo['price'] < $data['regiment_price'])    return json_send(['code'=>'error','msg'=>'拼团价格不能大于产品价格']);
             // 写入数据表
             $id						        = $Model->add($data);
             // 如果操作失败
@@ -96,7 +118,7 @@ class RegimentActive extends Auth{
                                                 'custom_uid'    =>  0,
                                                 'active_id'     =>  $id,
                                                 'product_id'    =>  $data['product_id'],
-                                                'status'        =>  1,
+                                                'status'        =>  0,
                                                 'start_time'    =>  $data['start_time'],
                                                 'end_time'      =>  $data['start_time'] + $data['expiration']*60*60,
                                                 'update_time'   =>  time(),
@@ -159,9 +181,12 @@ class RegimentActive extends Auth{
             $data['virtually']				= request('virtually',0);
             $data['status']			        = 1;
             // 核对产品
-            $product_res                    = $Model::query()->where([['status','=', 1],['product_id','=', $data['product_id']],['end_time','>=', time()]])->first();
+            $product_res                    = $Model::query()->where([['id','><', $id],['status','=', 1],['product_id','=', $data['product_id']],['end_time','>=', time()]])->first();
             // 提示
             if ($product_res)               return json_send(['code'=>'error','msg'=>'该产品正在参加拼团活动']);
+            //核对产品价格
+            $productInfo                    =   $Product->getOne($data['product_id']);
+            if ($productInfo['price'] < $data['regiment_price'])    return json_send(['code'=>'error','msg'=>'拼团价格不能大于产品价格']);
             // 写入数据表
             $id						        = $Model->add($data);
             // 如果操作失败

+ 182 - 5
app/Http/Controllers/Admin/RegimentRecord.php

@@ -1,10 +1,13 @@
 <?php namespace App\Http\Controllers\Admin;
 
+use App\Models\City;
 use App\Models\Custom as Custom;
 use App\Models\Product as Product;
 use App\Models\Orders as Orders;
 use App\Models\RegimentActive as RegimentActive;
 use App\Models\RegimentRecord as Model;
+use App\Models\WeiBan\Follow as WeiBanFollow;
+use Illuminate\Support\Carbon;
 use PhpOffice\PhpSpreadsheet\IOFactory;
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
 use PhpOffice\PhpSpreadsheet\Style\Alignment;
@@ -30,14 +33,34 @@ class RegimentRecord extends Auth{
      * */
     public function index(Model $Model, Product $Product, RegimentActive $RegimentActive, Custom $Custom,Orders $Orders){
         // 接收参数
+        $code					= request('code','');
         $name					= request('name','');
+        $productName			= request('product_name','');
+        $status			        = request('status','');
+        $start_time			    = request('start_time','');
+        $end_time			    = request('end_time','');
         // 查询条件
         $map 					= [];
         // 组合条件
-        if( $name )				$map[] = ['regiment_record.name','=',$name];
+        if( $name )				$map[] = ['regiment_active.name','=',$name];
+        if( $code ){
+            $id                 =   $RegimentActive->codeToId($code);
+            $map[] = ['regiment_active.id','=',$id];
+        }
+        if( $productName )		$map[] = ['product.name','=',$productName];
+        if( $status )			$map[] = ['regiment_record.status','=',$status];
+        if( $start_time )		{
+            $start_time         =   strtotime($start_time);
+            $map[] = ['regiment_record.insert_time','>=',$start_time];
+        }
+        if( $end_time )		{
+            $end_time         =   strtotime($end_time);
+            $map[] = ['regiment_record.insert_time','<=',$end_time];
+        }
         $select = [
             'regiment_record.*',
             'regiment.status as regiment_status',
+            'regiment.custom_uid as regiment_uid',
             'regiment_active.name as active_name',
             'product.name as product_name',
             'custom.username as username',
@@ -54,10 +77,13 @@ class RegimentRecord extends Auth{
             ->paginate(config('page_num',10));
         // 循环处理数据
         foreach($list as &$v){
-            $v['product_code']  = $Product->idToCode($v['product_id']);
-            $v['active_code']   = $RegimentActive->idToCode($v['active_id']);
-            $v['custom_code']   = $Custom->idToCode($v['custom_uid']);
-            $v['order_code']   = $Orders->idToCode($v['order_id']);
+            $v['product_code']          = $Product->idToCode($v['product_id']);
+            $v['active_code']           = $RegimentActive->idToCode($v['active_id']);
+            $v['custom_code']           = $Custom->idToCode($v['custom_uid']);
+            $v['order_code']            = $Orders->idToCode($v['order_id']);
+            $v['regiment_uid_code']     = $Custom->idToCode($v['regiment_uid']);
+            $userInfo                   = $Custom->getOne($v['regiment_uid']);
+            $v['regiment_username']     = $userInfo['username'];
         }
         // 分配数据
         $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
@@ -65,5 +91,156 @@ class RegimentRecord extends Auth{
         // 加载模板
         return 					$this->fetch();
     }
+    /**
+     * 导出表格
+     *
+     * */
+    public function down_excel(Model $Model, Product $Product, RegimentActive $RegimentActive, Custom $Custom,Orders $Orders){
+        // 接受参数
+        // 接收参数
+        $code					= request('code','');
+        $name					= request('name','');
+        $productName			= request('product_name','');
+        $status			        = request('status','');
+        $start_time			    = request('start_time','');
+        $end_time			    = request('end_time','');
+        // 查询条件
+        $map 					= [];
+        // 组合条件
+        if( $name )				$map[] = ['regiment_active.name','=',$name];
+        if( $code ){
+            $id                 =   $RegimentActive->codeToId($code);
+            $map[] = ['regiment_active.id','=',$id];
+        }
+        if( $productName )		$map[] = ['product.name','=',$productName];
+        if( $status )			$map[] = ['regiment_record.status','=',$status];
+        if( $start_time )		{
+            $start_time         =   strtotime($start_time);
+            $map[] = ['regiment_record.insert_time','>=',$start_time];
+        }
+        if( $end_time )		{
+            $end_time         =   strtotime($end_time);
+            $map[] = ['regiment_record.insert_time','<=',$end_time];
+        }
+        $select = [
+            'regiment_record.*',
+            'regiment.status as regiment_status',
+            'regiment.custom_uid as regiment_uid',
+            'regiment_active.name as active_name',
+            'product.name as product_name',
+            'custom.username as username',
+        ];
+        // 查询数据
+        $list					= $Model->query()
+            ->join('regiment','regiment.id','=','regiment_record.regiment_id')
+            ->join('regiment_active','regiment_active.id','=','regiment_record.active_id')
+            ->join('product','product.id','=','regiment_record.product_id')
+            ->join('custom','custom.uid','=','regiment_record.custom_uid')
+            ->where($map)
+            ->select($select)
+            ->orderByDesc('id')
+            ->paginate(config('page_num',10));
+        // 循环处理数据
+        foreach($list as &$v){
+            $v['product_code']  = $Product->idToCode($v['product_id']);
+            $v['active_code']   = $RegimentActive->idToCode($v['active_id']);
+            $v['custom_code']   = $Custom->idToCode($v['custom_uid']);
+            $v['order_code']    = $Orders->idToCode($v['order_id']);
+            $userInfo                   = $Custom->getOne($v['regiment_uid']);
+            $v['regiment_username']     = $userInfo['username'];
+        }
 
+        try {
+            // 去下载
+            $this->toDown($list);
+        } catch (\Throwable $th) {
+            echo $th->getMessage();
+        }
+
+    }
+    /**
+     * 去下载
+     */
+    private function  toDown($data){
+        // 创建新的电子表格对象
+        $spreadsheet			= new Spreadsheet();
+        // 设置合并单元格的行和列,例如合并A1到B2的单元格
+        $sheet					= $this->setStyle($spreadsheet);
+        // 从第二行写入
+        $row					= 2;
+        // 循环写入
+        foreach ($data as $key => $value) {
+            $statusName = '';
+            // 单元格内容写入
+            $sheet->setCellValue('A'.$row, $value['id']);
+            $sheet->setCellValue('B'.$row, $value['regiment_id']);
+            $sheet->setCellValue('C'.$row, $value['order_code']);
+            $sheet->setCellValue('D'.$row, $value['username']);
+            $sheet->setCellValue('E'.$row, $value['active_name']);
+            $sheet->setCellValue('F'.$row, $value['product_name']);
+            $sheet->setCellValue('G'.$row, $value['regiment_username']);
+            switch ($value['status']) {
+                case '0':
+                    $statusName =   '拼团中';
+                    break;
+                case '1':
+                    $statusName =   '取消拼团';
+                    break;
+                case '2':
+                    $statusName =   '拼团成功';
+                    break;
+                case '3':
+                    $statusName =   '拼团失败';
+                    break;
+            }
+            $sheet->setCellValue('H'.$row, $statusName);
+            $sheet->setCellValue('I'.$row, date('Y-m-d H:i:s',$value['insert_time']));
+            $row++;
+        }
+        //
+        // 创建内容
+        $writer 				= IOFactory::createWriter($spreadsheet, 'Xlsx');
+        header('Pragma: public');
+        header('Content-type:application/vnd.ms-excel');
+        header('Content-Disposition: inline;filename=下载拼团记录.xlsx');
+        // 输出数据流
+        return $writer->save('php://output');
+    }
+    /**
+     * 设置表格样式
+     *
+     */
+    private function setStyle(Spreadsheet $spreadsheet){
+        // 选择当前活动的工作表
+        $sheet					= $spreadsheet->getActiveSheet();
+        // 宽
+        $sheet->getColumnDimension('A')->setWidth(15);
+        $sheet->getColumnDimension('B')->setWidth(15);
+        $sheet->getColumnDimension('C')->setWidth(15);
+        $sheet->getColumnDimension('D')->setWidth(15);
+        $sheet->getColumnDimension('E')->setWidth(15);
+        $sheet->getColumnDimension('F')->setWidth(15);
+        $sheet->getColumnDimension('G')->setWidth(15);
+        $sheet->getColumnDimension('H')->setWidth(15);
+        $sheet->getColumnDimension('I')->setWidth(15);
+        // 默认高度
+        $sheet->getDefaultRowDimension()->setRowHeight(18);
+        // 加粗第一行
+        $sheet->getStyle('A:S')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
+        $sheet->getStyle('A1:S1')->getFont()->setBold(true);
+        $sheet->getStyle('A1:S1')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF00FF00'); // ARGB颜色代码,例如绿色
+        // 设置表格标题
+        $sheet
+            ->setCellValue('A1', '拼团记录ID')
+            ->setCellValue('B1', '团单ID')
+            ->setCellValue('C1', '订单编码')
+            ->setCellValue('D1', '客户昵称')
+            ->setCellValue('E1', '参与活动')
+            ->setCellValue('F1', '产品名称')
+            ->setCellValue('G1', '发起客户昵称')
+            ->setCellValue('H1', '拼团状态')
+            ->setCellValue('I1', '订单生成时间');
+        // 返回结果
+        return 					$sheet;
+    }
 }

+ 1 - 1
app/Http/Controllers/Api/Orders.php

@@ -729,7 +729,7 @@ class Orders extends Api{
                     'active_id'     =>  $regimentActiveInfo['id'],
                     'product_id'    =>  $buyInfo['product_id'],
                     'people_number' =>  1,
-                    'status'        =>  1,
+                    'status'        =>  0,
                     'start_time'    =>  $time,
                     'end_time'      =>  $time + $regimentActiveInfo['expiration']*3600,
                     'update_time'   =>  $time,

+ 2 - 2
app/Http/Controllers/Api/Product.php

@@ -166,7 +166,7 @@ class Product extends Api{
             $data['regiment_active']        = $regimentActive;
             $data['automatic_info']         = [];
             if ($regimentActive['automatic'] == 1){
-                $automaticInfo              = $Regiment::query()->where([['status','=',1],['active_id','=',$regimentActive['id']],['start_time','<=',$time],['end_time','>=',$time]])->first();
+                $automaticInfo              = $Regiment::query()->where([['status','=',0],['active_id','=',$regimentActive['id']],['start_time','<=',$time],['end_time','>=',$time]])->first();
                 if ($automaticInfo){
                     $data['automatic_info']     = $automaticInfo;
 					$data['regiment_type']      = 1;
@@ -179,7 +179,7 @@ class Product extends Api{
                 $data['regiment_type']      = 2;
                 $regiment = $Regiment::query()
                     ->join('custom','custom.uid','=','regiment.custom_uid')
-                    ->where([['regiment.active_id','=',$data['regiment_active_id']],['regiment.product_id','=',$data['id']],['regiment.status','=',1],['regiment.start_time','<=',$time],['regiment.end_time','>=',$time]])
+                    ->where([['regiment.active_id','=',$data['regiment_active_id']],['regiment.product_id','=',$data['id']],['regiment.status','=',0],['regiment.start_time','<=',$time],['regiment.end_time','>=',$time]])
                     ->select(['regiment.*','custom.username','custom.userpic'])
                     ->get();
                 if ($regiment){

+ 4 - 3
resources/views/admin/regiment/index.blade.php

@@ -17,9 +17,10 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 	<div class="form-group col col-md-1" style="margin-right: 2px;">
 		<select name="status" class="form-control">
 			<option value="" >状态</option>
-			<option value="0" @if (request('status') === '1' ) selected="selected" @endif >启用</option>
-			<option value="2" @if (request('status') === '2' ) selected="selected" @endif >停用</option>
-			<option value="3" @if (request('status') === '3' ) selected="selected" @endif >结束</option>
+			<option value="0" @if (request('status') === '0' ) selected="selected" @endif >拼团中</option>
+			<option value="1" @if (request('status') === '1' ) selected="selected" @endif >取消拼团</option>
+			<option value="2" @if (request('status') === '2' ) selected="selected" @endif >拼团成功</option>
+			<option value="3" @if (request('status') === '3' ) selected="selected" @endif >拼团失败</option>
 		</select>
 	</div>
 	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">

+ 71 - 3
resources/views/admin/regiment_record/index.blade.php

@@ -4,12 +4,27 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 @endsection
 @section('content')
 
-<form action="" method="get" class="form-horizontal form-line">
+<form action="" method="get" class="form-horizontal form-line" name="thisform">
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="code" value="{{request('code','')}}" placeholder="请输入活动编码" />
+	</div>
 	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
 		<input type="text" class="form-control" name="name" value="{{request('name','')}}" placeholder="请输入活动名称查询" />
 	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="product_name" value="{{request('product_name','')}}" placeholder="请输入产品名称查询" />
+	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
+		<input type="date" class="form-control" name="start_time" value="{{request('start_time','')}}" placeholder="请输入创建时间查询" />
+	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
+		<input type="date" class="form-control" name="end_time" value="{{request('end_time','')}}" placeholder="请输入结束查询" />
+	</div>
 	<input type="submit" class="btn btn-sm btn-primary" value="查询"/>
 	<a href="{{url('admin/regiment_record/index')}}" class="btn btn-sm btn-default" >重置</a>
+	@if( check_auth('admin/regiment_record/down_excel') )
+		<button type="button" onclick="alter_from_attr({'method':'get','action':`{{url('admin/regiment_record/down_excel')}}`})" class="btn btn-sm btn-primary"> 下载</button>
+	@endif
 </form>
 
 <div class="row">
@@ -39,7 +54,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<th>{{$a['username']}}<br/>{{$a['custom_code']}}</th>
 							<td>{{$a['active_name']}}<br/>{{$a['active_code']}}</td>
 							<td style="white-space:pre">{{$a['product_name']}}<br/>{{$a['product_code']}}</td>
-							<td>{{$a['username']}}<br/>{{$a['custom_code']}}</td>
+							<td>{{$a['regiment_username']}}<br/>{{$a['regiment_uid_code']}}</td>
 							<td>
 								@if( $a['status'] == 0 )
 									拼团中
@@ -61,7 +76,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<td colspan="20" class="page">{{$list->render()}}</td>
 						</tr>
 						<tr>
-							<td colspan="20">总计 {{$list->total()}} 个商店</td>
+							<td colspan="20">总计 {{$list->total()}} 个记录</td>
 						</tr>
 				</tbody>
 				
@@ -70,3 +85,56 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 	</div>
 </div>
 @endsection
+@section('javascript')
+	<script src="/static/fileupload/jquery.ui.widget.js"></script>
+	<script src="/static/fileupload/jquery.fileupload.js"></script>
+	<script type="text/javascript">
+		$(function(){
+			$('.upload').on('click', function() {
+				$('#form-upload').remove();
+				$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_file" type="file" name="order_file" multiple="multiple" /></form>');
+				$('#form-upload input[name=\'clockin_record_file\']').trigger('click');
+				$('[osctype="btn_upload_file"]').fileupload({
+					dataType: 'json',
+					url: "{{url('admin/custom_clockin_record/import_execl')}}",
+					singleFileUploads: false,
+					beforeSend: function() {
+						art.dialog({
+							id: 'loading',
+							lock: true,
+							title: '文件上传中'
+						});
+					},
+					done: function(e, data) {
+						art.dialog.list['loading'].close();
+						var result = data.result;
+						if (result.code == 'error') {
+							art.dialog({
+								content: result.msg,
+								lock: true,
+								ok: function() {}
+							});
+						}
+						if (result.code == 'success') {
+							art.dialog({
+								content: result.msg,
+								lock: true,
+								ok: function() {
+									location.reload();
+								}
+							});
+						}
+					},
+					fail: function(e,c) {
+						art.dialog.list['loading'].close();
+						art.dialog({
+							content: '<p>'+c.jqXHR.status+'=>'+c.jqXHR.statusText+'</p>',
+							lock: true,
+							ok: function() {}
+						});
+					}
+				});
+			});
+		})
+	</script>
+@endsection

+ 2 - 0
routes/web.php

@@ -463,5 +463,7 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     Route::any('regiment/index',[App\Http\Controllers\Admin\Regiment::class,'index']);
     //团记录列表
     Route::any('regiment_record/index',[App\Http\Controllers\Admin\RegimentRecord::class,'index']);
+    //团记录下载
+    Route::any('regiment_record/down_excel',[App\Http\Controllers\Admin\RegimentRecord::class,'down_excel']);
 
 });