Przeglądaj źródła

Merge remote-tracking branch 'origin/jun' into liuxiangxin

liuxiangxin 5 miesięcy temu
rodzic
commit
78bbc4bdce
33 zmienionych plików z 1779 dodań i 54 usunięć
  1. 1 0
      .gitignore
  2. 14 4
      app/Console/Commands/Regiment.php
  3. 7 1
      app/Http/Controllers/Admin/Orders.php
  4. 240 0
      app/Http/Controllers/Admin/RecruitmentActive.php
  5. 72 0
      app/Http/Controllers/Admin/RecruitmentActivePrize.php
  6. 91 0
      app/Http/Controllers/Admin/RecruitmentRecord.php
  7. 2 2
      app/Http/Controllers/Api/Orders.php
  8. 130 0
      app/Http/Controllers/Api/Recruitment.php
  9. 239 3
      app/Http/Controllers/Api/Wechat.php
  10. 51 0
      app/Http/Requests/Admin/RecruitmentActive.php
  11. 1 1
      app/Models/PromoProduct.php
  12. 126 0
      app/Models/RecruitmentActive.php
  13. 104 0
      app/Models/RecruitmentActivePrize.php
  14. 106 0
      app/Models/RecruitmentPrizeRecord.php
  15. 106 0
      app/Models/RecruitmentRecord.php
  16. 6 0
      app/Models/Traits/Score/BuyType.php
  17. BIN
      public/uploads/ueditor/images/admin/1/20240911/thumb.jpg
  18. 12 8
      resources/views/admin/banner/index.blade.php
  19. 2 0
      resources/views/admin/config/index.blade.php
  20. 9 0
      resources/views/admin/orders/index.blade.php
  21. 12 8
      resources/views/admin/orders_banner/index.blade.php
  22. 12 8
      resources/views/admin/orders_receipt/index.blade.php
  23. 73 0
      resources/views/admin/recruitment_active/add.blade.php
  24. 74 0
      resources/views/admin/recruitment_active/edit.blade.php
  25. 114 0
      resources/views/admin/recruitment_active/index.blade.php
  26. 56 0
      resources/views/admin/recruitment_active_prize/edit.blade.php
  27. 67 0
      resources/views/admin/recruitment_record/index.blade.php
  28. 2 2
      resources/views/admin/regiment/index.blade.php
  29. 2 0
      resources/views/admin/score_clockin/index.blade.php
  30. 12 8
      resources/views/admin/score_product/index.blade.php
  31. 12 8
      resources/views/admin/weiban_qrcode/index.blade.php
  32. 8 1
      routes/api.php
  33. 16 0
      routes/web.php

+ 1 - 0
.gitignore

