From 6b294d95714fa43d6cd77fd56ae0184640dbe4e8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 28 Aug 2023 18:46:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/TaskController.php | 8 ++++ app/common/logic/task/TaskLogic.php | 44 ++++++++++++++++++- .../logic/task_template/TaskTemplateLogic.php | 2 + 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index 438e70874..f2d4c4823 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -89,6 +89,14 @@ class TaskController extends BaseApiController return $this->success('ok'); } + /** + * 入股 + */ + public function shareholder(){ + $parmas = $this->request->param(); + $task = TaskLogic::detail($parmas); + return $this->success('ok', $task); + } /** * 三轮车详情 */ diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 06b3bc522..c2a179268 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -74,7 +74,7 @@ class TaskLogic extends BaseLogic { try { $time=strtotime(date('Y-m-d')); - $TaskSchedulingPlan=TaskSchedulingPlan::create([ + $TaskSchedulingPlan_data=[ 'create_user_id' => 0, 'company_id' => $v['company_id'], 'template_id' => $v['id'], @@ -83,7 +83,47 @@ class TaskLogic extends BaseLogic 'end_time' => $time+86399, 'sn' =>User::createUserSn(), 'status' => 1 - ]); + ]; + + //入股任务 + if($v['type']==35){ + $user_ids=User::where('company_id', $v['company_id'])->where('is_captain',1)->field('id,nickname')->select(); + if($user_ids){ + foreach($user_ids as $u_k=>$u_v){ + $find_35=Task::where('company_id', $v['company_id'])->where('id', $v['id'])->where('type',35)->where('director_uid',$u_v['id'])->where('status',3)->find(); + if(!$find_35){ + $TaskSchedulingPlan=TaskSchedulingPlan::create($TaskSchedulingPlan_data); + $arr = [ + 'template_id' => $v['id'], + 'scheduling_plan_id' => $TaskSchedulingPlan['id'], + 'company_id' => $v['company_id'], + 'title' => $v['title'], + 'money' => $v['money'], + 'type' => $v['type'], + 'content' => $v['content'], + 'start_time' => $time, + 'end_time' => $time+86399, + 'create_time' => time(), + 'update_time' => time(), + ]; + $data = $arr; + $data['money'] = 0; + $data['extend'] = json_encode(['shareholder'=>['moeny'=>$v['recharge'],'over_decimal'=>$v['over_decimal'],'count_moeny'=>$v['recharge']*count($user_ids)]]); + $data['type'] = 35; + $data['title'] = $u_v['nickname'].'的入股任务'; + $data['status'] = 2; + $data['director_uid'] = $u_v['id']; + $task_id = (new Task())->insertGetId($data); + TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]); + } + } + return true; + }else{ + Log::info('没有队长,任务下发失败'. json_encode($v)); + return false; + } + } + $TaskSchedulingPlan=TaskSchedulingPlan::create($TaskSchedulingPlan_data); $arr = [ 'template_id' => $v['id'], 'scheduling_plan_id' => $TaskSchedulingPlan['id'], diff --git a/app/common/logic/task_template/TaskTemplateLogic.php b/app/common/logic/task_template/TaskTemplateLogic.php index 6e6900992..5859e4ca9 100644 --- a/app/common/logic/task_template/TaskTemplateLogic.php +++ b/app/common/logic/task_template/TaskTemplateLogic.php @@ -98,6 +98,7 @@ class TaskTemplateLogic extends BaseLogic 'proportion_one' => $params['proportion_one']??0, 'stage_day_two' => $params['stage_day_two']??0, 'proportion_two' => $params['proportion_two']??0, + 'recharge' => $params['recharge']??0, ]); Db::commit(); @@ -173,6 +174,7 @@ class TaskTemplateLogic extends BaseLogic 'proportion_one' => $params['proportion_one']??0, 'stage_day_two' => $params['stage_day_two']??0, 'proportion_two' => $params['proportion_two']??0, + 'recharge' => $params['recharge']??0, ]); Db::commit();