jun 5 mesi fa
parent
commit
d57d74cdca
59 ha cambiato i file con 1728 aggiunte e 5 eliminazioni
  1. 1 0
      .gitignore
  2. 3 1
      app/Http/Controllers/Admin/Orders.php
  3. 65 0
      app/Http/Controllers/Admin/Regiment.php
  4. 229 0
      app/Http/Controllers/Admin/RegimentActive.php
  5. 69 0
      app/Http/Controllers/Admin/RegimentRecord.php
  6. 358 0
      app/Http/Controllers/Api/Orders.php
  7. 63 2
      app/Http/Controllers/Api/Product.php
  8. 52 0
      app/Http/Requests/Admin/RegimentActive.php
  9. 129 0
      app/Models/Regiment.php
  10. 129 0
      app/Models/RegimentActive.php
  11. 111 0
      app/Models/RegimentRecord.php
  12. 8 0
      app/Models/Traits/Orders/Status.php
  13. 5 0
      public/nginx.htaccess
  14. BIN
      public/uploads/images/1/1a87efa0115dc7aa13856b186c984d92.jpg
  15. BIN
      public/uploads/images/1/2.jpg
  16. BIN
      public/uploads/images/1/2.png
  17. BIN
      public/uploads/images/1/21a50dc854a8a293e65bbc9903748ae.png
  18. BIN
      public/uploads/images/1/4cfbfbf2f738f0de34c3d8f66a66a1a.png
  19. BIN
      public/uploads/images/1/O1CN01DfrUww1OEk0nOnFYN_2200569531674.jpg_q50.jpg
  20. BIN
      public/uploads/images/1/banlangen/thumb.jpg
  21. BIN
      public/uploads/images/1/banner/20241106-214350.jpg
  22. BIN
      public/uploads/images/1/banner/20241106-231932.jpg
  23. BIN
      public/uploads/images/1/banner/add_follow1.jpg
  24. BIN
      public/uploads/images/1/dane.png
  25. BIN
      public/uploads/images/1/ganmao/poster.jpg
  26. BIN
      public/uploads/images/1/ganmao/thumb.jpg
  27. BIN
      public/uploads/images/1/guizhouxinlao.jpg
  28. BIN
      public/uploads/images/1/hongpi/1.jpg
  29. BIN
      public/uploads/images/1/hongpi/2.jpg
  30. BIN
      public/uploads/images/1/hongpi/3.jpg
  31. BIN
      public/uploads/images/1/hongpi/4.jpg
  32. BIN
      public/uploads/images/1/hongpi/5.jpg
  33. BIN
      public/uploads/images/1/hongpi/6.jpg
  34. BIN
      public/uploads/images/1/hongpi/7.jpg
  35. BIN
      public/uploads/images/1/hongpi/8.jpg
  36. BIN
      public/uploads/images/1/hongpi/9.jpg
  37. BIN
      public/uploads/images/1/hongpi/999hongopi.jpeg
  38. BIN
      public/uploads/images/1/huoxiang/poster.jpg
  39. BIN
      public/uploads/images/1/huoxiang/thumb.jpg
  40. BIN
      public/uploads/images/1/ksmm.jpg
  41. BIN
      public/uploads/images/1/orders_banner/get_reward.jpg
  42. BIN
      public/uploads/images/1/piyanping/poster.jpg
  43. BIN
      public/uploads/images/1/piyanping/thumb.jpg
  44. BIN
      public/uploads/images/1/pudixiaoyan/333.jpg
  45. BIN
      public/uploads/images/1/pudixiaoyan/pudi.png
  46. BIN
      public/uploads/images/1/putaotangsuanxin/18.png
  47. BIN
      public/uploads/images/1/qianglipipalu/pipalu.png
  48. BIN
      public/uploads/images/1/weitai/poster.jpg
  49. BIN
      public/uploads/images/1/weitai/thumb.jpg
  50. BIN
      public/uploads/images/1/wenweishu/wenwei.png
  51. BIN
      public/uploads/images/1/yws.jpg
  52. 99 0
      resources/views/admin/regiment/index.blade.php
  53. 96 0
      resources/views/admin/regiment_active/add.blade.php
  54. 96 0
      resources/views/admin/regiment_active/edit.blade.php
  55. 117 0
      resources/views/admin/regiment_active/index.blade.php
  56. 75 0
      resources/views/admin/regiment_record/index.blade.php
  57. 1 1
      resources/views/admin/score_clockin/edit.blade.php
  58. 7 1
      routes/api.php
  59. 15 0
      routes/web.php

+ 1 - 0
.gitignore

@@ -9,6 +9,7 @@
 /elkconf
 /public/uploads/product/*
 /public/uploads/company/*
+/public
 /vendor
 *.DS_Store
 *.log

+ 3 - 1
app/Http/Controllers/Admin/Orders.php

@@ -12,6 +12,7 @@ use App\Models\Orders\Receipt;
 use App\Models\OrdersAddr;
 use App\Models\OrdersProduct;
 use Illuminate\Support\Facades\DB;
+use PhpOffice\PhpSpreadsheet\Cell\DataType;
 use PhpOffice\PhpSpreadsheet\IOFactory;
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
 use PhpOffice\PhpSpreadsheet\Style\Alignment;
@@ -444,7 +445,8 @@ class Orders extends Auth{
 			// 单元格内容写入
 			$sheet->setCellValue('A'.$row, $value['order_id']);
 			$sheet->setCellValue('B'.$row, $value['custom_uid']);
-			$sheet->setCellValue('C'.$row, $value['custom_name']);
+            //避免 = + - 识别成公式
+            $sheet->setCellValueExplicit('C'.$row, $value['custom_name'],DataType::TYPE_STRING);
 			$sheet->setCellValue('D'.$row, $value['status']);
 			$sheet->setCellValue('E'.$row, $value['contact_name']);
 			$sheet->setCellValue('F'.$row, $value['contact_phone']);

+ 65 - 0
app/Http/Controllers/Admin/Regiment.php

@@ -0,0 +1,65 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Models\Regiment as Model;
+use App\Models\Product as Product;
+use App\Models\RegimentActive as RegimentActive;
+use App\Models\Custom as Custom;
+use Illuminate\Support\Facades\DB;
+
+
+/**
+ * 团列表
+ *
+ * @author    jun
+ * 
+ */
+class Regiment extends Auth{
+
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','拼团活动');
+		$this->assign('breadcrumb2','团列表');
+	}
+
+    /**
+     * 列表页
+     *
+     * */
+    public function index(Model $Model,Product $Product,RegimentActive  $RegimentActive,Custom  $Custom){
+        // 接收参数
+        $name					= request('name','');
+        // 查询条件
+        $map 					= [];
+        // 组合条件
+        if( $name )				$map[] = ['regiment.name','=',$name];
+        $select = [
+            'regiment.*',
+            'regiment_active.name as active_name',
+            'product.name as product_name',
+            'custom.username as username',
+        ];
+        // 查询数据
+        $list					= $Model->query()
+            ->join('regiment_active','regiment_active.id','=','regiment.active_id')
+            ->join('product','product.id','=','regiment.product_id')
+            ->leftJoin('custom','custom.uid','=','regiment.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']);
+            if ($v['custom_uid']){
+                $v['custom_code']   = $Custom->idToCode($v['custom_uid']);
+            }
+        }
+        // 分配数据
+        $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+        $this->assign('list',$list);
+        // 加载模板
+        return 					$this->fetch();
+    }
+
+}

+ 229 - 0
app/Http/Controllers/Admin/RegimentActive.php