@@ -7,6 +7,7 @@
 /storage/framework/testing/*
 /storage/framework/views/*
 /elkconf
+/public/uploads/*
 /public/uploads/product/*
 /public/uploads/score_product/*
 /public/uploads/company/*

+ 14 - 4
app/Console/Commands/Regiment.php

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
 
 use App\Facades\Servers\Logs\Log;
 use App\Models\Orders;
+use App\Models\OrdersProduct;
 use Illuminate\Console\Command;
 use App\Facades\Servers\Redis\RedisLock;
 use App\Facades\Servers\WechatWork\ExternalContact;
@@ -59,9 +60,8 @@ class Regiment extends Command
         $Model          = New Model();
         $time           = time();
         // 活动结束
-        $activeList     =  $Model->query()->where([['end_time','<=',time()],['status','=',1]])->get();
+        $activeList     =  $Model->query()->where([['end_time','<=',time()],['status','=',1]])->get()->toArray();
         if ($activeList){
-            $activeList =  $activeList->toArray();
             $activeList =  array_column($activeList,null,'id');
             $activeIds  =   array_column($activeList,'id');
             $regiment   =   RegimentModel::query()->where('status','=',0)->whereIn('active_id',$activeIds)->get()->toArray();
@@ -76,6 +76,8 @@ class Regiment extends Command
                                //修改订单
                                $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>1,'update_time'=>$time]);
                                if (!$res)   Log::error('run_regiment','修改订单失败');
+                               $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>1]);
+                               if (!$res)   Log::error('run_regiment','修改订单产品失败');
                            }
                            //修改状态
                            $res         =   RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>2]);
@@ -91,13 +93,15 @@ class Regiment extends Command
                                $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                                //修改订单
                                $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
-                               if (!$res)   Log::error('run_regiment','修改团记录失败');
+                               if (!$res)   Log::error('run_regiment','修改订单失败');
+                               $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>11]);
+                               if (!$res)   Log::error('run_regiment','修改订单产品失败');
                            }
                        }
                 }
             }
             $res    =   $Model->query()->whereIn('id',$activeIds)->update(['status'=>2,'update_time'=>$time]);
-            if (!$res)   Log::error('run_regiment','修改团活动失败');
+            if (!$res)   Log::error('run_regiment','修改团活动失败:'.json_encode($activeIds));
         }
 
         //团过期
@@ -116,6 +120,9 @@ class Regiment extends Command
                         $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                         //修改订单
                         $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>1]);
+                        if (!$res)   Log::error('run_regiment','修改订单失败');
+                        $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>1]);
+                        if (!$res)   Log::error('run_regiment','修改订单产品失败');
                     }
                 }else{
                     $r = RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>3]);
@@ -125,6 +132,9 @@ class Regiment extends Command
                     $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                     //修改订单
                     $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
+                    if (!$res)   Log::error('run_regiment','修改订单失败');
+                    $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>11]);
+                    if (!$res)   Log::error('run_regiment','修改订单产品失败');
                 }
             }
         }

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

@@ -52,6 +52,7 @@ class Orders extends Auth{
 		$status					= request('status',0);
 		$startTime				= request('start_time','');
 		$endTime				= request('end_time','');
+		$is_regiment			= request('is_regiment','');
 		// 编码转ID
 		$id						= $code ? $Model->codeToId($code) : 0;
 		$productId				= $productCode ? $Product->codeToId($productCode) : 0;
@@ -72,14 +73,19 @@ class Orders extends Auth{
 		if( $startTime )		$map[] = ['orders_product.insert_time','>=',strtotime($startTime)];
 		if( $endTime )			$map[] = ['orders_product.insert_time','<=',strtotime($endTime)];
 		if( $status )			$map[] = ['orders_product.status','=',$status];
+        if($is_regiment){
+            if( $is_regiment == 1)		$map[] = ['orders.regiment_id','>',0];
+            if( $is_regiment == 2)		$map[] = ['orders.regiment_id','=',0];
+        }
 		// 查询数据
 		$list					= $OrdersProduct->query()
 									->join('custom','orders_product.custom_uid','=','custom.uid')
 									->join('orders_addr','orders_addr.order_id','=','orders_product.order_id')
+									->leftJoin('orders','orders.id','=','orders_product.order_id')
 									->where($map)
 									->orderByDesc('id')
 									->select([
-										'orders_product.*','custom.username as custom_name',
+										'orders_product.*','custom.username as custom_name','orders.regiment_id as regiment_id',
 										'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
 									])
 									->paginate(request('limit',config('page_num',10)))->appends(request()->all());

+ 240 - 0
app/Http/Controllers/Admin/RecruitmentActive.php

@@ -0,0 +1,240 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Facades\Servers\WechatMini\Mini;
+use App\Http\Requests\Admin\RecruitmentActive as Request;
+use App\Models\RecruitmentActive as Model;
+use App\Models\City;
+use App\Models\WeiBan\Tags as WeiBanTags;
+
+
+use function PHPUnit\Framework\isNull;
+
+/**
+ * 拉新活动
+ *
+ * @author    刘相欣
+ *
+ */
+class RecruitmentActive extends Auth{
+	
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','拉新活动');
+		$this->assign('breadcrumb2','活动列表');
+	}
+
+	/**
+	 * 列表页
+	 * 
+	 * */
+    public function index(Model $Model,City $City){
+		// 接收参数
+		$name					= request('name','');
+		$idCode					= request('id_code','');
+		$status					= request('status','');
+		$start_time				= request('start_time','');
+		$end_time			    = request('end_time','');
+		// 查询条件
+		$map 					= [];
+		// 组合条件
+		if( $name )				$map[] = ['name','=',$name];
+        if( $idCode ){
+            $id                 =   $Model->codeToId($idCode);
+            $map[] = ['id','=',$id];
+        }
+        if( $status )			$map[] = ['status','=',$status];
+        if( $start_time )		{
+            $start_time         =   strtotime($start_time);
+            $map[] = ['start_time','>=',$start_time];
+        }
+        if( $end_time )		{
+            $end_time         =   strtotime($end_time);
+            $map[] = ['end_time','<=',$end_time];
+        }
+		// 查询数据
+		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
+		// 循环处理数据
+		foreach ($list as $key => $value) {
+			// 小程序链接
+			$value['mp_urllink']= $this->getUrlLink($value['id']);
+            if( $value['city_ids'] ) {
+                // 解析数组
+                $cityids			= explode(',',$value['city_ids']);
+                // 获取城市
+                foreach ($cityids as $kk=>$vv) 	{
+                    // 获取值
+                    $vv				= $City->getOne($vv,'name');
+                    // 获取城市名
+                    $cityids[$kk]	= $vv;
+                }
+                // 城市列表
+                $value['city_ids']	= implode('、',$cityids);
+            }
+            if ($value['id']){
+                $value['id_code']   =   $Model->idToCode($value['id']);
+            }
+			// 重组
+			$list[$key]			= $value;
+		}
+		// 分配数据
+		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+		$this->assign('list',$list);
+		// 加载模板
+		return 					$this->fetch();
+    }
+
+	/**
+	 * 获取小程序链接
+	 * 
+	 */
+	private function getUrlLink($id){
+		// 结果数据
+        $link                  = cache('admin:recruitment:active:urllink:'.$id);
+        // 不存在数据
+        if ( is_null($link) ) {
+            // 从数据库获取数据
+            $link              = Mini::getUrlLink('pages/recruitment/index','?id='.$id);
+            // 存起来
+            cache(['admin:recruitment:active:urllink:'.$id=>$link],$link ? now()->addDays(28) : now()->addMinutes(3));
+        }
+        // 返回结果
+        return                  $link;
+
+	}
+
+	/**
+	 * 添加
+	 * 
+	 * */
+	public function add(Request $request,Model $Model,City $City,WeiBanTags $WeiBanTags){
+		if( request()->isMethod('post') ){
+			// 验证参数
+			$request->scene('add')->validate();
+			// 接收数据
+			$data['banner_img']		= request('banner_img','');
+			$data['name']			= request('name','');
+			$data['active_rule']	= request('active_rule','');
+			$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;
+			$cityIds				= request('city_ids',[]);
+			$tagScope				= request('tag_scope',[]);
+			$tagExcept				= request('tag_except',[]);
+			$data['city_ids']		= implode(',',$cityIds);
+			$data['tag_scope']		= implode(',',$tagScope);
+			$data['tag_except']		= implode(',',$tagExcept);
+			$data['status']			= 1;
+			// 写入数据表
+			$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']);
+		}
+		// 获取列表
+		$cityList					= $City->getCityList();
+		// 标签列表
+		$tagData					= $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
+		// 标签列表
+		$tagList					= [];
+		// 循环数据
+		foreach ($tagData as $value) {
+			$tagList[$value['group']][] = $value['name'];
+		}
+		// 分配数据
+		$this->assign('cityList',$cityList);
+		$this->assign('tagList',$tagList);
+		$this->assign('crumbs','新增');
+		// 加载模板
+		return						$this->fetch(); 
+	}
+
+	/**
+	 * 修改
+	 * 
+	 * */
+	public function edit(Request $request,Model $Model,City $City,WeiBanTags $WeiBanTags){
+		// 接收参数
+		$id							= request('id',0);
+		// 查询用户
+		$oldData					= $Model->where(['id'=>$id])->first();
+		// 修改
+		if(request()->isMethod('post')){
+			// 验证参数
+			$request->scene('edit')->validate();
+			// 接收数据
+			$data['banner_img']		= request('banner_img','');
+			$data['name']			= request('name','');
+			$data['active_rule']	= request('active_rule','');
+			$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;
+            $tagExcept				= request('tag_except',[]);
+			$cityIds				= request('city_ids',[]);
+			$tagScope				= request('tag_scope',[]);
+			$data['city_ids']		= implode(',',$cityIds);
+			$data['tag_scope']		= implode(',',$tagScope);
+            $data['tag_except']		= implode(',',$tagExcept);
+			// 写入数据表
+			$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('查无数据');
+		// 获取城市ID
+		$oldData['city_ids']		= explode(',',$oldData['city_ids']);
+		$oldData['tag_scope']		= explode(',',$oldData['tag_scope']);
+		$oldData['tag_except']		= explode(',',$oldData['tag_except']);
+		// 获取列表
+		$cityList					= $City->getCityList();
+		// 标签列表
+		$tagData					= $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
+		// 标签列表
+		$tagList					= [];
+		// 循环数据
+		foreach ($tagData as $value) {
+			$tagList[$value['group']][] = $value['name'];
+		}
+		// 分配数据
+		$this->assign('cityList',$cityList);
+		$this->assign('tagList',$tagList);
+		$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'=>'']);
+	}
+
+}

+ 72 - 0
app/Http/Controllers/Admin/RecruitmentActivePrize.php

