TaskSystem/app/api/controller/CeshiController.php

67 lines
2.6 KiB
PHP
Raw Normal View History

2023-08-10 17:10:12 +08:00
<?php
namespace app\api\controller;
use app\common\logic\finance\ShareProfit;
use app\common\logic\task\TaskLogic;
2023-08-14 17:44:55 +08:00
use app\common\model\Company;
2023-08-10 17:10:12 +08:00
use app\common\model\task\Task;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
2023-08-14 17:44:55 +08:00
use think\facade\Log;
2023-08-15 14:38:20 +08:00
use app\job\TaskInformationJob;
2023-08-10 17:10:12 +08:00
class CeshiController extends BaseApiController
{
public array $notNeedLogin = ['index','ceshi'];
public function index()
{
2023-08-16 00:14:09 +08:00
$all=TaskSchedulingPlan::whereDay('start_time')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
// halt($all);
2023-08-15 14:38:20 +08:00
foreach($all as $k=>$v){
queue(TaskInformationJob::class,$v);
}
halt(1);
2023-08-14 17:44:55 +08:00
//,'yesterday'
$all=TaskSchedulingPlan::whereDay('end_time')->where('is_pay',0)->with(['template_info','scheduling'])->select();
2023-08-10 17:10:12 +08:00
foreach($all as $k=>$data){
$task_id=explode(',',$data['task_id']);
2023-08-11 16:35:07 +08:00
$task_count=Task::where('id','in',$task_id)->field('director_uid')->with('director_info')->select();
2023-08-14 17:44:55 +08:00
if(empty($task_count)){
Log::error('任务结算失败任务id'.$task_id);
continue;
}
2023-08-10 17:10:12 +08:00
if(count($task_count)==count($task_id)){
2023-08-11 16:35:07 +08:00
$name_arr=[];
foreach ($task_count as $key => $value) {
$name_arr[$key]=$value['director_info']['nickname'];
}
$name=implode(',',$name_arr);
2023-08-10 17:10:12 +08:00
$arr['money']=$data['template_info']['money'];
$arr['company_id']=$data['scheduling']['company_id'];
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
2023-08-14 17:44:55 +08:00
$arr['proportion_one']=$data['template_info']['proportion_one'];
$arr['proportion_two']=$data['template_info']['proportion_two'];
2023-08-10 17:10:12 +08:00
$arr['sn']=$data['sn'];
2023-08-14 17:44:55 +08:00
$arr['id']=$data['id'];
2023-08-10 17:10:12 +08:00
(new ShareProfit())->first($arr);
}
}
2023-08-11 16:35:07 +08:00
halt(2);
2023-08-10 17:10:12 +08:00
}
public function ceshi(){
// $time=strtotime(date('Y-m-d',strtotime('+1 day')));
$time=strtotime(date('Y-m-d'));
$tiem_end=$time+86399;
2023-08-14 17:44:55 +08:00
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling','company'])->select()->toArray();
$company_id=0;
2023-08-10 17:10:12 +08:00
foreach($all as $k=>$v){
TaskLogic::CronAdd($v);
2023-08-14 17:44:55 +08:00
$company_id=$v['company_id'];
}
if($company_id!=0){
Company::where('id',$company_id)->inc('day_count')->update();
2023-08-10 17:10:12 +08:00
}
2023-08-11 16:35:07 +08:00
halt(TaskLogic::getError());
2023-08-10 17:10:12 +08:00
}
}