jun 5 сар өмнө
parent
commit
6bcc3001bf

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

@@ -0,0 +1,214 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Facades\Servers\WechatMini\Mini;
+use App\Http\Requests\Admin\Coupon\Active 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){
+		// 接收参数
+		$name					= request('name','');
+		// 查询条件
+		$map 					= [];
+		// 组合条件
+		if( $name )				$map[] = ['name','=',$name];
+		// 查询数据
+		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
+		// 循环处理数据
+		foreach ($list as $key => $value) {
+			// 小程序链接
+			$value['mp_urllink']= $this->getUrlLink($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/active','?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,ActiveCoupon $ActiveCoupon){
+		// 验证参数
+		$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'=>'数据不存在']);
+		// 如果设置上架
+		if( !$status )	{
+			// 判断奖品个数
+			$count		= $ActiveCoupon->query()->where([['status','=',0],['active_id','=',$id]])->count();
+			// 获取统计数量
+			if( !$count ) 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();
+	}
+
+
+}

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

@@ -0,0 +1,126 @@
+<?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;
+                }
+            }
+        }
+        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.id','=','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]);
+    }
+
+
+}

+ 218 - 2
app/Http/Controllers/Api/Wechat.php

@@ -1,8 +1,17 @@
 <?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\RecruitmentPrizeRecord;
+use App\Models\RecruitmentRecord;
+use App\Models\Score\Record;
+use App\Models\WeiBan\Tags;
+use App\Models\CustomScore;
+use Vinkla\Hashids\Facades\Hashids;
 
 /**
  * 微信接口
@@ -24,6 +33,7 @@ class Wechat extends Api{
 		// $this->verify_sign();
 		// 接收参数
 		$code									= request('code','');
+		$shareUid								= request('share_uid','');
 		// 授权结果
 		$result									= Mini::getUserPhone($code);
 		// 如果所需字段不存在
@@ -42,12 +52,218 @@ 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){
+                $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($uid);
+        if ($shareUid){
+            $shareUid       =   Hashids::decode($shareUid);
+        }
+        //查询拉新活动
+        if( !$custom['city_id'] )		return json_send(['code'=>'error','msg'=>'请选择所在城市后下单','data'=>['error'=>'请选择所在城市后下单']]);
+        // 获取城市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;
+                }
+            }
+        }
+        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){
+                //赠送拉新奖励
+                if ($activeInfo['old_prize']){
+                    switch ($activeInfo['old_prize_type']) {
+                        case 1:
+                            //赠送老用户积分
+                            $res            =   $this->sendScore($shareUid,$activeInfo['old_prize'],$recordId,1);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送老用户奖励失败:'.json_encode($activeInfo));
+                            break;
+                        case 2:
+                            //赠送老用户优惠卷
+                            $res            =   $this->sendCoupon($shareUid,$activeInfo['old_prize'],$recordId,1);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送老用户奖励失败:'.json_encode($activeInfo));
+                            break;
+                    }
+                }
+                //赠送新用户奖励
+                if ($activeInfo['new_prize']){
+                    switch ($activeInfo['new_prize_type']) {
+                        case 1:
+                            //赠送老用户积分
+                            $res            =   $this->sendScore($uid,$activeInfo['new_prize'],$recordId,2);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送新用户奖励失败:'.json_encode($activeInfo));
+                            break;
+                        case 2:
+                            //赠送老用户优惠卷
+                            $res            =   $this->sendCoupon($uid,$activeInfo['new_prize'],$recordId,2);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$uid.';拉新活动赠送新用户奖励失败:'.json_encode($activeInfo));
+                            break;
+                    }
+                }
+                //赠送上级奖励
+                if ($activeInfo['higher_prize']){
+                    //查询上级用户
+                    $higherInfo         =   RecruitmentRecord::query()->where('new_uid','=',$shareUid)->first();
+                    if (!$higherInfo)   return true;
+                    switch ($activeInfo['higher_prize_type']) {
+                        case 1:
+                            //赠送上级积分
+                            $res            =   $this->sendScore($higherInfo['old_uid'],$activeInfo['higher_prize'],$recordId,3);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$higherInfo['old_uid'].';拉新活动赠送上级奖励失败:'.json_encode($activeInfo));
+                            break;
+                        case 2:
+                            //赠送上级优惠卷
+                            $res            =   $this->sendCoupon($higherInfo['old_uid'],$activeInfo['higher_prize'],$recordId,3);
+                            if (!$res)      Log::error('recruitment','custom_uid:'.$higherInfo['old_uid'].';拉新活动赠送上级奖励失败:'.json_encode($activeInfo));
+                            break;
+                    }
+                }
+            }else{
+                Log::error('recruitment','custom_uid:'.$uid.';拉新活动新增拉新记录失败:'.json_encode($data));
+            }
+        }
+        return true;
+    }
+    public function sendScore($uid,$prize,$recordId,$type=1){
+        $time       =   time();
+        $res        =   CustomScore::query()->where('custom_uid','=',$uid)->increment('score',$prize);
+        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;
+    }
 }

+ 106 - 0
app/Models/RecruitmentActive.php

@@ -0,0 +1,106 @@
+<?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: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);
+    }
+
+}

+ 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'=>'拉新奖励']],
                                     ]];
 
     /**

+ 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

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

@@ -0,0 +1,93 @@
+@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>
+	<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>									
+					</tr>
+				</thead>
+				
+				<tbody>
+						@foreach ($list as $a)
+						<tr>
+							<th>{{$a['id']}}</th>
+							<td>{{$a['name']}}</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/coupon/active?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

+ 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']);

+ 14 - 0
routes/web.php

@@ -510,4 +510,18 @@ 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']);
+
 });