@@ -0,0 +1,72 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Models\RecruitmentActivePrize as Model;
+use App\Models\Coupon;
+use function PHPUnit\Framework\isNull;
+
+/**
+ * 拉新活动
+ *
+ * @author    刘相欣
+ *
+ */
+class RecruitmentActivePrize extends Auth{
+	
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','拉新活动');
+		$this->assign('breadcrumb2','拉新活动奖励配置');
+	}
+
+
+
+	/**
+	 * 修改
+	 * 
+	 * */
+	public function edit(Model $Model,Coupon $Coupon){
+		// 接收参数
+		$id							= request('id',0);
+		$activeId					= request('active_id',0);
+
+        // 错误告知
+        if( !$activeId )				return $this->error('缺失活动id');
+        $oldData					= $Model->where(['active_id'=>$activeId])->first();
+		// 修改
+		if(request()->isMethod('post')){
+			// 接收数据
+			$data['old_prize_type']	        = request('old_prize_type','');
+			$data['old_prize']	            = request('old_prize','');
+			$data['new_prize_type']	        = request('new_prize_type','');
+			$data['new_prize']	            = request('new_prize','');
+			$data['higher_prize_type']	    = request('higher_prize_type','');
+			$data['higher_prize']	        = request('higher_prize','');
+			$data['active_id']	            = $activeId;
+            if ($data['old_prize_type'] == 2){
+                $data['old_prize']          =   $Coupon->codeToId($data['old_prize']);
+            }
+            if ($data['new_prize_type'] == 2){
+                $data['new_prize']          =   $Coupon->codeToId($data['new_prize']);
+            }
+            if ($oldData){
+                // 写入数据表
+                $result					= $Model->edit($oldData['id'],$data);
+            }else{
+                $result					= $Model->add($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']);
+		}
+		$this->assign('oldData',$oldData);
+		$this->assign('activeId',$activeId);
+		$this->assign('crumbs','修改');
+		// 加载模板
+		return						$this->fetch();
+	}
+
+
+}

+ 91 - 0
app/Http/Controllers/Admin/RecruitmentRecord.php

@@ -0,0 +1,91 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Facades\Servers\WechatMini\Mini;
+use App\Models\RecruitmentRecord as Model;
+use App\Models\Custom;
+use App\Models\RecruitmentActive;
+
+
+use function PHPUnit\Framework\isNull;
+
+/**
+ * 拉新活动
+ *
+ * @author    刘相欣
+ *
+ */
+class RecruitmentRecord extends Auth{
+	
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','拉新活动');
+		$this->assign('breadcrumb2','活动数据列表');
+	}
+
+	/**
+	 * 列表页
+	 * 
+	 * */
+    public function index(Model $Model,Custom  $Custom,RecruitmentActive $RecruitmentActive){
+		// 接收参数
+		$code					= request('code','');
+		$old_uid_code			= request('old_uid_code','');
+		$new_uid_code			= request('new_uid_code','');
+		$start_time			    = request('start_time','');
+		$end_time			    = request('end_time','');
+		// 查询条件
+		$map 					= [];
+		// 组合条件
+		if( $code )	{
+            $activeId           =   $RecruitmentActive->codeToId($code);
+            $map[] = ['active_id','=',$activeId];
+        }
+        if( $old_uid_code )	{
+            $old_uid           =   $Custom->codeToId($old_uid_code);
+            $map[] = ['old_uid','=',$old_uid];
+        }
+        if( $new_uid_code )	{
+            $new_uid           =   $Custom->codeToId($new_uid_code);
+            $map[] = ['new_uid','=',$new_uid];
+        }
+        if( $start_time )		{
+            $start_time         =   strtotime($start_time);
+            $map[] = ['insert_time','>=',$start_time];
+        }
+        if( $end_time )		{
+            $end_time         =   strtotime($end_time);
+            $map[] = ['insert_time','<=',$end_time];
+        }
+		// 查询数据
+		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
+		// 循环处理数据
+		foreach ($list as $key => $value) {
+            if( $value['old_uid'] ) {
+                $oldCustom              = $Custom->getOne($value['old_uid']);
+                if ($oldCustom){
+                    $value['old_name']	    = $oldCustom['username'];
+                    $value['old_uid_code']	= $Custom->idToCode($oldCustom['uid']);
+                }
+            }
+            if( $value['new_uid'] ) {
+                $oldCustom              = $Custom->getOne($value['new_uid']);
+                if ($oldCustom){
+                    $value['new_name']	    = $oldCustom['username'];
+                    $value['new_uid_code']	= $Custom->idToCode($oldCustom['uid']);
+                }
+            }
+            if ($value['active_id']){
+                $value['active_id_code']	= $RecruitmentActive->idToCode($value['active_id']);
+                $value['active_name']	    = $RecruitmentActive::query()->where('id','=',$value['active_id'])->value('name');
+            }
+			// 重组
+			$list[$key]			= $value;
+		}
+		// 分配数据
+		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+		$this->assign('list',$list);
+		// 加载模板
+		return 					$this->fetch();
+    }
+
+}

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

