更新
This commit is contained in:
parent
e2b585f3c5
commit
fc9c0d52d3
app
@ -9,6 +9,7 @@ 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
|
||||
{
|
||||
@ -53,6 +54,26 @@ halt(2);
|
||||
|
||||
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'));
|
||||
// $tiem_end=$time+86399;
|
||||
@ -64,94 +85,6 @@ halt(2);
|
||||
TaskLogic::CronAdd($v);
|
||||
$company_id=$v['company_id'];
|
||||
}
|
||||
halt(1);
|
||||
$points = [
|
||||
[
|
||||
"lat"=> 28.914962,
|
||||
"lon"=>105.442355
|
||||
],
|
||||
|
||||
[
|
||||
"lat"=> 28.915456,
|
||||
"lon"=> 105.443891
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917516,
|
||||
"lon"=> 105.443371
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917536,
|
||||
"lon"=> 105.443415
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917001,
|
||||
"lon"=> 105.442421
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917103,
|
||||
"lon"=> 105.442291
|
||||
],
|
||||
[
|
||||
"lat"=> 28.916658,
|
||||
"lon"=> 105.442897
|
||||
],
|
||||
[
|
||||
"lat"=> 28.916428,
|
||||
"lon"=> 105.44278
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917073,
|
||||
"lon"=> 105.443507
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917073,
|
||||
"lon"=> 105.443522
|
||||
],
|
||||
[
|
||||
"lat"=> 28.916796,
|
||||
"lon"=> 105.443466
|
||||
],
|
||||
[
|
||||
"lat"=> 28.916665,
|
||||
"lon"=> 105.443357
|
||||
],
|
||||
[
|
||||
"lat"=> 28.916674,
|
||||
"lon"=> 105.442294
|
||||
],
|
||||
[
|
||||
"lat"=> 28.916698,
|
||||
"lon"=> 105.442268
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917279,
|
||||
"lon"=> 105.443006
|
||||
],
|
||||
[
|
||||
"lat"=> 28.917234,
|
||||
"lon"=> 105.442979
|
||||
]
|
||||
];
|
||||
$target =[
|
||||
"lat"=> 28.917378,
|
||||
"lon"=> 105.443005
|
||||
];
|
||||
|
||||
$closestPoint = $this->getClosestPoint($points, $target);
|
||||
halt($closestPoint);
|
||||
// $time=strtotime(date('Y-m-d',strtotime('+1 day')));
|
||||
$time=strtotime(date('Y-m-d'));
|
||||
$tiem_end=$time+86399;
|
||||
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling','company'])->select()->toArray();
|
||||
$company_id=0;
|
||||
foreach($all as $k=>$v){
|
||||
TaskLogic::CronAdd($v);
|
||||
$company_id=$v['company_id'];
|
||||
}
|
||||
if($company_id!=0){
|
||||
Company::where('id',$company_id)->inc('day_count')->update();
|
||||
}
|
||||
halt(TaskLogic::getError());
|
||||
}
|
||||
|
||||
function getClosestPoint($points, $target) {
|
||||
@ -169,4 +102,18 @@ halt(1);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -68,7 +68,11 @@ class RemoteController extends BaseApiController
|
||||
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
||||
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
||||
//
|
||||
$user_count_two = 5 * $company['day_count'];
|
||||
if($company['day_count']==0){
|
||||
$user_count_two = 5 * 1;
|
||||
}else{
|
||||
$user_count_two = 5 * $company['day_count'];
|
||||
}
|
||||
if ($user_count_two > $user_count) {
|
||||
$user_count_money = 58 * $user_count;
|
||||
} else {
|
||||
|
@ -23,41 +23,42 @@ class TaskInformationJob
|
||||
// if ($job->attempts() > 1) {
|
||||
// //通过这个方法可以检查这个任务已经重试了几次了
|
||||
// }
|
||||
$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(); // 可能要判断预存金是否满足
|
||||
$arr['status'] = 0;
|
||||
//信息更新
|
||||
if ($data['template_info']['type'] == 31) {
|
||||
if ($data['template_info']['information_count'] < $data['template_info']['information_day_count']) {
|
||||
Log::info('任务结算失败,信息更新未达到要求:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = '小组队长';
|
||||
$arr['status'] = 1;
|
||||
} elseif
|
||||
//交易金额
|
||||
($data['template_info']['type'] == 33) {
|
||||
$shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company);
|
||||
if ($shang_date_total_price == false) {
|
||||
Log::info('任务结算失败,交易金额未达到要求:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = $shang_date_total_price['name'];
|
||||
$arr['status'] = $shang_date_total_price['arr']['status'];
|
||||
} else {
|
||||
//其他类型任务
|
||||
$task_count = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
|
||||
if (empty($task_count)) {
|
||||
Log::info('列105 任务 '.$data['template_info']['title'].'结算失败,任务为空:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = $task_count['director_info']['nickname'];
|
||||
$arr['status'] = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$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(); // 可能要判断预存金是否满足
|
||||
$arr['status'] = 0;
|
||||
//信息更新
|
||||
if ($data['template_info']['type'] == 31) {
|
||||
if ($data['template_info']['information_count'] < $data['template_info']['information_day_count']) {
|
||||
Log::info('任务结算失败,信息更新未达到要求:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = '小组队长';
|
||||
$arr['status'] = 1;
|
||||
} elseif
|
||||
//交易金额
|
||||
($data['template_info']['type'] == 33) {
|
||||
$shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company);
|
||||
if ($shang_date_total_price == false) {
|
||||
Log::info('任务结算失败,交易金额未达到要求:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = $shang_date_total_price['name'];
|
||||
$arr['status'] = $shang_date_total_price['arr']['status'];
|
||||
} else {
|
||||
//其他类型任务
|
||||
$task_count = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
|
||||
if (empty($task_count)) {
|
||||
Log::info('列105 任务 ' . $data['template_info']['title'] . '结算失败,任务为空:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = $task_count['director_info']['nickname'];
|
||||
$arr['status'] = 1;
|
||||
}
|
||||
|
||||
$arr['money'] = $data['template_info']['money'];
|
||||
$arr['company_id'] = $data['scheduling']['company_id'];
|
||||
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成人:' . $name . ',的任务结算';
|
||||
@ -66,13 +67,13 @@ class TaskInformationJob
|
||||
$arr['sn'] = $data['sn'];
|
||||
$arr['id'] = $data['id'];
|
||||
} catch (\Exception $e) {
|
||||
Log::error('列122 任务结算失败:'.$data['template_info']['title'] . $e->getMessage() . json_encode($data));
|
||||
Log::error('列122 任务结算失败:' . $data['template_info']['title'] . $e->getMessage() . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
if($arr['status']==1){
|
||||
if ($arr['status'] == 1) {
|
||||
(new ShareProfit())->first($arr, $company);
|
||||
}else{
|
||||
Log::error('任务结算失败:'.$data['template_info']['title'].'未完成' . json_encode($data));
|
||||
} else {
|
||||
Log::error('任务结算失败:' . $data['template_info']['title'] . '未完成' . json_encode($data));
|
||||
}
|
||||
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
||||
$job->delete();
|
||||
|
Loading…
x
Reference in New Issue
Block a user