156 lines
6.3 KiB
PHP
156 lines
6.3 KiB
PHP
<?php
|
|
namespace app\api\controller;
|
|
|
|
use app\common\logic\finance\ShareProfit;
|
|
use app\common\logic\task\TaskLogic;
|
|
use app\common\model\Company;
|
|
use app\common\model\task\Task;
|
|
use app\common\model\task_scheduling\TaskScheduling;
|
|
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
|
use app\common\model\task_template\TaskTemplate;
|
|
use think\facade\Log;
|
|
use app\job\TaskInformationJob;
|
|
use Symfony\Component\HttpClient\HttpClient;
|
|
|
|
class CeshiController extends BaseApiController
|
|
{
|
|
public array $notNeedLogin = ['index','ceshi','ceshi1','ceshi2'];
|
|
|
|
/**
|
|
* 任务结算
|
|
*/
|
|
public function index()
|
|
{
|
|
// $all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
// halt($all);
|
|
$all=TaskSchedulingPlan::whereDay('end_time')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
foreach($all as $k=>$v){
|
|
queue(TaskInformationJob::class,$v);
|
|
}
|
|
halt(1);
|
|
}
|
|
|
|
/**
|
|
* 任务刷新
|
|
*/
|
|
public function ceshi(){
|
|
|
|
$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();
|
|
foreach($plan_all as $k=>$v){
|
|
$all=TaskTemplate::where('status',1)->where('task_scheduling',$v['id'])->limit(30)->select()->toArray();
|
|
if($all){
|
|
$plan_all[$k]['template']=$all;
|
|
}else{
|
|
unset($plan_all[$k]);
|
|
}
|
|
}
|
|
$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'];
|
|
}
|
|
Company::where('id','in',$company_id)->inc('day_count')->update();
|
|
}
|
|
|
|
public function stage_inspection($v,$moeny_type='moeny',$title='一'){
|
|
$count_moeny=0;
|
|
foreach($v['template'] as $kkkk=>$vvvv){
|
|
$count_moeny+=$vvvv[$moeny_type];
|
|
}
|
|
if($count_moeny>200){
|
|
Log::info($title.'阶段金额大于200无法下达'.json_encode($v['company_info']));
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
//三轮车判断
|
|
public function ceshi1(){
|
|
$params=[
|
|
'car_id'=>3,
|
|
'start_time'=>'2023-08-18',
|
|
'end_time'=>'2023-08-18 23:59:59'
|
|
];
|
|
$task=Task::where('id',487)->select()->toArray();
|
|
foreach($task as $k=>$v){
|
|
if(isset($v['extend']['terminus']['lnglat'])&& isset($v['extend']['transfer']['lnglat'])){
|
|
$arr=$v['extend']['terminus']['lnglat'];
|
|
$a=app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
|
|
|
|
$arr_two=$v['extend']['transfer']['lnglat'];
|
|
$b=app(RemoteController::class)->coordinate($params,$arr_two[0],$arr_two[1]);
|
|
if($a<500 && $b<500){
|
|
Task::where('id',$v['id'])->update(['status'=>3]);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public function ceshi2(){
|
|
$all=TaskSchedulingPlan::where('id',699)->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
foreach($all as $k=>$data){
|
|
// $company = Company::where('id', $data['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
|
|
$task = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
|
|
$arr['money'] = $data['template_info']['money'];
|
|
$arr['company_id'] = $data['scheduling']['company_id'];
|
|
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成人,的任务结算';
|
|
$arr['proportion_one'] = $data['template_info']['proportion_one'];
|
|
$arr['proportion_two'] = $data['template_info']['proportion_two'];
|
|
$arr['sn'] = $data['sn'];
|
|
$arr['id'] = $data['id'];
|
|
}
|
|
halt($arr);
|
|
}
|
|
|
|
} |