@@ -707,8 +707,8 @@ class Orders extends Api{
             // 判断库存
             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'];
+            $priceTotal					= $buyInfo['buy_num'] * $productInfo['price'];
+            $payTotal					= $buyInfo['buy_num'] * $regimentActiveInfo['regiment_price'];
         }
         $orderInfo = [
             'custom_uid'		    => $uid,

+ 130 - 0
app/Http/Controllers/Api/Recruitment.php

@@ -0,0 +1,130 @@
+<?php namespace App\Http\Controllers\Api;
+
+use App\Http\Controllers\Api\Api;
+use App\Models\RecruitmentActive as Model;
+use App\Models\RecruitmentPrizeRecord;
+use App\Models\RecruitmentRecord;
+use App\Models\Custom;
+use App\Models\WeiBan\Tags;
+use Vinkla\Hashids\Facades\Hashids;
+
+
+/**
+ * 拉新活动接口
+ *
+ * @author 刘相欣
+ *
+ * */
+class Recruitment extends Api{
+
+
+    /**
+     * 获取拉新活动			/api/recruitment/get_info
+     *
+     * */
+    public function get_info(Model $Model,Custom $Custom,RecruitmentPrizeRecord $RecruitmentPrizeRecord,RecruitmentRecord $RecruitmentRecord,Tags $WeiBanTags){
+        // 接口验签
+        // $this->verify_sign();
+        // 验证登录
+        $uid                    		= $this->checkLogin();
+        // 查询数据
+        // 获取客户城市ID
+        $custom							= $Custom->getOne($uid);
+        //查询拉新活动
+        if( !$custom['city_id'] )		return json_send(['code'=>'error','msg'=>'请选择所在城市后下单','data'=>['error'=>'请选择所在城市后下单']]);
+        // 获取城市ID
+        $cityId							= (string)$custom['city_id'];
+        // 查询用户标签
+        $tags							= $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
+        $time                           =   time();
+        $select                         = [
+            ['start_time','<=',$time],
+            ['end_time','>',$time],
+            ['status','=',0],
+        ];
+        $activeList                     = $Model::query()->whereRaw("find_in_set('$cityId', city_ids)")->where($select)->get()->toArray();
+        $activeInfo         =   [];
+        if ($activeList) {
+            foreach ($activeList as $active) {
+                $allowJoin = 0;
+                if ($active['tag_scope']) {
+                    // 解析数组
+                    $tag_scope = explode(',', $active['tag_scope']);
+                    // 标签范围限定时,默认不能参与
+                    // 判断标签是不是存在
+                    if ($tags) {
+                        foreach ($tags as $v) {
+                            // 标签范围内,允许参加
+                            if (in_array($v['name'], $tag_scope)) $allowJoin = 1;
+                        }
+                    }
+                }else{
+                    $allowJoin = 1;
+                }
+                if ($active['tag_except']) {
+                    // 解析数组
+                    $tag_except = explode(',', $active['tag_except']);
+                    // 标签范围限定时,默认不能参与
+                    $allowJoin = 0;
+                    // 判断标签是不是存在
+                    if ($tags) {
+                        foreach ($tags as $v) {
+                            // 标签范围内,允许参加
+                            if (in_array($v['name'], $tag_except)) $allowJoin = 0;
+                        }
+                    }
+                }
+                if ($allowJoin) {
+                    $activeInfo         =   $active;
+                    break;
+                }
+            }
+        }
+        if ($activeInfo){
+            $activeInfo['start_time']       =   date('Y-m-d H:i:s',$activeInfo['start_time']);
+            $activeInfo['end_time']         =   date('Y-m-d H:i:s',$activeInfo['end_time']);
+        }
+        return							json_send(['code'=>'success','msg'=>'获取成功','data'=>$activeInfo]);
+    }
+
+    /**
+     * 获取奖励记录		/api/recruitment/get_record
+     *
+     * */
+    public function get_record(RecruitmentPrizeRecord $recruitmentPrizeRecord){
+        // 接口验签
+        // $this->verify_sign();
+        // 验证登录
+        $uid                    	= $this->checkLogin();
+        // 接收参数
+        $limit						= request('limit',15);
+        // 查询条件
+        $map						= [['recruitment_prize_record.custom_uid','=',$uid]];
+        // 查询数据
+        $Paginator					= $recruitmentPrizeRecord->query()
+            ->join('recruitment_record','recruitment_record.id','=','recruitment_prize_record.recruitment_record_id')
+            ->join('custom','custom.uid','=','recruitment_record.new_uid')
+            ->where($map)
+            ->orderByDesc('id')
+            ->paginate($limit,['recruitment_prize_record.id','recruitment_prize_record.prize_type','recruitment_prize_record.prize','recruitment_prize_record.type','recruitment_prize_record.custom_uid','recruitment_prize_record.insert_time','recruitment_prize_record.recruitment_record_id','custom.username']);
+        // 重置数据
+        $list						= [];
+        // 获取数据
+        $list['total']				= $Paginator->total();
+        $list['current_page']		= $Paginator->currentPage();
+        $list['per_page']			= $Paginator->perPage();
+        $list['last_page']			= $Paginator->lastPage();
+        $list['data']				= $Paginator->items();
+        // 循环数据
+        foreach ($list['data'] as $key => $value) {
+            // 处理时间
+            $value['insert_time']		= date('Y-m-d H:i:s',$value['insert_time']);
+            // 重组
+            $list['data'][$key] 	= $value;
+        }
+        // 返回数据
+        return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
+    }
+
+
+}

+ 239 - 3
app/Http/Controllers/Api/Wechat.php

@@ -1,8 +1,18 @@
 <?php namespace App\Http\Controllers\Api;
 
+use App\Facades\Servers\Logs\Log;
 use App\Http\Controllers\Api\Api;
+use App\Models\City;
 use App\Models\Custom;
 use App\Facades\Servers\WechatMini\Mini;
+use App\Models\RecruitmentActive;
+use App\Models\RecruitmentActivePrize;
+use App\Models\RecruitmentPrizeRecord;
+use App\Models\RecruitmentRecord;
+use App\Models\Score\Record;
+use App\Models\WeiBan\Tags;
+use App\Models\CustomScore;
+use Vinkla\Hashids\Facades\Hashids;
 
 /**
  * 微信接口
@@ -19,11 +29,12 @@ class Wechat extends Api{
 	 * @param	string		$code		授权码
 	 * 
 	 * */
-	public function phone_number(Custom $Custom){
+	public function phone_number(Custom $Custom,Hashids $Hashids){
 		// 接口验签
 		// $this->verify_sign();
 		// 接收参数
 		$code									= request('code','');
+		$shareUid								= request('share_uid','');
 		// 授权结果
 		$result									= Mini::getUserPhone($code);
 		// 如果所需字段不存在
@@ -42,12 +53,237 @@ class Wechat extends Api{
 			$custom['uid'] 						= $Custom->add(['phone'=>$phone,'username'=>hide_phone($phone)]);
 			// 注册失败
 			if( empty($custom['uid']) )			return json_send(['code'=>'error','msg'=>'注册失败,请重试','data'=>['error'=>'注册失败,请重试']]);
+            //绑定裂变邀请关系
+            if($shareUid){
+                $shareUid       =   $Hashids::decodeHex($shareUid);
+                Log::error('recruitment','拉新活动:'.$shareUid);
+                $this->addRecruitment($custom['uid'],$shareUid);
+            }
 		}
 		// 进行登录
 		$token									= $Custom->createLoginAuthcode($custom['uid'],time());
 		// 返回结果
 		return									json_send(['code'=>'success','msg'=>'登录成功','data'=>$token]);
 	}
-
-
+    /**
+     * 拉新注册赠送奖励
+     *
+     * */
+    public function addRecruitment($uid,$shareUid){
+        $Custom     =   new Custom();
+        $WeiBanTags =   new Tags();
+        $RecruitmentActive  =   new RecruitmentActive();
+        // 获取客户城市ID
+        $custom							= $Custom->getOne($shareUid);
+        //查询拉新活动
+        if( !$custom['city_id'] ){
+            Log::error('recruitment','拉新活动,缺少城市:'.json_encode($custom));
+            return false;
+        }
+        // 获取城市ID
+        $cityId							= $custom['city_id'];
+        // 查询用户标签
+        $tags							= $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
+        $time                           =   time();
+        $select                         = [
+            ['start_time','<=',$time],
+            ['end_time','>',$time],
+            ['status','=',0],
+        ];
+        $activeList                     = $RecruitmentActive::query()->whereRaw("find_in_set('$cityId', city_ids)")->where($select)->get();
+        $activeInfo         =   [];
+        $data           =   [];
+        if ($activeList) {
+            foreach ($activeList as $active) {
+                $allowJoin = 0;
+                if ($active['tag_scope']) {
+                    // 解析数组
+                    $tag_scope = explode(',', $active['tag_scope']);
+                    // 标签范围限定时,默认不能参与
+                    // 判断标签是不是存在
+                    if ($tags) {
+                        foreach ($tags as $v) {
+                            // 标签范围内,允许参加
+                            if (in_array($v['name'], $tag_scope)) $allowJoin = 1;
+                        }
+                    }
+                }else{
+                    $allowJoin = 1;
+                }
+                if ($active['tag_except']) {
+                    // 解析数组
+                    $tag_except = explode(',', $active['tag_except']);
+                    // 标签范围限定时,默认不能参与
+                    $allowJoin = 0;
+                    // 判断标签是不是存在
+                    if ($tags) {
+                        foreach ($tags as $v) {
+                            // 标签范围内,允许参加
+                            if (in_array($v['name'], $tag_except)) $allowJoin = 0;
+                        }
+                    }
+                }
+                if ($allowJoin) {
+                    $activeInfo         =   $active;
+                    break;
+                }
+            }
+        }else{
+            Log::error('recruitment','custom_uid:'.$uid.';暂无拉新活动:');
+        }
+        if (!empty($activeInfo)){
+            $data['active_id']             =   $activeInfo['id'];
+            $data['old_uid']               =   $shareUid;
+            $data['new_uid']               =   $uid;
+            $data['insert_time']           =   $time;
+            $data['update_time']           =   $time;
+            //拉新记录
+            $recordId                      =   RecruitmentRecord::query()->insertGetId($data);
+            if ($recordId){
+                Log::info('recruitment','custom_uid:'.$uid.';拉新活动赠送奖励:'.json_encode($activeInfo));
+                //查询活动奖励配置
+                $prizeInfo                  =   RecruitmentActivePrize::query()->where('active_id','=',$activeInfo['id'])->first();
+                if (!$prizeInfo) {
+                    Log::info('recruitment','custom_uid:'.$uid.';拉新活动赠送奖励失败,无奖励配置:'.json_encode($prizeInfo));
+                    return false;
+                }
+                //赠送拉新奖励
+                if ($prizeInfo['old_prize']){
+                    switch ($prizeInfo['old_prize_type']) {
+                        case 1:
+                            //赠送老用户积分
+                            $res            =   $this->sendScore($shareUid,$prizeInfo['old_prize'],$recordId,1);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送老用户奖励失败:'.json_encode($prizeInfo));
+                            break;
+                        case 2:
+                            //赠送老用户优惠卷
+                            $res            =   $this->sendCoupon($shareUid,$prizeInfo['old_prize'],$recordId,1);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送老用户奖励失败:'.json_encode($prizeInfo));
+                            break;
+                    }
+                }
+                //赠送新用户奖励
+                if ($prizeInfo['new_prize']){
+                    switch ($prizeInfo['new_prize_type']) {
+                        case 1:
+                            //赠送老用户积分
+                            $res            =   $this->sendScore($uid,$prizeInfo['new_prize'],$recordId,2);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送新用户奖励失败:'.json_encode($prizeInfo));
+                            break;
+                        case 2:
+                            //赠送老用户优惠卷
+                            $res            =   $this->sendCoupon($uid,$prizeInfo['new_prize'],$recordId,2);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送新用户奖励失败:'.json_encode($prizeInfo));
+                            break;
+                    }
+                }
+                //赠送上级奖励
+                if ($prizeInfo['higher_prize']){
+                    //查询上级用户
+                    $higherInfo         =   RecruitmentRecord::query()->where('new_uid','=',$shareUid)->first();
+                    if (!$higherInfo)   return true;
+                    switch ($prizeInfo['higher_prize_type']) {
+                        case 1:
+                            //赠送上级积分
+                            $res            =   $this->sendScore($higherInfo['old_uid'],$prizeInfo['higher_prize'],$recordId,3);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$higherInfo['old_uid'].';拉新活动赠送上级奖励失败:'.json_encode($prizeInfo));
+                            break;
+                        case 2:
+                            //赠送上级优惠卷
+                            $res            =   $this->sendCoupon($higherInfo['old_uid'],$prizeInfo['higher_prize'],$recordId,3);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$higherInfo['old_uid'].';拉新活动赠送上级奖励失败:'.json_encode($prizeInfo));
+                            break;
+                    }
+                }
+            }else{
+                Log::error('recruitment','custom_uid:'.$uid.';拉新活动新增拉新记录失败:'.json_encode($data));
+            }
+        }else{
+            Log::error('recruitment','custom_uid:'.$uid.';无拉新活动:'.json_encode($activeInfo));
+        }
+        return true;
+    }
+    public function sendScore($uid,$prize,$recordId,$type=1){
+        $time       =   time();
+        $prize      =   (int)$prize;
+        $scoreInfo  =   CustomScore::query()->where('custom_uid','=',$uid)->first();
+        if ($scoreInfo){
+            $res    =   CustomScore::query()->where('custom_uid','=',$uid)->update(['score'=>$scoreInfo['score']+$prize,'update_time'=>$time]);
+        }else{
+            $res    =   CustomScore::query()->where('custom_uid','=',$uid)->insert(['custom_uid'=>$uid,'score'=>$prize,'update_time'=>$time,'insert_time'=>$time]);
+        }
+        if (!$res){
+            Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送老用户奖励失败:'.json_encode($prize));
+            return false;
+        }
+        $balance    =   CustomScore::query()->where('custom_uid','=',$uid)->first('score');
+        $recordInfo =   [
+            'score'         =>   $prize,
+            'balance'       =>   $balance,
+            'buy_type'      =>  9,
+            'pay_type'      =>  1,
+            'description'   =>  '拉新奖励',
+            'status'        =>  '1',
+            'pay_time'      =>  $time,
+            'insert_time'   =>  $time,
+            'update_time'   =>  $time,
+            'custom_uid'    =>  $uid,
+        ];
+        //用户积分记录
+        $res        =   Record::query()->insertGetId($recordInfo);
+        if (!$res){
+            Log::error('recruitment','积分记录失败;record:'.json_encode($recordInfo));
+            return false;
+        }
+        //拉新奖励记录
+        $prizeRecordInfo            =   [
+            'recruitment_record_id'     =>  $recordId,
+            'custom_uid'                =>  $uid,
+            'type'                      =>  $type,
+            'prize_type'                =>  1,
+            'prize'                     =>  $prize,
+            'insert_time'               =>  $time,
+            'update_time'               =>  $time,
+        ];
+        $res        =   RecruitmentPrizeRecord::query()->insertGetId($prizeRecordInfo);
+        if (!$res){
+            Log::error('recruitment','奖励记录失败;record:'.json_encode($prizeRecordInfo));
+            return false;
+        }
+        return true;
+    }
+    public function sendCoupon($uid,$prize,$recordId,$type=1){
+        $time       =   time();
+        $Coupon				                            = new \App\Models\Coupon();
+        $CustomCoupon				                    = new \App\Models\CustomCoupon();
+        // 获取优惠券的可用时间
+        $couponData			                            = $Coupon->query()->where([['id','=',$prize],['status','=','0']])->first(['issue_total','status','exp_time']);
+        // 如果不存在数据,发送失败
+        if( !$couponData || $couponData['status'] )     return 0;
+        // 查询总共发放数量
+        $total                                          = $this->query()->where([['coupon_id','=',$prize]])->count();
+        // 数量超过的话。不发
+        if( $total >= $couponData['issue_total'] )      return 0;
+        // 时间转时间
+        $expTime			                            = $Coupon->getExpTime($couponData['exp_time']);
+        // 发送优惠券
+        $res                                            =  $CustomCoupon->add(['coupon_id'=>$prize,'custom_uid'=>$uid,'exp_time'=>$expTime]);
+        if (!$res)  return false;
+        //拉新奖励记录
+        $prizeRecordInfo            =   [
+            'recruitment_record_id'     =>  $recordId,
+            'custom_uid'                =>  $uid,
+            'type'                      =>  $type,
+            'prize_type'                =>  1,
+            'prize'                     =>  $prize,
+            'insert_time'               =>  $time,
+            'update_time'               =>  $time,
+        ];
+        $res        =   RecruitmentPrizeRecord::query()->insertGetId($prizeRecordInfo);
+        if (!$res){
+            Log::error('recruitment','奖励记录失败;record:'.json_encode($prizeRecordInfo));
+            return false;
+        }
+        return true;
+    }
 }

