更新
This commit is contained in:
parent
d77fbaf6fa
commit
8d3eb6d833
@ -12,16 +12,15 @@ class RemoteController extends BaseApiController
|
|||||||
|
|
||||||
public array $notNeedLogin = ['index'];
|
public array $notNeedLogin = ['index'];
|
||||||
|
|
||||||
public function shang_date_total_price($company,$arr=[],$template_id=0)
|
public function shang_date_total_price($company, $arr = [], $template_id = 0)
|
||||||
{
|
{
|
||||||
$start_time = date('Y-m-d');
|
$start_time = date('Y-m-d');
|
||||||
$time=strtotime($start_time)+86399;
|
$time = strtotime($start_time) + 86399;
|
||||||
$end_time=date('Y-m-d H:i:s',$time);
|
$end_time = date('Y-m-d H:i:s', $time);
|
||||||
|
|
||||||
if(isset($arr['start_time']) && $arr['end_time']){
|
if (isset($arr['start_time']) && $arr['end_time']) {
|
||||||
$start_time = $arr['start_time'];
|
$start_time = $arr['start_time'];
|
||||||
$end_time = $arr['end_time'];
|
$end_time = $arr['end_time'];
|
||||||
|
|
||||||
}
|
}
|
||||||
$parmas = [
|
$parmas = [
|
||||||
"start_date" => $start_time,
|
"start_date" => $start_time,
|
||||||
@ -55,11 +54,11 @@ class RemoteController extends BaseApiController
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log::error('任务结算失败,公司类型错误:' . $company['company_type']);
|
Log::error('任务结算失败,公司类型错误:' . $company['company_type']);
|
||||||
Log::error('片区交易错误:'.$company);
|
Log::error('片区交易错误:' . $company);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$res = HttpClient::create()->request('GET', env('url.shop_prefix').'/api/order/statistics', [
|
$res = HttpClient::create()->request('GET', env('url.shop_prefix') . '/api/order/statistics', [
|
||||||
'query' => $parmas,
|
'query' => $parmas,
|
||||||
]);
|
]);
|
||||||
$json = json_decode($res->getContent(), true);
|
$json = json_decode($res->getContent(), true);
|
||||||
@ -71,11 +70,11 @@ class RemoteController extends BaseApiController
|
|||||||
$arr['total_price'] = $json['data']['total_price'];
|
$arr['total_price'] = $json['data']['total_price'];
|
||||||
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
||||||
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
||||||
$day_count=TaskTemplate::where('id',$template_id)->value('day_count');
|
$day_count = TaskTemplate::where('id', $template_id)->value('day_count');
|
||||||
//
|
//
|
||||||
if($day_count==0){
|
if ($day_count == 0) {
|
||||||
$user_count_two = 5 * 1;
|
$user_count_two = 5 * 1;
|
||||||
}else{
|
} else {
|
||||||
$user_count_two = 5 * $day_count;
|
$user_count_two = 5 * $day_count;
|
||||||
}
|
}
|
||||||
if ($user_count_two > $user_count) {
|
if ($user_count_two > $user_count) {
|
||||||
@ -98,20 +97,15 @@ class RemoteController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shang_date_list($company,$is_day,$querys){
|
public function shang_date_list($company, $querys)
|
||||||
if($is_day==1){
|
{
|
||||||
$start_time = date('Y-m-d');
|
$start_time = date('Y-m-d');
|
||||||
$time=strtotime($start_time)+86399;
|
$time = strtotime($start_time) + 86399;
|
||||||
$end_time=date('Y-m-d H:i:s',$time);
|
$end_time = date('Y-m-d H:i:s', $time);
|
||||||
}else{
|
|
||||||
$start_time = date('Y-m-d',strtotime('-1 day', time()));
|
if (isset($querys['start_time']) && isset($querys['end_time'])) {
|
||||||
$time=strtotime($start_time)+86399;
|
|
||||||
$end_time=date('Y-m-d H:i:s',$time);
|
|
||||||
}
|
|
||||||
if(isset($querys['start_time']) && isset($querys['end_time'])){
|
|
||||||
$start_time = $querys['start_time'];
|
$start_time = $querys['start_time'];
|
||||||
$end_time = $querys['end_time'];
|
$end_time = $querys['end_time'];
|
||||||
|
|
||||||
}
|
}
|
||||||
$parmas = [
|
$parmas = [
|
||||||
"start_date" => $start_time,
|
"start_date" => $start_time,
|
||||||
@ -147,54 +141,54 @@ class RemoteController extends BaseApiController
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($querys['page'])){
|
if (isset($querys['page'])) {
|
||||||
$parmas['page']=$querys['page'];
|
$parmas['page'] = $querys['page'];
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try {
|
||||||
$list = HttpClient::create()->request('GET', env('url.shop_prefix').'/api/region/order', [
|
$list = HttpClient::create()->request('GET', env('url.shop_prefix') . '/api/region/order', [
|
||||||
'query' => $parmas,
|
'query' => $parmas,
|
||||||
]);
|
]);
|
||||||
$json_list = json_decode($list->getContent(), true);
|
$json_list = json_decode($list->getContent(), true);
|
||||||
|
|
||||||
$data=[];
|
$data = [];
|
||||||
if($json_list['status'] == 200){
|
if ($json_list['status'] == 200) {
|
||||||
$data=$json_list['data']['list'];
|
$data = $json_list['data']['list'];
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}catch(\Exception $e){
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 获取坐标的距离
|
* 获取坐标的距离
|
||||||
*/
|
*/
|
||||||
public function coordinate($parmas,$longitude1,$latitude1){
|
public function coordinate($parmas, $longitude1, $latitude1)
|
||||||
$res = HttpClient::create()->request('GET', env('project.logistic_domain').'/api/getCarHistory', [
|
{
|
||||||
|
$res = HttpClient::create()->request('GET', env('project.logistic_domain') . '/api/getCarHistory', [
|
||||||
'query' => $parmas,
|
'query' => $parmas,
|
||||||
]);
|
]);
|
||||||
$json=json_decode($res->getContent(),true);
|
$json = json_decode($res->getContent(), true);
|
||||||
$points=$json['data'];
|
$points = $json['data'];
|
||||||
if(empty($points)){
|
if (empty($points)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$target =[
|
$target = [
|
||||||
"lat"=> $latitude1,
|
"lat" => $latitude1,
|
||||||
"lon"=> $longitude1
|
"lon" => $longitude1
|
||||||
];
|
];
|
||||||
$closestPoint = $this->getClosestPoint($points, $target);
|
$closestPoint = $this->getClosestPoint($points, $target);
|
||||||
return $this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat']);
|
return $this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 计算两点之间的距离
|
* 计算两点之间的距离
|
||||||
*/
|
*/
|
||||||
function getClosestPoint($points, $target) {
|
function getClosestPoint($points, $target)
|
||||||
|
{
|
||||||
$minDistance = PHP_INT_MAX;
|
$minDistance = PHP_INT_MAX;
|
||||||
$closestPoint = null;
|
$closestPoint = null;
|
||||||
foreach ($points as $point) {
|
foreach ($points as $point) {
|
||||||
@ -203,29 +197,30 @@ class RemoteController extends BaseApiController
|
|||||||
if ($distance < $minDistance) {
|
if ($distance < $minDistance) {
|
||||||
$minDistance = $distance;
|
$minDistance = $distance;
|
||||||
$closestPoint = $point;
|
$closestPoint = $point;
|
||||||
}else{
|
} else {
|
||||||
$distance=0;
|
$distance = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$closestPoint,$distance];
|
return [$closestPoint, $distance];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 计算两点之间的距离
|
* 计算两点之间的距离
|
||||||
*/
|
*/
|
||||||
function calculateDistance( $longitude1,$latitude1, $longitude2,$latitude2 ) {
|
function calculateDistance($longitude1, $latitude1, $longitude2, $latitude2)
|
||||||
|
{
|
||||||
$earthRadius = 6371; // 地球半径,单位为公里
|
$earthRadius = 6371; // 地球半径,单位为公里
|
||||||
|
|
||||||
$dLat = deg2rad($latitude2 - $latitude1);
|
$dLat = deg2rad($latitude2 - $latitude1);
|
||||||
$dLon = deg2rad($longitude2 - $longitude1);
|
$dLon = deg2rad($longitude2 - $longitude1);
|
||||||
|
|
||||||
$a = sin($dLat/2) * sin($dLat/2) +
|
$a = sin($dLat / 2) * sin($dLat / 2) +
|
||||||
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
|
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
|
||||||
sin($dLon/2) * sin($dLon/2);
|
sin($dLon / 2) * sin($dLon / 2);
|
||||||
$c = 2 * asin(sqrt($a));
|
$c = 2 * asin(sqrt($a));
|
||||||
|
|
||||||
return $earthRadius * $c*100;
|
return $earthRadius * $c * 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,12 @@ class TaskController extends BaseApiController
|
|||||||
if ($find != false) {
|
if ($find != false) {
|
||||||
if($time<time()){
|
if($time<time()){
|
||||||
$transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool');
|
$transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool');
|
||||||
if($transaction_pool==0){
|
|
||||||
$find['transaction']['arr']['transaction_pool']=$find['transaction']['arr']['total_price'];
|
|
||||||
}else{
|
|
||||||
$find['transaction']['arr']['transaction_pool']=bcadd($find['transaction']['arr']['total_price'],$transaction_pool,2);
|
|
||||||
}
|
|
||||||
$res[$k]['extend']['transaction'] = $find;
|
$res[$k]['extend']['transaction'] = $find;
|
||||||
|
if($transaction_pool==0){
|
||||||
|
$res[$k]['extend']['transaction']['arr']['transaction_pool']=$find['arr']['total_price'];
|
||||||
|
}else{
|
||||||
|
$res[$k]['extend']['transaction']['arr']['transaction_pool']=bcadd($res[$k]['extend']['transaction']['arr']['total_price'],$transaction_pool,2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Task::where('id',$item['id'])->update(['extend'=>json_encode(['transaction'=>$find],true)]);
|
// Task::where('id',$item['id'])->update(['extend'=>json_encode(['transaction'=>$find],true)]);
|
||||||
} else {
|
} else {
|
||||||
@ -93,13 +93,15 @@ class TaskController extends BaseApiController
|
|||||||
// $list = App(RemoteController::class)->shang_date_list($company, 1, $parmas);
|
// $list = App(RemoteController::class)->shang_date_list($company, 1, $parmas);
|
||||||
$parmas['start_time']=date('Y-m-d',$task['start_time']);
|
$parmas['start_time']=date('Y-m-d',$task['start_time']);
|
||||||
$parmas['end_time']=$task['end_time'].' 23:59:59';
|
$parmas['end_time']=$task['end_time'].' 23:59:59';
|
||||||
$list = App(RemoteController::class)->shang_date_list($company, 1, $parmas);
|
$list = App(RemoteController::class)->shang_date_list($company, $parmas);
|
||||||
|
$shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company,$parmas,$task['template_id']);
|
||||||
|
|
||||||
if ($task != false) {
|
if ($task != false) {
|
||||||
$find['list'] = $list;
|
$find['list'] = $list;
|
||||||
if($transaction_pool==0){
|
if($transaction_pool==0){
|
||||||
$task['extend']['transaction']['arr']['transaction_pool']=$task['extend']['transaction']['arr']['total_price'];
|
$task['extend']['transaction']['arr']['transaction_pool']=$shang_date_total_price['arr']['total_price'];
|
||||||
}else{
|
}else{
|
||||||
$task['extend']['transaction']['arr']['transaction_pool']=bcadd($task['extend']['transaction']['arr']['total_price'],$transaction_pool,2);
|
$task['extend']['transaction']['arr']['transaction_pool']=bcadd($shang_date_total_price['arr']['total_price'],$transaction_pool,2);
|
||||||
}
|
}
|
||||||
$find['extend']=$task['extend'];
|
$find['extend']=$task['extend'];
|
||||||
return $this->success('ok', $find);
|
return $this->success('ok', $find);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user