diff --git a/app/api/controller/CeshiController.php b/app/api/controller/CeshiController.php index 8f3b3c5fa..c24353f3b 100644 --- a/app/api/controller/CeshiController.php +++ b/app/api/controller/CeshiController.php @@ -38,7 +38,7 @@ class CeshiController extends BaseApiController $time=strtotime(date('Y-m-d')); // $time=strtotime(date('Y-m-d')); // $tiem_end=$time+86399;where('cron_time','<',$time)-> - $plan_all=TaskScheduling::where('status',1)->with('company_info')->select()->toArray(); + $plan_all=TaskScheduling::where('id',99)->with('company_info')->select()->toArray(); foreach($plan_all as $k=>$v){ $all=TaskTemplate::where('status',1)->where('task_scheduling',$v['id'])->limit(30)->select()->toArray(); if($all){ @@ -49,53 +49,7 @@ class CeshiController extends BaseApiController } $company_id=[]; foreach($plan_all as $k=>$v){ - - foreach($v['template'] as $kkk=>$vvv){ - if ($v['types'] == 1 ||$vvv['types'] == 3) { - if ($v['company_info'] && $v['company_info']['day_count'] <=$vvv['stage_day_one']) { - $res=$this->stage_inspection($v['template'],'moeny','一'); - if($res==false){ - return false; - } - } else { - $res=$this->stage_inspection($v['template'],'money_two','二'); - if($res==false){ - return false; - } - } - } elseif ($v['types'] == 2) { - if ($v['company_info']['day_count'] <=$vvv['stage_day_one']) { - $res=$this->stage_inspection($v['template'],'moeny','一'); - if($res==false){ - return false; - } - } elseif ($v['company_info']['day_count'] <=$vvv['stage_day_two']) { - $res=$this->stage_inspection($v['template'],'money_two','二'); - if($res==false){ - return false; - } - } else { - $res=$this->stage_inspection($v['template'],'money_three','三'); - if($res==false){ - return false; - } - } - } else { - if ( $v['company_info']['day_count'] <=$vvv['stage_day_one']) { - $res=$this->stage_inspection($v['template'],'money_three','三'); - if($res==false){ - return false; - } - } else { - $res=$this->stage_inspection($v['template'],'money_two','二'); - if($res==false){ - return false; - } - } - } - } foreach($v['template'] as $kk=>$vv){ - halt($v); TaskLogic::CronAdd($vv,$v); } $company_id[]=$v['company_id']; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 850feede3..bc0eddec3 100755 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -84,7 +84,6 @@ class PayNotifyLogic extends BaseLogic $order->pay_status = PayEnum::ISPAID; $order->pay_time = time(); $order->save(); -Log::error($order->toArray()); if($order && isset($order['extend']['type']) &&$order['extend']['type']==1){ $find=Task::where('id',$order['extend']['task_id'])->find(); if($find &&isset($find['extend']['shareholder'])){ diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 24f6c72d8..2c19b2182 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -70,60 +70,21 @@ class TaskLogic extends BaseLogic /** * 定时添加任务 */ - public static function CronAdd(array $v,$datas): bool + public static function CronAdd(array $v, $datas): bool { try { - $time=strtotime(date('Y-m-d')); - $TaskSchedulingPlan_data=[ + $time = strtotime(date('Y-m-d')); + $TaskSchedulingPlan_data = [ 'create_user_id' => 0, 'company_id' => $v['company_id'], 'template_id' => $v['id'], 'scheduling_id' => $v['task_scheduling'], 'start_time' => $time, - 'end_time' => $time+86399, - 'sn' =>User::createUserSn(), + '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'=>['money'=>$v['recharge'],'over_decimal'=>$v['over_decimal'],'count_money'=>$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); + $TaskSchedulingPlan = TaskSchedulingPlan::create($TaskSchedulingPlan_data); $arr = [ 'template_id' => $v['id'], 'scheduling_plan_id' => $TaskSchedulingPlan['id'], @@ -133,23 +94,23 @@ class TaskLogic extends BaseLogic 'type' => $v['type'], 'content' => $v['content'], 'start_time' => $time, - 'end_time' => $time+86399, + 'end_time' => $time + 86399, 'create_time' => time(), 'update_time' => time(), ]; $data = $arr; - $data['money'] = self::task_money($v,$datas); + $data['money'] = self::task_money($v, $datas); $data['extend'] = json_encode($v['extend']); //信息更新 if ($v['type'] == 31) { - $finds=TaskTemplate::where('id', $v['id'])->field('information_count,information_day_count')->find(); - $update=0; - if($finds['information_count']>$finds['information_day_count']){ - $day_count=$finds['information_count']-$finds['information_day_count']; - if($day_count>=5){ - $update=5; - }else{ - $update=$day_count; + $finds = TaskTemplate::where('id', $v['id'])->field('information_count,information_day_count')->find(); + $update = 0; + if ($finds['information_count'] > $finds['information_day_count']) { + $day_count = $finds['information_count'] - $finds['information_day_count']; + if ($day_count >= 5) { + $update = 5; + } else { + $update = $day_count; } } $data["extend"] = json_encode(['informationg' => ['count' => 5, 'update' => $update]]); @@ -158,6 +119,19 @@ class TaskLogic extends BaseLogic if ($v['type'] == 32) { $data['director_uid'] = $datas['company_info']['user_id']; } + //入股任务 + if ($v['type'] == 35) { + $user_ids = User::where('company_id', $v['company_id'])->where('is_captain', 1)->field('id,nickname')->select(); + if(isset($v['extend']['shareholder'])){ + $v['extend']['shareholder']['money']=$v['recharge']; + $v['extend']['shareholder']['over_decimal']=$v['over_decimal']; + foreach($user_ids as $kkk=>$vvv){ + $v['extend']['shareholder']['user_list'][$kkk]=['name'=>$vvv['nickname'],'money'=>bcdiv($v['recharge'],count($user_ids),2),'time'=>$v['create_time']]; + } + } + $data['extend']=json_encode($v['extend']); + } + halt($data); $task_id = (new Task())->insertGetId($data); TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]); // TaskTemplate::where('id', $v['id'])->update(['cron_time' => time()]); @@ -168,7 +142,7 @@ class TaskLogic extends BaseLogic } } //任务金额 - private static function task_money($v,$datas) + private static function task_money($v, $datas) { if ($v['types'] == 1 || $v['types'] == 3) { if ($datas['company_info'] && $datas['company_info']['day_count'] <= $v['stage_day_one']) { @@ -185,7 +159,7 @@ class TaskLogic extends BaseLogic return $v['money_three']; } } else { - if ( $datas['company_info']['day_count'] <= $v['stage_day_one']) { + if ($datas['company_info']['day_count'] <= $v['stage_day_one']) { $a = $v['money']; } else { $a = $v['money_two']; diff --git a/app/common/logic/task_template/TaskTemplateLogic.php b/app/common/logic/task_template/TaskTemplateLogic.php index 5859e4ca9..27acfe89b 100644 --- a/app/common/logic/task_template/TaskTemplateLogic.php +++ b/app/common/logic/task_template/TaskTemplateLogic.php @@ -81,6 +81,9 @@ class TaskTemplateLogic extends BaseLogic if($params['types']!=33){ $params['money_three']=0; } + if($params['type']==35){ + $params['extend']=['shareholder'=>['user_id'=>$params['task_admin']]]; + } TaskTemplate::create([ 'title' => $params['title'], 'admin_id' => $params['admin_id'],