+ 51 - 0
app/Http/Requests/Admin/RecruitmentActive.php

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

+ 1 - 1
app/Models/PromoProduct.php

@@ -178,7 +178,7 @@ class PromoProduct extends Model
             if ($reduction){
                 foreach ($value as $k=>$v){
                     // 优惠价格 = 价格占总价的比例 * 优惠的总价
-                    $productPrice[$v['product_id']]['promo_rebate_price']          = number_format( $reduction * ($productPrice[$v['product_id']]['price_total'] / $reduction) , 2 , '.' ,'');
+                    $productPrice[$v['product_id']]['promo_rebate_price']          = number_format( $reduction * ($productPrice[$v['product_id']]['price_total'] / $priceSum) , 2 , '.' ,'');
                 }
             }
         }

+ 126 - 0
app/Models/RecruitmentActive.php

@@ -0,0 +1,126 @@
+<?php namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 拉新活动模型
+ * 
+ */
+class RecruitmentActive extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'recruitment_active';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+    /**
+     * 添加数据
+     * 
+     */
+    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:recruitment:active:list');
+        // 不存在数据
+        if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where(['status'=>0])->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:recruitment: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('kllx','',$code));
+    }
+
+    /**
+     * id转编码
+     *
+     * @param  int  $uid 编码
+     *
+     */
+    public function idToCode($uid){
+        return 'kllx'. str_pad($uid, 9, '0', STR_PAD_LEFT);
+    }
+
+}

