TaskSystem/app/api/controller/CeshiController.php

122 lines
4.9 KiB
PHP
Raw Normal View History

2023-08-10 17:10:12 +08:00
<?php
namespace app\api\controller;
use app\common\logic\task\TaskLogic;
2023-08-14 17:44:55 +08:00
use app\common\model\Company;
2023-08-30 14:28:18 +08:00
use app\common\model\company\CompanyAccountLog;
2023-08-10 17:10:12 +08:00
use app\common\model\task\Task;
2023-08-28 09:31:13 +08:00
use app\common\model\task_scheduling\TaskScheduling;
2023-08-10 17:10:12 +08:00
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
2023-08-18 16:32:41 +08:00
use app\common\model\task_template\TaskTemplate;
2023-08-30 14:28:18 +08:00
use app\common\model\user\User as UserModel;
use app\common\model\user\UserAccountLog;
2023-08-14 17:44:55 +08:00
use think\facade\Log;
2023-08-10 17:10:12 +08:00
class CeshiController extends BaseApiController
{
2023-08-22 14:32:57 +08:00
public array $notNeedLogin = ['index','ceshi','ceshi1','ceshi2'];
2023-08-10 17:10:12 +08:00
2023-08-24 13:42:45 +08:00
/**
* 任务结算
*/
2023-08-10 17:10:12 +08:00
public function index()
{
2023-08-30 14:28:18 +08:00
$user_ids = UserModel::where('company_id', 175)->where('is_captain', 1)->field('id,nickname,brigade')->select();
$shareholder_user = UserModel::where('id', 322)->field('id,nickname,brigade')->find();
$money=bcdiv(6000,count($user_ids),2);
$left_amount=0;
2023-08-30 14:16:11 +08:00
foreach ($user_ids as $kkk => $vvv) {
2023-08-30 14:28:18 +08:00
$left_amount+=bcadd(1000,$money,2);
2023-08-30 14:16:11 +08:00
$company_log = [
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
2023-08-30 14:28:18 +08:00
'company_id'=>175,
2023-08-30 14:16:11 +08:00
'change_object' => CompanyAccountLog::SHAREHOLDER,//变动对象
'change_type' => CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY,//变动类型
'action' => CompanyAccountLog::INC,//1-增加 2-减少
2023-08-30 14:28:18 +08:00
'left_amount' =>$left_amount,//变动后数量
2023-08-30 14:16:11 +08:00
'change_amount' => $money,//变动数量
2023-08-30 14:28:18 +08:00
'remark' =>$shareholder_user['nickname'].'完成了'.$vvv['brigade'].'队的股金:'.$money.'元',
2023-08-30 14:16:11 +08:00
'status'=>1,
];
CompanyAccountLog::create($company_log);
2023-08-15 14:38:20 +08:00
}
2023-08-10 17:10:12 +08:00
}
2023-08-24 13:42:45 +08:00
/**
* 任务刷新
*/
2023-08-10 17:10:12 +08:00
public function ceshi(){
2023-08-18 16:32:41 +08:00
2023-08-10 17:10:12 +08:00
$time=strtotime(date('Y-m-d'));
2023-08-21 15:14:39 +08:00
// $time=strtotime(date('Y-m-d'));
2023-08-24 13:42:45 +08:00
// $tiem_end=$time+86399;where('cron_time','<',$time)->
2023-08-29 16:40:03 +08:00
$plan_all=TaskScheduling::where('id',99)->with('company_info')->select()->toArray();
2023-08-28 09:31:13 +08:00
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]);
}
}
2023-08-24 14:29:54 +08:00
$company_id=[];
2023-08-28 09:31:13 +08:00
foreach($plan_all as $k=>$v){
foreach($v['template'] as $kk=>$vv){
TaskLogic::CronAdd($vv,$v);
}
2023-08-24 14:29:54 +08:00
$company_id[]=$v['company_id'];
2023-08-14 17:44:55 +08:00
}
2023-08-28 09:31:13 +08:00
Company::where('id','in',$company_id)->inc('day_count')->update();
2023-08-10 17:10:12 +08:00
}
2023-08-18 10:12:56 +08:00
2023-08-28 09:31:13 +08:00
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;
}
2023-08-22 14:54:34 +08:00
//三轮车判断
2023-08-22 09:58:04 +08:00
public function ceshi1(){
$params=[
'car_id'=>3,
'start_time'=>'2023-08-18',
'end_time'=>'2023-08-18 23:59:59'
];
2023-08-22 10:36:56 +08:00
$task=Task::where('id',487)->select()->toArray();
2023-08-22 09:58:04 +08:00
foreach($task as $k=>$v){
2023-08-22 10:21:13 +08:00
if(isset($v['extend']['terminus']['lnglat'])&& isset($v['extend']['transfer']['lnglat'])){
2023-08-22 09:58:04 +08:00
$arr=$v['extend']['terminus']['lnglat'];
2023-08-22 10:36:56 +08:00
$a=app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
2023-08-22 10:21:13 +08:00
$arr_two=$v['extend']['transfer']['lnglat'];
2023-08-22 10:36:56 +08:00
$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]);
}
2023-08-22 09:58:04 +08:00
}
2023-08-22 10:21:13 +08:00
2023-08-18 10:12:56 +08:00
}
}
2023-08-21 15:14:39 +08:00
2023-08-28 09:31:13 +08:00
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);
}
2023-08-22 14:32:57 +08:00
2023-08-10 17:10:12 +08:00
}