@@ -0,0 +1,229 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Http\Requests\Admin\RegimentActive as Request;
+use App\Models\RegimentActive as Model;
+use App\Models\Product as Product;
+use Illuminate\Support\Facades\DB;
+
+
+/**
+ * 拼团活动
+ *
+ * @author    jun
+ * 
+ */
+class RegimentActive extends Auth{
+
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','拼团活动');
+		$this->assign('breadcrumb2','拼团活动列表');
+	}
+
+    /**
+     * 列表页
+     *
+     * */
+    public function index(Model $Model){
+        // 接收参数
+        $name					= request('name','');
+        // 查询条件
+        $map 					= [];
+        // 组合条件
+        if( $name )				$map[] = ['regiment_active.name','=',$name];
+        $select = ['regiment_active.*','product.name as product_name'];
+        // 查询数据
+        $list					= $Model->query()
+            ->join('product','product.id','=','regiment_active.product_id')
+            ->where($map)
+            ->select($select)
+            ->orderByDesc('regiment_active.id')
+            ->paginate(config('page_num',10));
+        // 循环处理数据
+        foreach ($list as $key => &$value) {
+            $value['code']	= $Model->idToCode($value['id']);
+        }
+        // 分配数据
+        $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+        $this->assign('list',$list);
+        // 加载模板
+        return 					$this->fetch();
+    }
+
+    /**
+     * 添加
+     *
+     * */
+    public function add(Request $request, Model $Model, Product $Product){
+        if( request()->isMethod('post') ){
+            // 验证参数
+            $request->scene('add')->validate();
+            // 接收数据
+            $product_code		            = request('product_code','');
+            $data['product_id']		        = $Product->codeToId($product_code);
+            if (!$data['product_id'])       return json_send(['code'=>'error','msg'=>'产品不存在']);
+            $data['regiment_price']		    = request('regiment_price',0);
+            $data['quota']	                = request('quota','');
+            $data['name']	                = request('name','');
+            $data['number']	                = request('number',0);
+            $expiration_day	                = request('expiration_day',0);
+            $expiration_hours	            = request('expiration_hours',0);
+            $data['expiration']	            = $expiration_day * 24 + $expiration_hours;
+            $data['start_time']		        = request('start_time','');
+            $data['end_time']		        = request('end_time','');
+            $data['start_time']		        = $data['start_time'] ? strtotime($data['start_time']) : 0;
+            $data['end_time']		        = $data['end_time'] ? strtotime($data['end_time']) : 0;
+            $data['participation_number']	= request('participation_number',0);
+            $data['open_people']			= request('open_people',1);
+            $data['partake_people']			= request('partake_people',1);
+            $data['exceed_people']			= request('exceed_people',1);
+            $data['automatic']				= request('automatic',1);
+            $data['virtually']				= request('virtually',1);
+            $data['status']			        = 1;
+            $where                          =   [
+                ['status','=', 1],
+                ['product_id','=', $data['product_id']],
+                ['end_time','>=', time()]
+            ];
+            $product_res                    = $Model::query()->where($where)->first();
+            if ($product_res)               return json_send(['code'=>'error','msg'=>'该产品正在参加拼团活动']);
+            // 写入数据表
+            $id						        = $Model->add($data);
+            // 如果操作失败
+            if( !$id ) 				        return json_send(['code'=>'error','msg'=>'新增失败']);
+            // 记录行为
+            $this->addAdminHistory(admin('uid'),$Model->getTable(),$id,1,[],$data);
+            // 告知结果
+            return					json_send(['code'=>'success','msg'=>'新增成功','action'=>'add']);
+        }
+        // 标签列表
+        $tagList					= [];
+        $cityList					= [];
+        // 分配数据
+        $this->assign('cityList',$cityList);
+        $this->assign('tagList',$tagList);
+        $this->assign('crumbs','新增');
+        // 加载模板
+        return						$this->fetch();
+    }
+
+    /**
+     * 修改
+     *
+     * */
+    public function edit(Request $request,Model $Model,Product $Product){
+        // 接收参数
+        $id							= request('id',0);
+        // 查询用户
+        $oldData					= $Model->where(['id'=>$id])->first()->toArray();
+        // 修改
+        if(request()->isMethod('post')){
+            // 验证参数
+            $request->scene('edit')->validate();
+            // 接收数据
+            $product_code		            = request('product_code','');
+            $data['product_id']		        = $Product->codeToId($product_code);
+            if (!$data['product_id'])       return json_send(['code'=>'error','msg'=>'产品不存在']);
+            $data['regiment_price']		    = request('regiment_price',0);
+            $data['quota']	                = request('quota','');
+            $data['name']	                = request('name','');
+            $data['number']	                = request('number',0);
+            $expiration_day	                = request('expiration_day',0);
+            $expiration_hours	            = request('expiration_hours',0);
+            $data['expiration']	            = $expiration_day * 24 + $expiration_hours;
+            $data['start_time']		        = request('start_time','');
+            $data['end_time']		        = request('end_time','');
+            $data['start_time']		        = $data['start_time'] ? strtotime($data['start_time']) : 0;
+            $data['end_time']		        = $data['end_time'] ? strtotime($data['end_time']) : 0;
+            $data['participation_number']	= request('participation_number',0);
+            $data['open_people']			= request('open_people',1);
+            $data['partake_people']			= request('partake_people',1);
+            $data['exceed_people']			= request('exceed_people',1);
+            $data['automatic']				= request('automatic',1);
+            $data['virtually']				= request('virtually',1);
+            // 写入数据表
+            $result					= $Model->edit($id,$data);
+            // 如果操作失败
+            if( !$result ) 			return json_send(['code'=>'error','msg'=>'修改失败']);
+            // 记录行为
+            $this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,$oldData,$data);
+            // 告知结果
+            return					json_send(['code'=>'success','msg'=>'修改成功','action'=>'edit']);
+        }
+        // 错误告知
+        if( !$oldData )				return $this->error('查无数据');
+        $oldData['product_code']	= $Product->idToCode($oldData['product_id']);
+        $this->assign('oldData',$oldData);
+        $this->assign('crumbs','修改');
+        // 加载模板
+        return						$this->fetch();
+    }
+
+    /**
+     * 修改状态
+     *
+     * */
+    public function set_status(Request $request,Model $Model){
+        // 验证参数
+        $request->scene('set_status')->validate();
+        // 设置状态
+        $id				= request('id',0);
+        $status			= request('status',0);
+        // 查询用户
+        $oldData		= $Model->where(['id'=>$id])->first();
+        // 如果用户不存在
+        if( !$oldData )	return json_send(['code'=>'error','msg'=>'数据不存在']);
+        // 执行修改
+        $result			= $Model->edit($id,['status'=>$status]);
+        // 提示新增失败
+        if( !$result )	return json_send(['code'=>'error','msg'=>'设置失败']);
+        // 记录行为
+        $this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,$oldData,['status'=>$status]);
+        // 告知结果
+        return 			json_send(['code'=>'success','msg'=>'设置成功','path'=>'']);
+    }
+    /**
+     * 复制
+     *
+     * */
+    public function copy(Request $request,Model $Model,Clockin $Clockin){
+        // 验证参数
+        $request->scene('copy')->validate();
+        // 设置状态
+        $id				= request('id',0);
+        $time           =   time();
+        // 查询
+        $data		    = $Model->where(['id'=>$id])->first()->toArray();
+        if (!$data)     json_send(['code'=>'error','msg'=>'复制失败,活动不存在']);
+        $clockinList    = $Clockin->getActiveList($id);
+        DB::beginTransaction();
+        try {
+            unset($data['id']);
+            $data['status'] = 1;
+            $data['name'] = $data['name'].'复制';
+            //复制活动
+            $newId          = $Model->add($data);
+            if (!$newId){
+                DB::rollBack();
+                return json_send(['code'=>'error','msg'=>'复制失败']);
+            }
+            if ($clockinList){
+                foreach ($clockinList as &$clockin){
+                    $clockin['active_id'] = $newId;
+                    $clockin['insert_time'] = $time;
+                    $clockin['update_time'] = $time;
+                    unset($clockin['id']);
+                }
+                $re = $Clockin->Query()->insert($clockinList);
+                if (!$re)   return  json_send(['code'=>'error','msg'=>'复制失败']);
+            }
+            DB::commit();
+        }catch (\Exception $e){
+            // 回退数据
+            DB::rollBack();
+            // 失败提示
+            return						json_send(['code'=>'error','msg'=>'复制失败','data'=>['error'=>$e->getMessage().$e->getLine()]]);
+        }
+        return json_send(['code'=>'success','msg'=>'复制成功','path'=>'']);
+    }
+}

+ 69 - 0
app/Http/Controllers/Admin/RegimentRecord.php

@@ -0,0 +1,69 @@
+<?php namespace App\Http\Controllers\Admin;
+
+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 PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\Fill;
+
+/**
+ * 客户签到记录
+ *
+ * @author    jun
+ *
+ */
+class RegimentRecord extends Auth{
+
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','拼团活动');
+		$this->assign('breadcrumb2','拼团记录');
+	}
+
+    /**
+     * 列表页
+     *
+     * */
+    public function index(Model $Model, Product $Product, RegimentActive $RegimentActive, Custom $Custom,Orders $Orders){
+        // 接收参数
+        $name					= request('name','');
+        // 查询条件
+        $map 					= [];
+        // 组合条件
+        if( $name )				$map[] = ['regiment_record.name','=',$name];
+        $select = [
+            'regiment_record.*',
+            'regiment.status as regiment_status',
+            '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']);
+        }
+        // 分配数据
+        $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+        $this->assign('list',$list);
+        // 加载模板
+        return 					$this->fetch();
+    }
+
+}

+ 358 - 0
app/Http/Controllers/Api/Orders.php

@@ -13,6 +13,9 @@ use App\Models\CustomCoupon;
 use App\Models\CustomScore;
 use App\Models\OrdersAddr;
 use App\Models\OrdersProduct;
+use App\Models\Regiment;
+use App\Models\RegimentActive;
+use App\Models\RegimentRecord;
 use App\Models\ShopCart;
 use Illuminate\Support\Facades\DB;
 use App\Models\WeiBan\Tags as WeiBanTags;
@@ -531,4 +534,359 @@ class Orders extends Api{
 		return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$orderInfo]);
 	}
 