+ 104 - 0
app/Models/RecruitmentActivePrize.php

@@ -0,0 +1,104 @@
+<?php namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 拉新活动模型
+ * 
+ */
+class RecruitmentActivePrize extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'recruitment_active_prize';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 返回结果
+        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:coupon:active:list');
+        // 不存在数据
+        if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where(['status'=>0])->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:coupon: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);
+    }
+
+}

+ 106 - 0
app/Models/RecruitmentPrizeRecord.php

@@ -0,0 +1,106 @@
+<?php namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 拉新活动模型
+ * 
+ */
+class RecruitmentPrizeRecord extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'recruitment_prize_record';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 返回结果
+        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:coupon:active:list');
+        // 不存在数据
+        if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where(['status'=>0])->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:coupon: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);
+    }
+
+
+
+}

+ 106 - 0
app/Models/RecruitmentRecord.php

@@ -0,0 +1,106 @@
+<?php namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 拉新活动模型
+ * 
+ */
+class RecruitmentRecord extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'recruitment_record';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 返回结果
+        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:coupon:active:list');
+        // 不存在数据
+        if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where(['status'=>0])->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:coupon: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);
+    }
+
+
+
+}

+ 6 - 0
app/Models/Traits/Score/BuyType.php

@@ -60,6 +60,12 @@ trait BuyType
                                         'name'          =>'收货奖励',
                                         // 支付方式  方式名称
                                         'pay_type'      =>['1'=>['id'=>1,'name'=>'回执审核']],
