This commit is contained in:
mkm 2023-08-21 16:32:56 +08:00
parent fc9c0d52d3
commit 8c0dcc669c
4 changed files with 72 additions and 51 deletions

View File

@ -24,61 +24,15 @@ class CeshiController extends BaseApiController
queue(TaskInformationJob::class,$v); queue(TaskInformationJob::class,$v);
} }
halt(1); halt(1);
//,'yesterday'
$all=TaskSchedulingPlan::whereDay('end_time')->where('is_pay',0)->with(['template_info','scheduling'])->select();
foreach($all as $k=>$data){
$task_id=explode(',',$data['task_id']);
$task_count=Task::where('id','in',$task_id)->field('director_uid')->with('director_info')->select();
if(empty($task_count)){
Log::error('任务结算失败任务id'.$task_id);
continue;
}
if(count($task_count)==count($task_id)){
$name_arr=[];
foreach ($task_count as $key => $value) {
$name_arr[$key]=$value['director_info']['nickname'];
}
$name=implode(',',$name_arr);
$arr['money']=$data['template_info']['money'];
$arr['company_id']=$data['scheduling']['company_id'];
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
$arr['proportion_one']=$data['template_info']['proportion_one'];
$arr['proportion_two']=$data['template_info']['proportion_two'];
$arr['sn']=$data['sn'];
$arr['id']=$data['id'];
(new ShareProfit())->first($arr);
}
}
halt(2);
} }
public function ceshi(){ public function ceshi(){
$parmas=[
'car_id'=>3,
'start_time'=>'2023-08-18',
'end_time'=>'2023-08-18 23:59:59',
];
$res = HttpClient::create()->request('GET', 'http://logistics.lihaink.cn/api/getCarHistory', [
'query' => $parmas,
]);
$json=json_decode($res->getContent(),true);
$points=$json['data'];
$target =[
"lat"=> 28.917378,
"lon"=> 105.443005
];
$closestPoint = $this->getClosestPoint($points, $target);
halt($this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat'],1));
halt($closestPoint);
$time=strtotime(date('Y-m-d')); $time=strtotime(date('Y-m-d'));
// $time=strtotime(date('Y-m-d')); // $time=strtotime(date('Y-m-d'));
// $tiem_end=$time+86399; // $tiem_end=$time+86399;
$all=TaskTemplate::where('cron_time','<',$time)->where('status',1)->with('company')->select()->toArray(); // $all=TaskTemplate::where('cron_time','<',$time)->where('status',1)->with('company')->select()->toArray();
// $all=TaskTemplate::where('id',60)->with('company')->select()->toArray(); $all=TaskTemplate::where('id',73)->with('company')->select()->toArray();
// $all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray(); // $all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
$company_id=0; $company_id=0;
foreach($all as $k=>$v){ foreach($all as $k=>$v){

View File

@ -92,4 +92,63 @@ class RemoteController extends BaseApiController
return false; return false;
} }
} }
/**
*
* 获取坐标的距离
*/
public function coordinate($parmas,$longitude1,$latitude1){
$res = HttpClient::create()->request('GET', 'http://logistics.lihaink.cn/api/getCarHistory', [
'query' => $parmas,
]);
$json=json_decode($res->getContent(),true);
$points=$json['data'];
$target =[
"lat"=> $latitude1,
"lon"=> $longitude1
];
$closestPoint = $this->getClosestPoint($points, $target);
return $this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat']);
}
/**
*
* 计算两点之间的距离
*/
function getClosestPoint($points, $target) {
$minDistance = PHP_INT_MAX;
$closestPoint = null;
foreach ($points as $point) {
// halt($point,$target);
$distance = sqrt(pow(($point['lat'] - $target['lat']), 2) + pow(($point['lon'] - $target['lon']), 2));
if ($distance < $minDistance) {
$minDistance = $distance;
$closestPoint = $point;
}
}
return [$closestPoint,$distance];
}
/**
*
* 计算两点之间的距离
*/
function calculateDistance( $longitude1,$latitude1, $longitude2,$latitude2 ) {
$earthRadius = 6371; // 地球半径,单位为公里
$dLat = deg2rad($latitude2 - $latitude1);
$dLon = deg2rad($longitude2 - $longitude1);
$a = sin($dLat/2) * sin($dLat/2) +
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
sin($dLon/2) * sin($dLon/2);
$c = 2 * asin(sqrt($a));
return $earthRadius * $c*1000;
}
} }

View File

@ -103,8 +103,6 @@ class TaskLogic extends BaseLogic
if ($v['type'] == 31) { if ($v['type'] == 31) {
$data["extend"] = json_encode(['informationg' => ['count' => 5, 'update' => 0]]); $data["extend"] = json_encode(['informationg' => ['count' => 5, 'update' => 0]]);
TaskTemplate::where('id', $v['id'])->inc('information_day_count', 5)->update(); TaskTemplate::where('id', $v['id'])->inc('information_day_count', 5)->update();
} else {
$data["extend"] = json_encode([]);
} }
if ($v['type'] == 32) { if ($v['type'] == 32) {
$data['director_uid'] = $v['company']['user_id']; $data['director_uid'] = $v['company']['user_id'];

View File

@ -47,7 +47,17 @@ class TaskInformationJob
} }
$name = $shang_date_total_price['name']; $name = $shang_date_total_price['name'];
$arr['status'] = $shang_date_total_price['arr']['status']; $arr['status'] = $shang_date_total_price['arr']['status'];
} else { } elseif
//三轮车
($data['template_info']['type'] == 32){
$task = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
if(empty($task)){
$task_car = Task::where('id', $data['task_id'])->field('director_uid,extend')->where('status', 2)->with('director_info')->find();
}
}
else {
//其他类型任务 //其他类型任务
$task_count = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find(); $task_count = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
if (empty($task_count)) { if (empty($task_count)) {