+    /**
+     * 创建拼团订单						 	/api/orders/create_regiment
+     *
+     * */
+    public function create_regiment(Request $request,Custom $Custom,City $City,Model $Model,WeiBanTags $WeiBanTags,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,CustomAddr $CustomAddr,CustomScore $CustomScore){
+        // 接口验签
+        // $this->verify_sign();
+        // 验证参数
+        $request->scene('create')->validate();
+        // 检查登录
+        $uid							= $this->checkLogin();
+        // 接收参数
+        $isCart							= request('is_cart',0);
+        $productList					= request('product_list','[]');
+        $customCouponId					= request('custom_coupon_id',0);
+        $addrId							= request('addr_id',0);
+        $regimentId					    = request('regiment_id',0);
+        $regimentActiveId				= request('regiment_active_id',0);
+        $btnType					    = request('btn_type',0);
+        // 如果不存在数据
+        if( !$addrId )					return json_send(['code'=>'error','msg'=>'请选择收货地址','data'=>['error'=>'请选择收货地址']]);
+        // 解码购买信息
+        $buyList						= json_decode($productList,true);
+        // 如果不存在数据
+        if( empty($buyList) )			return json_send(['code'=>'error','msg'=>'没有需下单的产品','data'=>['error'=>'产品列表为空']]);
+        $time = time();
+        // 选择地址
+        $addr							= $CustomAddr->getOne($addrId);
+        // 如果不存在数据
+        if( !$addr )					return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
+        // 重组数据
+        $addr							= ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
+        // 获取客户城市ID
+        $custom							= $Custom->getOne($uid);
+        // 如果不存在的话
+        if( !$custom )					return json_send(['code'=>'no_login','msg'=>'用户不存在,请重新登录','data'=>['error'=>'用户不存在,请重新登录']]);
+        // 如果不存在的话
+        if( !$custom['city_id'] )		return json_send(['code'=>'error','msg'=>'请选择所在城市后下单','data'=>['error'=>'请选择所在城市后下单']]);
+        // 获取城市ID
+        $cityId							= $custom['city_id'];
+        $cityName						= $City->getOne($cityId,'name');
+        $pid 							= $City->getOne($cityId,'pid');
+        $province						= $City->getOne($pid,'name');
+        // 判断选择的城市名称是不是一致
+        if( $cityName != $addr['contact_city'] ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.$province.'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
+        //获取团活动信息
+        $regimentActiveInfo             = RegimentActive::query()
+            ->where([['id','=',$regimentActiveId],['status','=',1],['start_time','<=',$time],['end_time','>=',$time]])
+            ->first();
+        if (!$regimentActiveInfo)       return json_send(['code'=>'error','msg'=>'拼团活动不存在','data'=>['error'=>'拼团活动不存在']]);
+        //是否符合开团条件
+        if($btnType == 3){
+            if ($regimentActiveInfo['open_people'] == 1){
+                if ($custom['insert_time'] > $regimentActiveInfo['start_time']) return json_send(['code'=>'error','msg'=>'此活动只允许老用户开团','data'=>['error'=>'此活动只允许老用户开团']]);
+            }
+            if ($regimentActiveInfo['open_people'] == 2){
+                if ($custom['insert_time'] < $regimentActiveInfo['start_time']) return json_send(['code'=>'error','msg'=>'此活动只允许新用户开团','data'=>['error'=>'此活动只允许新用户开团']]);
+            }
+        }
+        //是否符合参团条件
+        if($btnType == 4){
+            if ($regimentActiveInfo['partake_people'] == 1){
+                if ($custom['insert_time'] > $regimentActiveInfo['start_time']) return json_send(['code'=>'error','msg'=>'此活动只允许老用户参与','data'=>['error'=>'此活动只允许老用户开团']]);
+            }
+            if ($regimentActiveInfo['open_people'] == 2){
+                if ($custom['insert_time'] < $regimentActiveInfo['start_time']) return json_send(['code'=>'error','msg'=>'此活动只允许新用户参与','data'=>['error'=>'此活动只允许新用户开团']]);
+            }
+            //查询团信息
+            $regimentInfo = Regiment::query()
+                ->where([['id','=',$regimentId],['status','=',1],['start_time','<=',$time],['end_time','>=',$time]])
+                ->first();
+            if (!$regimentInfo)       return json_send(['code'=>'error','msg'=>'拼团活动不存在','data'=>['error'=>'拼团活动不存在']]);
+        }
+        //查询用户参团记录
+        $regimentRecordCount             = RegimentRecord::query()
+            ->where([['custom_uid','=',$uid],['active_id','=',$regimentActiveInfo['id']]])
+            ->count('id');
+        if ($regimentRecordCount >= $regimentActiveInfo['participation_number'])    return json_send(['code'=>'error','msg'=>'该活动每人仅限参与'.$regimentActiveInfo['participation_number'].'次','data'=>['error'=>'该活动每人仅限参与'.$regimentActiveInfo['participation_number'].'次']]);
+
+        $tags							= $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
+        // 查询产品信息
+        $productList					= $Product->getListByIds(array_column($buyList,'product_id'));
+        // 当前时间
+        $time 							= time();
+        // 产品以商业公司分组,方便写入订单
+        $orderProduct					= [];
+        // 产品价格同级,用于优惠券计算
+        $productPrice					= [];
+        $priceTotal					    = 0;
+        $payTotal					    = 0;
+        $buyInfo                        = $buyList[0];
+        if ($buyInfo){
+            if( empty($productList[$buyInfo['product_id']]) )	return json_send(['code'=>'error','msg'=>'产品不存在或已下架','data'=>['error'=>'产品不存在或已下架=>'.$buyInfo['product_id']]]);
+            // 获取产信息
+            $productInfo 					= $productList[$buyInfo['product_id']];
+            // 判断是不是可以参与
+            if( $productInfo['tag_scope'] ) {
+                // 解析数组
+                $productInfo['tag_scope']	= explode(',',$productInfo['tag_scope']);
+                // 标签范围限定时,默认不能参与
+                $allowJoin 					= 0;
+                // 判断标签是不是存在
+                foreach ($tags as $value) 	{
+                    // 标签范围内,允许参加
+                    if( in_array($value['name'],$productInfo['tag_scope']) )  $allowJoin = 1;
+                }
+                // 如果不能参与
+                if( !$allowJoin )	return json_send(['code'=>'error','msg'=>'不在 '.$productInfo['product_name'].' 参与范围','data'=>['error'=>'不在标签范围内']]);
+            }
+            // 判断是不是可以参与
+            if( $productInfo['tag_exclude'] ) {
+                // 解析数组
+                $productInfo['tag_exclude']	= explode(',',$productInfo['tag_exclude']);
+                // 判断标签是不是存在
+                foreach ($tags as $value) 	{
+                    // 标签排除范围内,不允许参加
+                    if( in_array($value['name'],$productInfo['tag_exclude']) )  return json_send(['code'=>'error','msg'=>'不在 '.$productInfo['product_name'].' 可参与范围','data'=>['error'=>'用户在标签排除范围']]);
+                }
+            }
+            //拼团活动限购
+            if ($regimentActiveInfo['quota']){
+                if ($buyInfo['buy_num'] > $regimentActiveInfo['quota'])     return json_send(['code'=>'error','msg'=>'超过拼团限购','data'=>['error'=>'拼团限购=>'.$buyInfo['product_id']]]);
+            }
+            // 如果产品限购
+            if( $productInfo['quota'] )	{
+                // 是否在限购时间,当前时间大于开始时间,并且小于结束时间
+                if( $productInfo['quota_start'] <= $time && $time <= $productInfo['quota_end'] ){
+                    // 通过时间查询商品的购买总数
+                    $total 				= $OrdersProduct->query()->where([['custom_uid','=',$uid],['product_id','=',$productInfo['id']],['insert_time','>=',$productInfo['quota_start']],['insert_time','<=',$productInfo['quota_end']]])->sum('buy_num');
+                    // 判断限购数量
+                    $total	 			= $buyInfo['buy_num'] + $total;
+                    // 如果超过数量
+                    if( $total > $productInfo['quota'] ) return json_send(['code'=>'error','msg'=>'限购'.$productInfo['quota'].'套-'.$productInfo['product_name'],'data'=>['error'=>'已超限=>'.($total - $productInfo['quota'])]]);
+                }
+            }
+            // 需要扣除的库存
+            $productList[$buyInfo['product_id']]['decr'] = $buyInfo['buy_num'];
+            // 判断库存
+            if( $productInfo['stock'] < $productList[$buyInfo['product_id']]['decr'] )  return json_send(['code'=>'error','msg'=>$productInfo['product_name'].'-库存不足','data'=>['error'=>'产品库存不足=>'.$buyInfo['product_id']]]);
+            // 计算价值
+            $priceTotal					= $buyInfo['buy_num'] * $regimentActiveInfo['regiment_price'];
+            $payTotal					= $buyInfo['buy_num'] * $productInfo['price'];
+        }
+        $orderInfo = [
+            'custom_uid'		    => $uid,
+            'status'		        => 10,
+            'pay_total'		        => $payTotal,
+            'price_total'		    => $priceTotal,
+            'business_id'		    => $productList[$buyInfo['product_id']]['business_id'],
+        ];
+        // 赠送积分
+        $orderInfo['order_score']		= (config('order_score_send',0) && floor( $orderInfo['pay_total'] * 1 ) > 0 )  ? floor( $orderInfo['pay_total'] * 1 ) : 0;
+        $orderProductInfo = [
+            'product_name'		    => $productList[$buyInfo['product_id']]['product_name'],
+            'sku_attr_names'		=> $productList[$buyInfo['product_id']]['sku_attr_names'],
+            'product_thumb'		    => $productList[$buyInfo['product_id']]['product_thumb'],
+            'buy_num'		        => $buyInfo['buy_num'],
+            'price_total'		    => $priceTotal,
+            'pay_total'		        => $buyInfo['buy_num'] * $productList[$buyInfo['product_id']]['price'],
+            'product_id'		    => $buyInfo['product_id'],
+            'custom_uid'		    => $uid,
+            'business_id'		    => $productList[$buyInfo['product_id']]['business_id'],
+        ];
+        // 组合数据,写入订单表,子表
+        DB::beginTransaction();
+        // 写入数据
+        try {
+            // 扣减商品库存
+            foreach ($productList as $key => $value) {
+                // 扣减库存
+                $result 				= $Product->edit($value['id'],['stock'=>DB::raw('stock+-'.$value['decr'])]);
+                // 判断结果
+                if( !$result ) 			{
+                    // 回退数据
+                    DB::rollBack();
+                    // 错误提示
+                    return 				json_send(['code'=>'error','msg'=>'库存扣减失败','data'=>['error'=>'库存扣减失败']]);
+                }
+            }
+            //创建拼团
+            if($btnType == 3){
+                $regimentInfo       =   [
+                    'custom_uid'    =>  $uid,
+                    'active_id'     =>  $regimentActiveInfo['id'],
+                    'product_id'    =>  $buyInfo['product_id'],
+                    'people_number' =>  1,
+                    'status'        =>  1,
+                    'start_time'    =>  $time,
+                    'end_time'      =>  $time + $regimentActiveInfo['expiration']*3600,
+                    'update_time'   =>  $time,
+                    'insert_time'   =>  $time,
+                ];
+                $regimentId 			= Regiment::query()->insert($regimentInfo);
+                if( !$regimentId )			{
+                    // 回退数据
+                    DB::rollBack();
+                    // 提示信息
+                    return				json_send(['code'=>'error','msg'=>'创建拼团失败','data'=>['error'=>'创建拼团失败']]);
+                }
+            }
+            $orderInfo['regiment_id']   = $regimentId;
+            // 创建总订单
+            $orderId				= $Model->add($orderInfo);
+            // 如果订单写入失败
+            if( !$orderId )			{
+                // 回退数据
+                DB::rollBack();
+                // 错误提示
+                return 				json_send(['code'=>'error','msg'=>'下单失败','data'=>['error'=>'订单创建失败']]);
+            }
+            $orderProductInfo['order_id'] = $orderId;
+            // 写入子表
+            $result					= $OrdersProduct->query()->insert($orderProductInfo);
+            // 如果扣减失败
+            if( !$result )			{
+                // 回退数据
+                DB::rollBack();
+                // 提示信息
+                return				json_send(['code'=>'error','msg'=>'子订单创建失败','data'=>['error'=>'子订单创建失败']]);
+            }
+            // 写入订单地址表
+            $addr['order_id']		= $orderId;
+            // 写入订单地址表
+            $result 				= $OrdersAddr->add($addr);
+            // 地址写入失败
+            if( !$result )			{
+                // 回退数据
+                DB::rollBack();
+                // 提示信息
+                return				json_send(['code'=>'error','msg'=>'地址写入失败','data'=>['error'=>'地址写入失败']]);
+            }
+            if($btnType == 4){
+                // 拼团人数加1
+                $inc				=   Regiment::query()->where('id','=',$regimentId)->increment('people_number',1);
+                if( !$inc )			{
+                    // 回退数据
+                    DB::rollBack();
+                    // 提示信息
+                    return				json_send(['code'=>'error','msg'=>'创建拼团失败','data'=>['error'=>'创建拼团失败']]);
+                }
+                //团满
+                if ((($regimentInfo['people_number'] + 1) == $regimentActiveInfo['number']) && $regimentActiveInfo == 1) {
+                    $res            =   regiment::query()->where('id','=',$regimentId)->update(['status'=>3]);
+                    if( !$res )			{
+                        // 回退数据
+                        DB::rollBack();
+                        // 提示信息
+                        return				json_send(['code'=>'error','msg'=>'创建拼团失败','data'=>['error'=>'创建拼团失败']]);
+                    }
+                    //修改订单
+                    $orderRes       =   $Model::query()->where('regiment_id','=',$regimentId)->update(['status'=>'1']);
+                    if( !$orderRes )			{
+                        // 回退数据
+                        DB::rollBack();
+                        // 提示信息
+                        return				json_send(['code'=>'error','msg'=>'创建拼团失败','data'=>['error'=>'创建拼团失败']]);
+                    }
+                    //赠送积分
+                    $orderList      =   $Model::query()->where('regiment_id','=',$regimentId)->get();
+                    foreach ($orderList as $key => $value) {
+                        if( $value['order_score'] > 0 ) $CustomScore->trade($orderInfo['custom_uid'],$value['id'],$value['order_score'],5,1);
+                    }
+                }
+            }
+            //拼团记录
+            $regimentRecordInfo       =   [
+                'custom_uid'    =>  $uid,
+                'regiment_id'   =>  $regimentId,
+                'active_id'     =>  $regimentActiveInfo['id'],
+                'product_id'    =>  $buyInfo['product_id'],
+                'order_id'      =>  $orderId,
+                'update_time'   =>  $time,
+                'insert_time'   =>  $time,
+            ];
+            $result 				= RegimentRecord::query()->insert($regimentRecordInfo);
+            if( !$result )			{
+                // 回退数据
+                DB::rollBack();
+                // 提示信息
+                return				json_send(['code'=>'error','msg'=>'创建拼团记录失败','data'=>['error'=>'创建拼团记录失败']]);
+            }
+            // 提交数据
+            DB::commit();
+            // 返回结果
+            return						json_send(['code'=>'success','msg'=>'下单成功','data'=>['id'=>null]]);
+            // 返回结果
+        } catch (\Throwable $th) {
+            // 回退数据
+            DB::rollBack();
+            // 判断结果,如果库存扣减失败的话
+            if( stripos($th->getMessage(),'UNSIGNED') )  return json_send(['code'=>'error','msg'=>'库存不足','data'=>['error'=>'产品库存扣减失败']]);
+            // 下单失败提示
+            return						json_send(['code'=>'error','msg'=>'系统异常,请稍后再试','data'=>['error'=>$th->getMessage().$th->getLine()]]);
+        }
+    }
+    /**
+     * 取消拼团				/api/orders/cancel_regiment
+     *
+     * */
+    public function cancel_regiment( Request $request, Model $Model,OrdersProduct $OrdersProduct,CustomScore $CustomScore){
+        // 验证参数
+        $request->scene('cancel')->validate();
+        // 检查登录
+        $uid			= $this->checkLogin();
+        // 接收参数
+        $id				= request('id',0);
+        $status 		= 4;
+        // 获取产品和数量
+        $oldData 		= $Model->query()->where([['id','=',$id],['custom_uid','=',$uid]])->first(['id','order_score','status','custom_uid','insert_time']);
+        // 如果用户不存在
+        if( !$oldData )	return json_send(['code'=>'error','msg'=>'订单不存在']);
+        // 如果已经取消
+        if( $oldData['status'] == 4 ) 	return json_send(['code'=>'error','msg'=>'订单已取消']);
+        // 如果团不存在
+        if( !$oldData['regiment_id'] )	return json_send(['code'=>'error','msg'=>'拼团不存在']);
+        // 组合数据,写入订单表,子表
+        DB::beginTransaction();
+        try{
+            // 查询数据
+            $result			= $Model->setOrderStatus($id,$status,$OrdersProduct);
+            // 提示新增失败
+            if( isset($result['error']) )	{
+                // 回退数据
+                DB::rollBack();
+                // 提示信息
+                return		json_send(['code'=>'error','msg'=>$result['error'],'data'=>['error'=>$result['error']]]);
+            }
+            //取消加入团
+            $regimentRes    = Regiment::query()->where('id','=',$oldData['regiment_id'])->decrement('people_number',1);
+            if( !$regimentRes )	{
+                // 回退数据
+                DB::rollBack();
+                // 提示信息
+              return json_send(['code'=>'error','msg'=>'取消拼团失败']);
+            }
+            //修改拼团记录
+            $regimentRes    = RegimentRecord::query()->where([['order_id','=',$oldData['id'],]])->update(['status'=>'2']);
+            if( !$regimentRes )	{
+                // 回退数据
+                DB::rollBack();
+                // 提示信息
+                return json_send(['code'=>'error','msg'=>'取消拼团失败']);
+            }
+            // 提交数据
+            DB::commit();
+            // 告知结果
+            return			json_send(['code'=>'success','msg'=>'取消成功']);
+            // 返回结果
+        } catch (\Throwable $th) {
+            // 回退数据
+            DB::rollBack();
+            // 下单失败提示
+            return			json_send(['code'=>'error','msg'=>'取消失败','data'=>['error'=>$th->getMessage().$th->getLine()]]);
+        }
+    }
 }

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