+                                    ],'9'=>[
+                                        'id'            =>9,
+                                        // 类型名称
+                                        'name'          =>'拉新奖励',
+                                        // 支付方式  方式名称
+                                        'pay_type'      =>['1'=>['id'=>1,'name'=>'拉新奖励']],
                                     ]];
 
     /**

BIN
public/uploads/ueditor/images/admin/1/20240911/thumb.jpg


+ 12 - 8
resources/views/admin/banner/index.blade.php

@@ -44,17 +44,21 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td> {{$a['status']?'停用':'启用'}} </td>
 						<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 						<td>
+							@if(check_auth('admin/banner/edit'))
 							<a class="btn btn-sm btn-warning" href="{{url('admin/banner/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
 								编辑
 							</a>
-							@if ($a['status'])
-								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
-									启用
-								</a>
-							@else
-								<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
-									停用
-								</a>
+							@endif
+							@if(check_auth('admin/banner/set_status'))
+								@if ($a['status'])
+									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
+										启用
+									</a>
+								@else
+									<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+										停用
+									</a>
+								@endif
 							@endif
 						</td>
 					</tr>

+ 2 - 0
resources/views/admin/config/index.blade.php

@@ -19,9 +19,11 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<td>{{$a['id']}}</td>
 							<td>{{$a['info']}}</td>
 							<td>
+								@if(check_auth('admin/config/edit'))
 								<a class="btn btn-sm btn-warning" href="{{url('admin/config/edit?'.http_build_query(["id"=>$a["id"]]))}}">
 									编辑
 								</a>
+								@endif
 							</td>
 						</tr>
 					@endforeach

+ 9 - 0
resources/views/admin/orders/index.blade.php

@@ -49,6 +49,13 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			<option value="4" @if ( request('status') === '4' ) selected="selected" @endif >已取消</option>
 		</select>
 	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12" style="margin-right: 2px;">
+		<select name="is_regiment" class="form-control">
+			<option value="" >是否团单</option>
+			<option value="1" @if ( request('is_regiment') === '1' ) selected="selected" @endif >是</option>
+			<option value="2" @if ( request('is_regiment') === '2' ) selected="selected" @endif >否</option>
+		</select>
+	</div>
 	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12" style="margin-right: 2px;">
 		<select name="orders_other" class="form-control">
 			<option value="0" >订单分类</option>
@@ -90,6 +97,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>收货地址</th>
 						<th>订单状态</th>
 						<th>下单时间</th>
+						<th>是否团单</th>
 						<th>操作</th>
 					</tr>
 				</thead>
@@ -109,6 +117,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td>{{$a['contact_province']}}/{{$a['contact_city']}}/{{$a['contact_area']}}/{{$a['contact_addr']}} {{$a['contact_shop']}}</td>
 						<td>{{$a['state']}}</td>
 						<td>{{date('Y-m-d H:i:s',$a['insert_time'])}}</td>
+						<td>{{$a['regiment_id']>0?'是':'否'}}</td>
 						<td>
 							@if( check_auth('admin/orders/detail') )
 								@if( $a['status']==9 )

+ 12 - 8
resources/views/admin/orders_banner/index.blade.php

@@ -38,17 +38,21 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td> {{$a['status']?'停用':'启用'}} </td>
 						<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 						<td>
+							@if( check_auth('admin/orders_banner/edit') )
 							<a class="btn btn-sm btn-warning" href="{{url('admin/orders_banner/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
 								编辑
 							</a>
-							@if ($a['status'])
-								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
-									启用
-								</a>
-							@else
-								<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
-									停用
-								</a>
+							@endif
+							@if( check_auth('admin/orders_banner/set_status') )
+								@if ($a['status'])
+									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
+										启用
+									</a>
+								@else
+									<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+										停用
+									</a>
+								@endif
 							@endif
 						</td>
 					</tr>

+ 12 - 8
resources/views/admin/orders_receipt/index.blade.php

@@ -38,17 +38,21 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td> {{$a['status']?'停用':'启用'}} </td>
 						<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 						<td>
+							@if( check_auth('admin/orders_banner/edit') )
 							<a class="btn btn-sm btn-warning" href="{{url('admin/orders_banner/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
 								编辑
 							</a>
-							@if ($a['status'])
-								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
-									启用
-								</a>
-							@else
-								<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
-									停用
-								</a>
+							@endif
+							@if( check_auth('admin/orders_banner/set_status') )
+								@if ($a['status'])
+									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
+										启用
+									</a>
+								@else
+									<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+										停用
+									</a>
+								@endif
 							@endif
 						</td>
 					</tr>

+ 73 - 0
resources/views/admin/recruitment_active/add.blade.php

@@ -0,0 +1,73 @@
+@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-2">
+		<label class="control-label">活动首图 [1180*490]</label>
+		<div id="banner_img">
+			<a id="banner_img-image" href="#" data-toggle="image" class="img-thumb">
+				<img src="{{path_compat('')}}" width="120" />
+			</a>
+			<input type="hidden" name="banner_img" value="" id="input-banner_img" />
+		</div>
+	</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-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-3">
+		<label class="control-label">活动城市</label>
+		<select name="city_ids[]" class="form-control selectpicker" data-max-options="20" data-live-search="true" data-live-search-placeholder="搜索城市" data-none-results-text="未搜索到 {0}" title="选择城市" multiple>
+			@foreach ($cityList as $group)
+			<optgroup label="{{$group['name']}}">
+				@foreach ($group['city'] as $city)
+				<option value="{{$city['id']}}" >{{$city['name']}}</option>
+				@endforeach
+			</optgroup>
+			@endforeach
+		</select>
+	</div>
+	<div class="form-group col-sm-3">
+		<label class="control-label">标签范围(标签存在延迟,请慎用)</label>
+		<select name="tag_scope[]" class="form-control selectpicker" data-max-options="10" data-live-search="true" data-live-search-placeholder="搜索标签" data-none-results-text="未搜索到 {0}" title="选择标签" multiple>
+			@foreach ($tagList as $group=>$tags)
+			<optgroup label="{{$group}}">
+				@foreach ($tags as $tag)
+				<option value="{{$tag}}" >{{$tag}}</option>
+				@endforeach
+			</optgroup>
+			@endforeach
+		</select>
+	</div>
+	<div class="form-group col-sm-3">
+		<label class="control-label">标签除外(标签存在延迟,请慎用)</label>
+		<select name="tag_except[]" class="form-control selectpicker" data-max-options="10" data-live-search="true" data-live-search-placeholder="搜索标签" data-none-results-text="未搜索到 {0}" title="选择标签" multiple>
+			@foreach ($tagList as $group=>$tags)
+				<optgroup label="{{$group}}">
+					@foreach ($tags as $tag)
+						<option value="{{$tag}}" >{{$tag}}</option>
+					@endforeach
+				</optgroup>
+			@endforeach
+		</select>
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">活动规则</label>
+		<textarea class="form-control" name="active_rule" rows="10" placeholder="请输入活动规则" maxlength="255" ></textarea>
+	</div>
+	<div class="form-group col-sm-12">
+		@csrf
+		<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />
+	</div>
+</form>
+@endsection

+ 74 - 0
resources/views/admin/recruitment_active/edit.blade.php

@@ -0,0 +1,74 @@
+@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-2">
+		<label class="control-label">活动首图 [1180*490]</label>
+		<div id="banner_img">
+			<a id="banner_img-image" href="#" data-toggle="image" class="img-thumb">
+				<img src="{{path_compat($oldData['banner_img'])}}" width="120" />
+			</a>
+			<input type="hidden" name="banner_img" value="{{$oldData['banner_img']}}" id="input-banner_img" />
+		</div>
+	</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-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-3">
+		<label class="control-label">活动城市</label>
+		<select name="city_ids[]" class="form-control selectpicker" data-max-options="20" data-live-search="true" data-live-search-placeholder="搜索城市" data-none-results-text="未搜索到 {0}" title="选择城市" multiple>
+			@foreach ($cityList as $group)
+			<optgroup label="{{$group['name']}}">
+				@foreach ($group['city'] as $city)
+				<option value="{{$city['id']}}"  @if(in_array($city['id'],$oldData['city_ids'])) selected @endif >{{$city['name']}}</option>
+				@endforeach
+			</optgroup>
+			@endforeach
+		</select>
+	</div>
+	<div class="form-group col-sm-3">
+		<label class="control-label">标签范围(标签存在延迟,请慎用)</label>
+		<select name="tag_scope[]" class="form-control selectpicker" data-max-options="10" data-live-search="true" data-live-search-placeholder="搜索标签" data-none-results-text="未搜索到 {0}" title="选择标签" multiple>
+			@foreach ($tagList as $group=>$tags)
+			<optgroup label="{{$group}}">
+				@foreach ($tags as $tag)
+				<option value="{{$tag}}"  @if(in_array($tag,$oldData['tag_scope'])) selected @endif >{{$tag}}</option>
+				@endforeach
+			</optgroup>
+			@endforeach
+		</select>
+	</div>
+	<div class="form-group col-sm-3">
+		<label class="control-label">标签除外(标签存在延迟,请慎用)</label>
+		<select name="tag_except[]" class="form-control selectpicker" data-max-options="10" data-live-search="true" data-live-search-placeholder="搜索标签" data-none-results-text="未搜索到 {0}" title="选择标签" multiple>
+			@foreach ($tagList as $group=>$tags)
+				<optgroup label="{{$group}}">
+					@foreach ($tags as $tag)
+						<option value="{{$tag}}"  @if(in_array($tag,$oldData['tag_except'])) selected @endif >{{$tag}}</option>
+					@endforeach
+				</optgroup>
+			@endforeach
+		</select>
+	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">活动规则</label>
+		<textarea class="form-control" name="active_rule" rows="10" placeholder="请输入活动规则" >{{$oldData['active_rule']}}</textarea>
+	</div>
+	<div class="form-group col-sm-12">
+		@csrf
+		<input type="hidden" name="id" id="id" value="{{$oldData['id']}}" />
+		<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />
+	</div>
+</form>
+@endsection

+ 114 - 0
resources/views/admin/recruitment_active/index.blade.php

@@ -0,0 +1,114 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+
+@if(check_auth('admin/recruitment_active/add'))
+	<div class="page-header">
+		<a href="{{url('admin/recruitment_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>
+	<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="id_code" value="{{request('id_code','')}}" 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="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;">
+		<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/recruitment_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>
+						<th>活动状态</th>
+						<th>修改时间</th>
+						<th>操作</th>									
+					</tr>
+				</thead>
+				
+				<tbody>
+						@foreach ($list as $a)
+						<tr>
+							<th>{{$a['id_code']}}</th>
+							<td>{{$a['name']}}</td>
+							<td>{{$a['city_ids']}}</td>
+							<td>{{$a['tag_scope']}}</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>/pages/recruitment/index?id={{$a['id']}}</td>
+							<td>{{$a['mp_urllink']}}</td>
+							<td>
+								@if( $a['status'] )
+								停用
+								@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['update_time'])}}</td>
+							<td>
+								@if(check_auth('admin/recruitment_active_prize/edit'))
+								<a href="{{url('admin/recruitment_active_prize/edit?'.http_build_query(['active_id'=>$a['id']]))}}" class="btn btn-sm btn-primary" >奖励配置</a>
+								@endif
+								@if(check_auth('admin/recruitment_active/edit'))
+								<a href="{{url('admin/recruitment_active/edit?'.http_build_query(['id'=>$a['id']]))}}" class="btn btn-sm btn-warning" >编辑</a>
+								@endif
+								@if(check_auth('admin/recruitment_active/set_status'))
+									@if($a['status'])
+									<a data-url="{{url('admin/recruitment_active/set_status?'.http_build_query(['id'=>$a['id'],'status'=>0]))}}" class="set_status btn btn-sm btn-success" >启用</a>
+									@else
+									<a data-url="{{url('admin/recruitment_active/set_status?'.http_build_query(['id'=>$a['id'],'status'=>1]))}}" 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

+ 56 - 0
resources/views/admin/recruitment_active_prize/edit.blade.php

@@ -0,0 +1,56 @@
+@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-5">
+		<label class="control-label">老用户</label>
+		<select name="old_prize_type" class="form-control selectpicker" data-max-options="20" title="选择奖励类型">
+			<option>选择奖励类型</option>
+			<option value="1"  @if(isset($oldData['old_prize_type']) && $oldData['old_prize_type'] == 1) selected @endif >积分</option>
+			<option value="2"  @if(isset($oldData['old_prize_type']) && $oldData['old_prize_type'] == 2) selected @endif >优惠卷</option>
+		</select>
+
+	</div>
+	<div class="form-group col-sm-5">
+		<label class="control-label">奖励</label>
+		<input class="form-control" required="required" type="text" placeholder="老用户奖励" name="old_prize" value="{{isset($oldData['old_prize']) ? $oldData['old_prize'] : ''}}" />
+	</div>
+	<div class="form-group col-sm-5">
+		<label class="control-label">新用户</label>
+		<select name="new_prize_type" class="form-control selectpicker" data-max-options="20" title="选择奖励类型">
+			<option>选择奖励类型</option>
+			<option value="1"  @if(isset($oldData['new_prize_type']) && $oldData['new_prize_type'] == 1) selected @endif >积分</option>
+			<option value="2"  @if(isset($oldData['new_prize_type']) && $oldData['new_prize_type'] == 2) selected @endif >优惠卷</option>
+		</select>
+
+	</div>
+	<div class="form-group col-sm-5">
+		<label class="control-label">奖励</label>
+		<input class="form-control" required="required" type="text" placeholder="新用户奖励" name="new_prize" value="{{isset($oldData['new_prize']) ? $oldData['new_prize'] : ''}}" />
+	</div>
+	<div class="form-group col-sm-10">
+		<label class="control-label">分佣(上级分佣奖励)</label>
+	</div>
+	<div class="form-group col-sm-5">
+		<label class="control-label">上级用户</label>
+		<select name="higher_prize_type" class="form-control selectpicker" data-max-options="20" title="选择奖励类型">
+			<option>选择奖励类型</option>
+			<option value="1"  @if(isset($oldData['higher_prize_type']) && $oldData['higher_prize_type'] == 1) selected @endif >积分</option>
+			<option value="2"  @if(isset($oldData['higher_prize_type']) && $oldData['higher_prize_type'] == 2) selected @endif >优惠卷</option>
+		</select>
+
+	</div>
+	<div class="form-group col-sm-5">
+		<label class="control-label">奖励</label>
+		<input class="form-control" required="required" type="text" placeholder="上级用户奖励" name="higher_prize" value="{{isset($oldData['higher_prize']) ? $oldData['higher_prize'] : ''}}" />
+	</div>
+	<div class="form-group col-sm-12">
+		@csrf
+		<input type="hidden" name="id" id="id" value="{{isset($oldData['id']) ?? $oldData['id']}}" />
+		<input type="hidden" name="active_id" id="active_id" value="{{$activeId}}" />
+		<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />
+	</div>
+</form>
+@endsection

+ 67 - 0
resources/views/admin/recruitment_record/index.blade.php

@@ -0,0 +1,67 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+
+<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="old_uid_code" value="{{request('old_uid_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="new_uid_code" value="{{request('new_uid_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="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/recruitment_record/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>
+					</tr>
+				</thead>
+				
+				<tbody>
+						@foreach ($list as $a)
+						<tr>
+							<th>{{$a['active_id_code']}}</th>
+							<td>{{$a['active_name']}}</td>
+							<td>{{$a['old_uid_code']}}</td>
+							<td>{{$a['old_name']}}</td>
+							<td>{{$a['new_uid_code']}}</td>
+							<td>{{$a['new_name']}}</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

+ 2 - 2
resources/views/admin/regiment/index.blade.php

@@ -68,10 +68,10 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 									拼团中
 								@endif
 								@if( $a['status'] == 2 )
-										拼团成功
+										拼团失败
 								@endif
 								@if( $a['status'] == 3 )
-										拼团失败
+										拼团成功
 								@endif
 							</td>
 							<td>{{date('Y/m/d H:i:s',$a['start_time'])}}</td>

+ 2 - 0
resources/views/admin/score_clockin/index.blade.php

@@ -32,9 +32,11 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td>{{$a['coupon_name'] ? $a['coupon_name'].'('.$a['coupon_code'].')':''}}</td>
 						<td>{{date('Y-m-d H:i:s',$a['update_time'])}}</td>
 						<td>
+							@if(check_auth('admin/score_clockin/edit'))
 							<a class="btn btn-sm btn-warning" href="{{url('admin/score_clockin/edit?'.http_build_query(['id'=>$a['id']]))}}">
 								编辑
 							</a>
+							@endif
 							<!-- @if ($a['status'])
 								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/score_clockin/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
 									启用

+ 12 - 8
resources/views/admin/score_product/index.blade.php

@@ -55,17 +55,21 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td> {{$a['admin_name']}}</td>
 						<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
 						<td>
+							@if(check_auth('admin/score_product/edit'))
 							<a class="btn btn-sm btn-warning" href="{{url('admin/score_product/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
 								编辑
 							</a>
-							@if ($a['status'])
-								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/score_product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
-									上架
-								</a>
-							@else
-								<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/score_product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
-									下架
-								</a>
+							@endif
+							@if(check_auth('admin/score_product/set_status'))
+								@if ($a['status'])
+									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/score_product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
+										上架
+									</a>
+								@else
+									<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/score_product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+										下架
+									</a>
+								@endif
 							@endif
 						</td>
 					</tr>

+ 12 - 8
resources/views/admin/weiban_qrcode/index.blade.php

@@ -36,17 +36,21 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td> {{$a['status']?'停用':'启用'}} </td>
 						<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 						<td>
+							@if(check_auth('admin/weiban_qrcode/edit'))
 							<a class="btn btn-sm btn-warning" href="{{url('admin/weiban_qrcode/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
 								编辑
 							</a>
-							@if ($a['status'])
-								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/weiban_qrcode/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
-									启用
-								</a>
-							@else
-								<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/weiban_qrcode/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
-									停用
-								</a>
+							@endif
+							@if(check_auth('admin/weiban_qrcode/set_status'))
+								@if ($a['status'])
+									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/weiban_qrcode/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
+										启用
+									</a>
+								@else
+									<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/weiban_qrcode/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+										停用
+									</a>
+								@endif
 							@endif
 						</td>
 					</tr>

+ 8 - 1
routes/api.php

@@ -196,4 +196,11 @@ Route::any('orders/cancel_regiment',[\App\Http\Controllers\Api\Orders::class,'ca
  * 分享信息
  * 
  * */