@@ -10,6 +10,8 @@ use App\Models\Product\City as ProductCity;
 use App\Models\Product\Spec as ProductSpec;
 use App\Models\Product\Skus as ProductSkus;
 use App\Models\ProductPhoto;
+use App\Models\RegimentActive;
+use App\Models\Regiment;
 
 /**
  * 产品接口
@@ -27,7 +29,7 @@ class Product extends Api{
 	 * @param	int		$limit			每页条数,默认10条
 	 * 
 	 * */
-	public function get_list(Request $request,Model $Model,Custom $Custom){
+	public function get_list(Request $request,Model $Model,Custom $Custom,RegimentActive $RegimentActive){
 		// 接口验签
 		// $this->verify_sign();
         // 验证参数
@@ -60,10 +62,25 @@ class Product extends Api{
 		$data['per_page']			= $Paginator->perPage();
 		$data['last_page']			= $Paginator->lastPage();
 		$data['data']				= $Paginator->items();
+        $time = time();
 		// 处理请求
 		foreach ( $data['data'] as $key => $value ) {
 			// 处理数据
 			$value['thumb'] 		= path_compat($value['thumb']);
+            $regimentWhere = [
+                ['status','=',1],
+                ['start_time','<=',$time],
+                ['end_time','>=',$time],
+                ['product_id','=',$value['id']]
+            ];
+            $regiment = $RegimentActive::query()->where($regimentWhere)->first();
+            if ( $regiment ){
+                $value['regiment_number']   = $regiment['number'];
+                $value['regiment_id']       = $regiment['id'];
+                $value['regiment_title']    = $regiment['number'].'人团';
+            }else{
+                $value['regiment_id'] = null;
+            }
 			// 重组数据
 			$data['data'][$key]		= $value;
 		}
@@ -78,7 +95,7 @@ class Product extends Api{
 	 * @param	int     $id		        产品id
 	 * 
 	 * */
-	public function get_detail(Request $request,Model $Model,ProductPhoto $ProductPhoto,Business $Business,ProductAttr $ProductAttr,ProductSpec $ProductSpec,ProductSkus $ProductSkus ){
+	public function get_detail(Request $request,Model $Model,ProductPhoto $ProductPhoto,Business $Business,ProductAttr $ProductAttr,ProductSpec $ProductSpec,ProductSkus $ProductSkus,RegimentActive $RegimentActive,Regiment $Regiment ){
 		// 接口验签
 		// $this->verify_sign();
         // 验证参数
@@ -133,6 +150,50 @@ class Product extends Api{
 		// 手机号
 		if( isset($data['business_info']['phone']) ) unset($data['business_info']['phone']);
 		if( isset($data['business_info']['logopic']) ) $data['business_info']['logopic'] = path_compat($data['business_info']['logopic']);
+        //拼团数据
+        $time = time();
+        $regimentWhere = [
+            ['status','=',1],
+            ['start_time','<=',$time],
+            ['end_time','>=',$time],
+            ['product_id','=',$data['id']]
+        ];
+        $regimentActive = $RegimentActive::query()
+            ->where($regimentWhere)
+            ->first();
+        $data['regiment_list']              = [];
+        $data['automatic_info']             = [];
+        if ( $regimentActive ){
+            $data['regiment_number']        = $regimentActive['number'];
+            $data['regiment_active_id']     = $regimentActive['id'];
+            $data['regiment_price']         = $regimentActive['regiment_price'];
+            $data['regiment_quota']         = $regimentActive['quota'];
+            $data['regiment_active']        = $regimentActive;
+            $data['automatic_info']         = [];
+            if ($regimentActive['automatic'] == 1){
+                $data['regiment_title']         = '多人团';
+                $automaticInfo              = $Regiment::query()->where([['status','=',1],['active_id','=',$regimentActive['id']],['start_time','<=',$time],['end_time','>=',$time]])->first();
+                $data['automatic_info']     = $automaticInfo;
+                $data['regiment_type']      = 1;
+            }else{
+                $data['regiment_title']     = $regimentActive['number'].'人团';
+                $data['regiment_type']      = 2;
+                $regiment = $Regiment::query()
+                    ->join('custom','custom.uid','=','regiment.custom_uid')
+                    ->where([['regiment.product_id','=',$data['id']],['regiment.status','=',1],['regiment.start_time','<=',$time],['regiment.end_time','>=',$time]])
+                    ->select(['regiment.*','custom.username','custom.userpic'])
+                    ->get();
+                if ($regiment){
+                    foreach ($regiment as &$value) {
+                        $value['userpic']	= $value['userpic'] ? path_compat($value['userpic']) : '';
+                    }
+                    $data['regiment_list']        = $regiment;
+                }
+            }
+        }else{
+            $data['regiment_active_id'] = null;
+            $data['regiment_type']      = 0;
+        }
 		// 返回结果
 		return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
 	}

+ 52 - 0
app/Http/Requests/Admin/RegimentActive.php

@@ -0,0 +1,52 @@
+<?php namespace App\Http\Requests\Admin;
+
+use App\Http\Requests\BaseRequest;
+
+/**
+ * 拼团活动验证器
+ * 
+ */
+class RegimentActive extends BaseRequest
+{
+	/**
+     * 获取应用于请求的规则
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        // 返回结果
+        return      [
+            // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
+            // 验证字段,验证规则,提示信息
+            'name' 			    => 'required|unique:score_clockin_active,name,'.request('id',0),
+            'id'                => 'required|integer|gt:0',
+        ];
+    }
+
+
+    // 场景列表
+    protected   $scenes         = [
+        'add'  		            => ['name'],
+        'edit'  		        => ['id','name'],
+        'set_status'  		    => ['id'],
+        'copy'  		        => ['id'],
+    ];
+
+    /**
+     * 获取已定义验证规则的错误消息
+     *
+     * @return array
+     */
+    public function messages()
+    {
+        return [
+            'name.required'     => '活动名称必填',
+            'name.unique'	    => '活动名称已经存在',
+            'id.required'       => 'ID未知',
+            'id.integer'        => 'ID格式错误',
+            'id.gt'   		    => 'ID格式错误',
+        ];
+    }
+}
+?>

+ 129 - 0
app/Models/Regiment.php

@@ -0,0 +1,129 @@
+<?php namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use App\Facades\Servers\Redis\Redis;
+use App\Models\CustomScore;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 生成的团
+ * 
+ */
+class Regiment extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'regiment';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+
+    /**
+     * 添加数据
+     *
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $id;
+    }
+
+    /**
+     * 添加数据
+     *
+     */
+    public function edit($id,$data)
+    {
+        // 更新时间
+        $data['update_time']                = time();
+        // 写入数据表
+        $result						        = $this->query()->where(['id'=>$id])->update($data);
+        // 如果操作失败
+        if( !$result )                      return $result;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $result;
+    }
+
+    /**
+     * 获取列表
+     * @param   Bool    $force  是否强制更新
+     *
+     */
+    public function getList($force = false)
+    {
+        // 结果数据
+        //$list                   = $force ? [] : cache('admin:clockin:active:list');
+        $where[]                = ['status','=',0];
+        $where[]                = ['end_time','>=',time()];
+        $where[]                = ['start_time','<=',time()];
+        // 不存在数据
+        //if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where($where)->get(['id','name','banner_img','active_rule','status','start_time','end_time','tag_scope','city_ids']);
+            // 是否有数据
+            $data              = $data ? $data->toArray() : [];
+            // 循环处理数据
+            $list              = [];
+            // 进行更新
+            foreach ($data as $value) {
+                // 重组数据
+                $list[$value['id']] = $value;
+            }
+            // 存起来
+            //cache(['admin:clockin:active:list'=>$list]);
+        //}
+        // 返回结果
+        return                  $list;
+    }
+
+    /**
+     * 获取配置平台对应的应用数据
+     *
+     * @param   Array      用户ID
+     * @param   String     指定字段
+     *
+     */
+    public function getOne($id,$field='')
+    {
+        // 获取列表数据
+        $list                   = $this->getList();
+        // 获取数据
+        $one                    = isset($list[$id]) ? $list[$id] : [];
+        // 返回值
+        return                  empty($field) ? $one : ( isset($one[$field]) ? $one[$field] : null);
+    }
+
+    /**
+     * 编码转id
+     *
+     * @param  string $code 编码
+     *
+     */
+    public function codeToId($code){
+        return intval(str_ireplace('klpt','',$code));
+    }
+
+    /**
+     * id转编码
+     *
+     * @param  int  $id 编码
+     *
+     */
+    public function idToCode($id){
+        return 'klpt'. str_pad($id, 9, '0', STR_PAD_LEFT);
+    }
+
+}

+ 129 - 0
app/Models/RegimentActive.php

@@ -0,0 +1,129 @@
+<?php namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use App\Facades\Servers\Redis\Redis;
+use App\Models\CustomScore;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 拼团活动
+ * 
+ */
+class RegimentActive extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'regiment_active';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+
+    /**
+     * 添加数据
+     *
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $id;
+    }
+
+    /**
+     * 添加数据
+     *
+     */
+    public function edit($id,$data)
+    {
+        // 更新时间
+        $data['update_time']                = time();
+        // 写入数据表
+        $result						        = $this->query()->where(['id'=>$id])->update($data);
+        // 如果操作失败
+        if( !$result )                      return $result;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $result;
+    }
+
+    /**
+     * 获取列表
+     * @param   Bool    $force  是否强制更新
+     *
+     */
+    public function getList($force = false)
+    {
+        // 结果数据
+        //$list                   = $force ? [] : cache('admin:clockin:active:list');
+        $where[]                = ['status','=',0];
+        $where[]                = ['end_time','>=',time()];
+        $where[]                = ['start_time','<=',time()];
+        // 不存在数据
+        //if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where($where)->get();
+            // 是否有数据
+            $data              = $data ? $data->toArray() : [];
+            // 循环处理数据
+            $list              = [];
+            // 进行更新
+            foreach ($data as $value) {
+                // 重组数据
+                $list[$value['id']] = $value;
+            }
+            // 存起来
+            //cache(['admin:clockin:active:list'=>$list]);
+        //}
+        // 返回结果
+        return                  $list;
+    }
+
+    /**
+     * 获取配置平台对应的应用数据
+     *
+     * @param   Array      用户ID
+     * @param   String     指定字段
+     *
+     */
+    public function getOne($id,$field='')
+    {
+        // 获取列表数据
+        $list                   = $this->getList();
+        // 获取数据
+        $one                    = isset($list[$id]) ? $list[$id] : [];
+        // 返回值
+        return                  empty($field) ? $one : ( isset($one[$field]) ? $one[$field] : null);
+    }
+
+    /**
+     * 编码转id
+     *
+     * @param  string $code 编码
+     *
+     */
+    public function codeToId($code){
+        return intval(str_ireplace('klpt','',$code));
+    }
+
+    /**
+     * id转编码
+     *
+     * @param  int  $id 编码
+     *
+     */
+    public function idToCode($id){
+        return 'klpt'. str_pad($id, 9, '0', STR_PAD_LEFT);
+    }
+
+}

+ 111 - 0
app/Models/RegimentRecord.php

@@ -0,0 +1,111 @@
+<?php namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use App\Facades\Servers\Redis\Redis;
+use App\Models\CustomScore;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 团记录
+ * 
+ */
+class RegimentRecord extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'regiment_record';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+
+    /**
+     * 添加数据
+     *
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $id;
+    }
+
+    /**
+     * 添加数据
+     *
+     */
+    public function edit($id,$data)
+    {
+        // 更新时间
+        $data['update_time']                = time();
+        // 写入数据表
+        $result						        = $this->query()->where(['id'=>$id])->update($data);
+        // 如果操作失败
+        if( !$result )                      return $result;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $result;
+    }
+
+    /**
+     * 获取列表
+     * @param   Bool    $force  是否强制更新
+     *
+     */
+    public function getList($force = false)
+    {
+        // 结果数据
+        //$list                   = $force ? [] : cache('admin:clockin:active:list');
+        $where[]                = ['status','=',0];
+        $where[]                = ['end_time','>=',time()];
+        $where[]                = ['start_time','<=',time()];
+        // 不存在数据
+        //if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where($where)->get(['id','name','banner_img','active_rule','status','start_time','end_time','tag_scope','city_ids']);
+            // 是否有数据
+            $data              = $data ? $data->toArray() : [];
+            // 循环处理数据
+            $list              = [];
+            // 进行更新
+            foreach ($data as $value) {
+                // 重组数据
+                $list[$value['id']] = $value;
+            }
+            // 存起来
+            //cache(['admin:clockin:active:list'=>$list]);
+        //}
+        // 返回结果
+        return                  $list;
+    }
+
+    /**
+     * 获取配置平台对应的应用数据
+     *
+     * @param   Array      用户ID
+     * @param   String     指定字段
+     *
+     */
+    public function getOne($id,$field='')
+    {
+        // 获取列表数据
+        $list                   = $this->getList();
+        // 获取数据
+        $one                    = isset($list[$id]) ? $list[$id] : [];
+        // 返回值
+        return                  empty($field) ? $one : ( isset($one[$field]) ? $one[$field] : null);
+    }
+
+    
+
+}

+ 8 - 0
app/Models/Traits/Orders/Status.php

@@ -51,6 +51,14 @@ trait Status
                                         'id'            =>9,
                                         'name'          =>'回执审核',// 回执审核
                                         'state'         =>'回执审核',
+                                    ],'10'=>[
+                                        'id'            =>10,
+                                        'name'          =>'拼团中',// 回执审核
+                                        'state'         =>'拼团中',
+                                    ],'11'=>[
+                                        'id'            =>11,
+                                        'name'          =>'拼团失败',// 回执审核
+                                        'state'         =>'拼团失败',
                                     ]];
 
     /**

+ 5 - 0
public/nginx.htaccess

@@ -0,0 +1,5 @@
+location / {
+if (!-e $request_filename){
+rewrite ^/(.*)$ /index.php/$1 last;
+}
+}

BIN
public/uploads/images/1/1a87efa0115dc7aa13856b186c984d92.jpg


BIN
public/uploads/images/1/2.jpg


BIN
public/uploads/images/1/2.png


BIN
public/uploads/images/1/21a50dc854a8a293e65bbc9903748ae.png


BIN
public/uploads/images/1/4cfbfbf2f738f0de34c3d8f66a66a1a.png


BIN
public/uploads/images/1/O1CN01DfrUww1OEk0nOnFYN_2200569531674.jpg_q50.jpg


BIN
public/uploads/images/1/banlangen/thumb.jpg


BIN
public/uploads/images/1/banner/20241106-214350.jpg


BIN
public/uploads/images/1/banner/20241106-231932.jpg


BIN
public/uploads/images/1/banner/add_follow1.jpg


BIN
public/uploads/images/1/dane.png


BIN
public/uploads/images/1/ganmao/poster.jpg


BIN
public/uploads/images/1/ganmao/thumb.jpg


BIN
public/uploads/images/1/guizhouxinlao.jpg


BIN
public/uploads/images/1/hongpi/1.jpg


BIN
public/uploads/images/1/hongpi/2.jpg


BIN
public/uploads/images/1/hongpi/3.jpg


BIN
public/uploads/images/1/hongpi/4.jpg


BIN
public/uploads/images/1/hongpi/5.jpg


BIN
public/uploads/images/1/hongpi/6.jpg


BIN
public/uploads/images/1/hongpi/7.jpg


BIN
public/uploads/images/1/hongpi/8.jpg


BIN
public/uploads/images/1/hongpi/9.jpg


BIN
public/uploads/images/1/hongpi/999hongopi.jpeg


BIN
public/uploads/images/1/huoxiang/poster.jpg


BIN
public/uploads/images/1/huoxiang/thumb.jpg


BIN
public/uploads/images/1/ksmm.jpg


BIN
public/uploads/images/1/orders_banner/get_reward.jpg


BIN
public/uploads/images/1/piyanping/poster.jpg


BIN
public/uploads/images/1/piyanping/thumb.jpg


BIN
public/uploads/images/1/pudixiaoyan/333.jpg


BIN
public/uploads/images/1/pudixiaoyan/pudi.png


BIN
public/uploads/images/1/putaotangsuanxin/18.png


BIN
public/uploads/images/1/qianglipipalu/pipalu.png


BIN
public/uploads/images/1/weitai/poster.jpg


BIN
public/uploads/images/1/weitai/thumb.jpg


BIN
public/uploads/images/1/wenweishu/wenwei.png


BIN
public/uploads/images/1/yws.jpg


+ 99 - 0
resources/views/admin/regiment/index.blade.php

@@ -0,0 +1,99 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+
+@if(check_auth('admin/score_clockin_active/add'))
+	<div class="page-header">
+		<a href="{{url('admin/score_clockin_active/add')}}" class="btn btn-primary">新增</a>
+	</div>
+@endif
+
+<form action="" method="get" class="form-horizontal form-line">
+	<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-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>
+		</select>
+	</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/score_clockin_active/index')}}" class="btn btn-sm btn-default" >重置</a>
+</form>
+
+<div class="row">
+	<div class="col-xs-12">	
+		<div class="table-responsive">
+			<table class="table table-striped table-bordered table-hover">
+				<thead>
+					<tr>
+						<th>团单ID</th>
+						<th>参与活动/活动编码</th>
+						<th>产品名称/产品编码</th>
+						<th>发起客户昵称/发起客户编码</th>
+						<th>拼团状态</th>
+						<th>开始时间</th>
+						<th>结束时间</th>
+						<th>修改时间</th>
+					</tr>
+				</thead>
+				
+				<tbody>
+						@foreach ($list as $a)
+						<tr>
+							<th>{{$a['id']}}</th>
+							<td>{{$a['active_name']}}<br/>{{$a['active_code']}}</td>
+							<td style="white-space:pre">{{$a['product_name']}}<br/>{{$a['product_code']}}</td>
+							<td>
+								@if( $a['custom_uid'])
+									{{$a['username']}}<br/>{{$a['custom_code']}}
+								@else
+									商家发起
+								@endif
+							</td>
+							<td>
+								@if( $a['status'] == 1 )
+									拼团中
+								@endif
+								@if( $a['status'] == 2 )
+										拼团失败
+								@endif
+								@if( $a['status'] == 3 )
+										拼团成功
+								@endif
+							</td>
+							<td>{{date('Y/m/d H:i:s',$a['start_time'])}}</td>
+							<td>{{date('Y/m/d H:i:s',$a['end_time'])}}</td>
+							<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
+						</tr>  
+						@endforeach
+						<tr>
+							<td colspan="20" class="page">{{$list->render()}}</td>
+						</tr>
+						<tr>
+							<td colspan="20">总计 {{$list->total()}} 个商店</td>
+						</tr>
+				</tbody>
+				
+			</table>
+		</div>
+	</div>
+</div>
+@endsection

+ 96 - 0
resources/views/admin/regiment_active/add.blade.php

@@ -0,0 +1,96 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+<form class="post-form" action="" method="post">
+	<div class="form-group col-sm-12" style="font-size:large">基础信息</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">拼团产品</label>
+		<input class="form-control" required="required" type="text" placeholder="产品编码" name="product_code" value="" />
+	</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">活动价格</label>
+		<input class="form-control" required="required" type="text" placeholder="活动价格" min="0" name="regiment_price" value="" />
+	</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">每人限购</label>
+		<input class="form-control" required="required" type="number" placeholder="每人限购" min="0" name="quota" value="" />
+	</div>
+	<div class="form-group col-sm-4">
+		<label class="control-label">活动名称</label>
+		<input class="form-control" required="required" type="text" placeholder="活动名称" name="name" maxlength="45" value="" />
+	</div>
+	<div class="form-group col-sm-4">
+		<label class="control-label">成团人数</label>
+		<input class="form-control" required="required" type="number" placeholder="成团人数" name="number" maxlength="45" value="" />
+	</div>
+	<div class="form-group col-sm-3">
+		<label class="control-label">活动开始时间</label>
+		<input class="form-control" required="required" type="datetime-local" placeholder="开始时间"  name="start_time" value="" />
+	</div>
+	<div class="form-group col-sm-3">
+		<label class="control-label">活动结束时间</label>
+		<input class="form-control" required="required" type="datetime-local" placeholder="结束时间" name="end_time" value="" />
+	</div>
+	<div class="form-group col-sm-6">
+		<label class="control-label">拼团有效期</label>
+		<div class="form-group col-sm-12">
+			<div class="form-group col-sm-6">
+				<label class="control-label">天</label>
+				<input class="form-control" required="required" type="number" placeholder="天" name="expiration_day" maxlength="45" value="" />
+			</div>
+			<div class="form-group col-sm-6">
+				<label class="control-label">小时 </label>
+				<input class="form-control" required="required" type="number" placeholder="小时" name="expiration_hours" maxlength="45" max="24" value="" />
+			</div>
+		</div>
+	</div>
+	<div class="form-group col-sm-12 " style="font-size:large">更多设置</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">最多参与次数</label>
+		<input class="form-control" required="required" type="text" placeholder="最多参与次数" min="0" name="participation_number" value="" />
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">开团人员</label>
+		<div class="radio">
+			<label class="radio-inline"><input type="radio" value="1" name="open_people" >老用户</label>
+			<label class="radio-inline"><input type="radio" value="2" name="open_people" >新用户</label>
+			<label class="radio-inline"><input type="radio" value="3" name="open_people" >不限新老用户</label>
+		</div>
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">参团人员</label>
+		<div class="radio">
+			<label class="radio-inline"><input type="radio" value="1" name="partake_people" >老用户</label>
+			<label class="radio-inline"><input type="radio" value="2" name="partake_people" >新用户</label>
+			<label class="radio-inline"><input type="radio" value="3" name="partake_people" >不限新老用户</label>
+		</div>
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">超员成团</label>
+		<div class="radio">
+			<label class="radio-inline"><input type="radio" value="2" name="exceed_people" >开启</label>
+			<label class="radio-inline"><input type="radio" value="1" name="exceed_people" >关闭</label>
+		</div>
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">自动开团</label>
+		<div class="radio">
+			<label class="radio-inline"><input type="radio" value="2" name="automatic" >开启</label>
+			<label class="radio-inline"><input type="radio" value="1" name="automatic" >关闭</label>
+		</div>
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">虚拟成团</label>
+		<div class="radio">
+			<label class="radio-inline"><input type="radio" value="2" name="virtually" >开启</label>
+			<label class="radio-inline"><input type="radio" value="1" name="virtually" >关闭</label>
+		</div>
+	</div>
+	<div class="form-group col-sm-12">
+		@csrf
+		<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />
+	</div>
+</form>
+@endsection

+ 96 - 0
resources/views/admin/regiment_active/edit.blade.php

@@ -0,0 +1,96 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+	<form class="post-form" action="" method="post">
+		<div class="form-group col-sm-12" style="font-size:large">基础信息</div>
+		<div class="form-group col-sm-2">
+			<label class="control-label">拼团产品</label>
+			<input class="form-control" required="required" type="text" placeholder="产品编码" name="product_code" value="{{$oldData['product_code']}}" />
+		</div>
+		<div class="form-group col-sm-2">
+			<label class="control-label">活动价格</label>
+			<input class="form-control" required="required" type="text" placeholder="活动价格" min="0" name="regiment_price" value="{{$oldData['regiment_price']}}" />
+		</div>
+		<div class="form-group col-sm-2">
+			<label class="control-label">每人限购</label>
+			<input class="form-control" required="required" type="number" placeholder="每人限购" min="0" name="quota" value="{{$oldData['quota']}}" />
+		</div>
+		<div class="form-group col-sm-4">
+			<label class="control-label">活动名称</label>
+			<input class="form-control" required="required" type="text" placeholder="活动名称" name="name" maxlength="45" value="{{$oldData['name']}}" />
+		</div>
+		<div class="form-group col-sm-4">
+			<label class="control-label">成团人数</label>
+			<input class="form-control" required="required" type="number" placeholder="成团人数" name="number" maxlength="45" value="{{$oldData['number']}}" />
+		</div>
+		<div class="form-group col-sm-3">
+			<label class="control-label">活动开始时间</label>
+			<input class="form-control" required="required" type="datetime-local" placeholder="开始时间"  name="start_time" value="{{date('Y-m-d H:i',$oldData['start_time'])}}" />
+		</div>
+		<div class="form-group col-sm-3">
+			<label class="control-label">活动结束时间</label>
+			<input class="form-control" required="required" type="datetime-local" placeholder="结束时间" name="end_time" value="{{date('Y-m-d H:i',$oldData['end_time'])}}" />
+		</div>
+		<div class="form-group col-sm-6">
+			<label class="control-label">拼团有效期</label>
+			<div class="form-group col-sm-12">
+				<div class="form-group col-sm-6">
+					<label class="control-label">天</label>
+					<input class="form-control" required="required" type="number" placeholder="天" name="expiration_day" maxlength="45" value="{{(int)$oldData['expiration']/24}}" />
+				</div>
+				<div class="form-group col-sm-6">
+					<label class="control-label">小时 </label>
+					<input class="form-control" required="required" type="number" placeholder="小时" name="expiration_hours" maxlength="45" max="24" value="{{fmod($oldData['expiration'], 24)}}" />
+				</div>
+			</div>
+		</div>
+		<div class="form-group col-sm-12 " style="font-size:large">更多设置</div>
+		<div class="form-group col-sm-12">
+			<label class="control-label">最多参与次数</label>
+			<input class="form-control" required="required" type="text" placeholder="最多参与次数" min="0" name="participation_number" value="{{$oldData['participation_number']}}" />
+		</div>
+		<div class="form-group col-sm-12">
+			<label class="control-label">开团人员</label>
+			<div class="radio">
+				<label class="radio-inline"><input type="radio" value="1" @if($oldData['open_people'] == 1) checked @endif name="open_people" >老用户</label>
+				<label class="radio-inline"><input type="radio" value="2" name="open_people" @if($oldData['open_people'] == 2) checked @endif>新用户</label>
+				<label class="radio-inline"><input type="radio" value="3" name="open_people" @if($oldData['open_people'] == 3) checked @endif>不限新老用户</label>
+			</div>
+		</div>
+		<div class="form-group col-sm-12">
+			<label class="control-label">参团人员</label>
+			<div class="radio">
+				<label class="radio-inline"><input type="radio" value="1" name="partake_people" @if($oldData['partake_people'] == 1) checked @endif>老用户</label>
+				<label class="radio-inline"><input type="radio" value="2" name="partake_people" @if($oldData['partake_people'] == 2) checked @endif>新用户</label>
+				<label class="radio-inline"><input type="radio" value="3" name="partake_people" @if($oldData['partake_people'] == 3) checked @endif>不限新老用户</label>
+			</div>
+		</div>
+		<div class="form-group col-sm-12">
+			<label class="control-label">超员成团</label>
+			<div class="radio">
+				<label class="radio-inline"><input type="radio" value="2" name="exceed_people" @if($oldData['exceed_people'] == 2) checked @endif>开启</label>
+				<label class="radio-inline"><input type="radio" value="1" name="exceed_people" @if($oldData['partake_people'] == 1) checked @endif>关闭</label>
+			</div>
+		</div>
+		<div class="form-group col-sm-12">
+			<label class="control-label">自动开团</label>
+			<div class="radio">
+				<label class="radio-inline"><input type="radio" value="2" name="automatic" @if($oldData['automatic'] == 2) checked @endif>开启</label>
+				<label class="radio-inline"><input type="radio" value="1" name="automatic" @if($oldData['automatic'] == 1) checked @endif>关闭</label>
+			</div>
+		</div>
+		<div class="form-group col-sm-12">
+			<label class="control-label">虚拟成团</label>
+			<div class="radio">
+				<label class="radio-inline"><input type="radio" value="2" name="virtually" @if($oldData['virtually'] == 2) checked @endif>开启</label>
+				<label class="radio-inline"><input type="radio" value="1" name="virtually" @if($oldData['virtually'] == 1) checked @endif>关闭</label>
+			</div>
+		</div>
+		<div class="form-group col-sm-12">
+			@csrf
+			<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />
+		</div>
+	</form>
+@endsection

+ 117 - 0
resources/views/admin/regiment_active/index.blade.php

@@ -0,0 +1,117 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+
+@if(check_auth('admin/regiment_active/add'))
+	<div class="page-header">
+		<a href="{{url('admin/regiment_active/add')}}" class="btn btn-primary">新增</a>
+	</div>
+@endif
+
+<form action="" method="get" class="form-horizontal form-line">
+	<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-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>
+		</select>
+	</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/score_clockin_active/index')}}" class="btn btn-sm btn-default" >重置</a>
+</form>
+
+<div class="row">
+	<div class="col-xs-12">	
+		<div class="table-responsive">
+			<table class="table table-striped table-bordered table-hover">
+				<thead>
+					<tr>
+						<th>活动编码</th>
+						<th>活动名称</th>
+						<th>产品名称</th>
+						<th>拼团人数(人)</th>
+						<th>活动价格(元)</th>
+						<th>拼团有效期</th>
+						<th>状态</th>
+						<th>活动时间</th>
+						<th>创建时间</th>
+						<th>修改时间</th>
+						<th>操作</th>									
+					</tr>
+				</thead>
+				
+				<tbody>
+						@foreach ($list as $a)
+						<tr>
+							<th>{{$a['code']}}</th>
+							<td style="white-space:pre">{{$a['name']}}</td>
+							<td>{{$a['product_name']}}</td>
+							<td>{{$a['number']}}</td>
+							<td>{{$a['regiment_price']}}</td>
+							<td>{{$a['expiration']}}</td>
+							<td>
+								@if( $a['status'] === 2)
+								停用
+								@else
+									@if( $a['start_time'] <= time() && $a['end_time'] <= time() )
+										已结束
+									@endif
+									@if( $a['start_time'] <= time() && $a['end_time'] > time() )
+										进行中
+									@endif
+									@if( $a['start_time'] > time() )
+										待进行
+									@endif
+								@endif
+							</td>
+							<td>{{date('Y/m/d H:i:s',$a['start_time'])}}<br/>{{date('Y/m/d H:i:s',$a['end_time'])}}</td>
+							<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
+							<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
+							<td>
+								@if(check_auth('admin/regiment_active/edit'))
+								<a href="{{url('admin/regiment_active/edit?'.http_build_query(['id'=>$a['id']]))}}" class="btn btn-sm btn-warning" >编辑</a>
+								@endif
+								@if(check_auth('admin/regiment_active/copy'))
+									<a data-url="{{url('admin/regiment_active/copy?'.http_build_query(['id'=>$a['id'],'status'=>0]))}}" class="set_status btn btn-sm btn-success" >复制</a>
+								@endif
+								@if(check_auth('admin/regiment_active/set_status'))
+									@if($a['status'] === 2)
+									<a data-url="{{url('admin/regiment_active/set_status?'.http_build_query(['id'=>$a['id'],'status'=>1]))}}" class="set_status btn btn-sm btn-success" >启用</a>
+									@else
+									<a data-url="{{url('admin/regiment_active/set_status?'.http_build_query(['id'=>$a['id'],'status'=>2]))}}" class="set_status btn btn-sm btn-danger" >停用</a>
+									@endif
+								@endif
+							</td>							
+						</tr>  
+						@endforeach
+						<tr>
+							<td colspan="20" class="page">{{$list->render()}}</td>
+						</tr>
+						<tr>
+							<td colspan="20">总计 {{$list->total()}} 个商店</td>
+						</tr>
+				</tbody>
+				
+			</table>
+		</div>
+	</div>
+</div>
+@endsection

+ 75 - 0
resources/views/admin/regiment_record/index.blade.php

@@ -0,0 +1,75 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+
+@if(check_auth('admin/score_clockin_active/add'))
+	<div class="page-header">
+		<a href="{{url('admin/score_clockin_active/add')}}" class="btn btn-primary">新增</a>
+	</div>
+@endif
+
+<form action="" method="get" class="form-horizontal form-line">
+	<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>
+	<input type="submit" class="btn btn-sm btn-primary" value="查询"/>
+	<a href="{{url('admin/score_clockin_active/index')}}" class="btn btn-sm btn-default" >重置</a>
+</form>
+
+<div class="row">
+	<div class="col-xs-12">	
+		<div class="table-responsive">
+			<table class="table table-striped table-bordered table-hover">
+				<thead>
+					<tr>
+						<th>拼团记录ID</th>
+						<th>团单ID</th>
+						<th>订单编码</th>
+						<th>客户昵称/编码</th>
+						<th>参与活动/活动编码</th>
+						<th>产品名称/产品编码</th>
+						<th>发起客户昵称/发起客户编码</th>
+						<th>拼团状态</th>
+						<th>订单生成时间</th>
+					</tr>
+				</thead>
+				
+				<tbody>
+						@foreach ($list as $a)
+						<tr>
+							<th>{{$a['id']}}</th>
+							<th>{{$a['regiment_id']}}</th>
+							<th>{{$a['order_code']}}</th>
+							<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>
+								@if( $a['regiment_status'] == 1 )
+									拼团中
+								@endif
+								@if( $a['regiment_status'] == 2 )
+									拼团失败
+								@endif
+								@if( $a['regiment_status'] == 3 )
+									拼团成功
+								@endif
+							</td>
+							<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
+						</tr>  
+						@endforeach
+						<tr>
+							<td colspan="20" class="page">{{$list->render()}}</td>
+						</tr>
+						<tr>
+							<td colspan="20">总计 {{$list->total()}} 个商店</td>
+						</tr>
+				</tbody>
+				
+			</table>
+		</div>
+	</div>
+</div>
+@endsection

+ 1 - 1
resources/views/admin/score_clockin/edit.blade.php

@@ -6,7 +6,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 <form class="post-form" action="" method="post">
 	<div class="form-group col-sm-12">
 		<label class="control-label">任务天数</label>
-		<input class="form-control" type="number" placeholder="任务天数,第几天" required="" min="1" max="7" name="what_day" value="{{$oldData['what_day']}}" />
+		<input class="form-control" type="number" placeholder="任务天数,第几天" required="" min="1" name="what_day" value="{{$oldData['what_day']}}" />
 	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">奖励积分</label>

+ 7 - 1
routes/api.php

@@ -177,4 +177,10 @@ Route::any('weizan_orders/import',[\App\Http\Controllers\Api\WeiZan\Orders::clas
  * 订单回执上传
  * 
  * */
-Route::any('orders_receipt/apply',[\App\Http\Controllers\Api\Orders\Receipt::class,'apply']);
+Route::any('orders_receipt/apply',[\App\Http\Controllers\Api\Orders\Receipt::class,'apply']);
+
+// 创建拼团订单
+Route::any('orders/create_regiment',[\App\Http\Controllers\Api\Orders::class,'create_regiment']);
+
+//取消拼团
+Route::any('orders/cancel_regiment',[\App\Http\Controllers\Api\Orders::class,'cancel_regiment']);

+ 15 - 0
routes/web.php

@@ -441,4 +441,19 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     // 详情
     Route::any('orders_receipt/refuse',[App\Http\Controllers\Admin\OrdersReceipt::class,'refuse']);
 
+
+    /* 拼团活动 */
+    // 拼团活动列表
+    Route::any('regiment_active/index',[App\Http\Controllers\Admin\RegimentActive::class,'index']);
+    // 新增
+    Route::any('regiment_active/add',[App\Http\Controllers\Admin\RegimentActive::class,'add']);
+    // 编辑
+    Route::any('regiment_active/edit',[App\Http\Controllers\Admin\RegimentActive::class,'edit']);
+    // 状态
+    Route::any('regiment_active/set_status',[App\Http\Controllers\Admin\RegimentActive::class,'set_status']);
+    //团列表
+    Route::any('regiment/index',[App\Http\Controllers\Admin\Regiment::class,'index']);
+    //团记录列表
+    Route::any('regiment_record/index',[App\Http\Controllers\Admin\RegimentRecord::class,'index']);
+
 });