-Route::any('share_message/get_list',[\App\Http\Controllers\Api\ShareMessage::class,'get_list']);
+Route::any('share_message/get_list',[\App\Http\Controllers\Api\ShareMessage::class,'get_list']);
+
+/**
+ * 拉新活动
+ *
+ * */
+Route::any('recruitment/get_info',[\App\Http\Controllers\Api\Recruitment::class,'get_info']);
+Route::any('recruitment/get_record',[\App\Http\Controllers\Api\Recruitment::class,'get_record']);

+ 16 - 0
routes/web.php

@@ -511,4 +511,20 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     Route::any('promo_product/set_status',[App\Http\Controllers\Admin\PromoProduct::class,'set_status']);
 
 
+    /* 拉新活动 */
+    // 拉新活动列表
+    Route::any('recruitment_active/index',[App\Http\Controllers\Admin\RecruitmentActive::class,'index']);
+    // 新增
+    Route::any('recruitment_active/add',[App\Http\Controllers\Admin\RecruitmentActive::class,'add']);
+    // 编辑
+    Route::any('recruitment_active/edit',[App\Http\Controllers\Admin\RecruitmentActive::class,'edit']);
+    // 复制
+    Route::any('recruitment_active/copy',[App\Http\Controllers\Admin\RecruitmentActive::class,'copy']);
+    // 状态
+    Route::any('recruitment_active/set_status',[App\Http\Controllers\Admin\RecruitmentActive::class,'set_status']);
+    //奖励配置
+    Route::any('recruitment_active_prize/edit',[App\Http\Controllers\Admin\RecruitmentActivePrize::class,'edit']);
+    // 拉新活动数据列表
+    Route::any('recruitment_record/index',[App\Http\Controllers\Admin\RecruitmentRecord::class,'index']);
+
 });