fixed 协助总负责人

This commit is contained in:
chenbo 2023-11-18 19:29:13 +08:00
parent 75d34b1a84
commit 843f41c7cf

View File

@ -981,7 +981,7 @@ class TaskLogic extends BaseLogic
// 任务累计天数第一个周期结算
if ($dayCount == $stageOneDayCount) {
$rate = bcdiv($liaisonManCount, $villageCount, 2);
if (bccomp($rate, 0.5, 2) == 1) {
if (bccomp($rate, 0.5, 2) == 1 || bccomp($rate, 0.5, 2) == 0) {
// 按个数结算
$taskInfo['money'] = bcmul($liaisonManCount, 120, 2);
(new TownShareProfit())->dealTaskSettlementMaster5($taskInfo, $townCompany, $taskSchedulePlan);
@ -1164,24 +1164,38 @@ class TaskLogic extends BaseLogic
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$groupServiceCompanyList = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(street,:responsible_area)", ['company_type' => 18,'responsible_area'=>$townCompany['responsible_area']], true);
// $groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray();
$isDone = 1; // 任务是否完成标记
$isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记
foreach ($groupServiceCompanyList as $groupServiceCompany) {
// 查询小组服务公司是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 3) {
$isTaskSchedule = 1;
// 查询小组服务公司的循环任务有没有全部做完 任意有一个任务没有做完,则判定为该小组服务公司没有完成每日任务,即协助总负责人开展工作任务也认定失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
// 负责人任务类型id列表
$typeIds = [];
$townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id');
foreach ($townMasterTaskTypeList as $item) {
if ($item['value'] == 'town_task_type_master_3') {
$typeIds[] = $item['id'];
}
if ($item['value'] == 'town_task_type_master_4') {
$typeIds[] = $item['id'];
}
if ($item['value'] == 'town_task_type_master_5') {
$typeIds[] = $item['id'];
}
if ($item['value'] == 'town_task_type_master_8') {
$typeIds[] = $item['id'];
}
}
// 查询 镇农科公司负责人是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 4) {
$isTaskSchedule = 1;
// 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
}
}
@ -2229,27 +2243,41 @@ class TaskLogic extends BaseLogic
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$groupServiceCompanyList = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(street,:responsible_area)", ['company_type' => 18,'responsible_area'=>$townCompany['responsible_area']], true);
// $groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray();
$isDone = 1; // 任务是否完成标记
$isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记
foreach ($groupServiceCompanyList as $groupServiceCompany) {
// 查询小组服务公司是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 3) {
$isTaskSchedule = 1;
// 查询小组服务公司的循环任务有没有全部做完 任意有一个任务没有做完,则判定为该小组服务公司没有完成每日任务,即协助总负责人开展工作任务也认定失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
// 负责人任务类型id列表
$typeIds = [];
$townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id');
foreach ($townMasterTaskTypeList as $item) {
if ($item['value'] == 'town_task_type_master_3') {
$typeIds[] = $item['id'];
}
if ($item['value'] == 'town_task_type_master_4') {
$typeIds[] = $item['id'];
}
if ($item['value'] == 'town_task_type_master_5') {
$typeIds[] = $item['id'];
}
if ($item['value'] == 'town_task_type_master_8') {
$typeIds[] = $item['id'];
}
}
// 查询 镇农科公司负责人是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 4) {
$isTaskSchedule = 1;
// 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
}
}
// 下属小组服务公司有任务安排,也完成了任务
if ($isDone === 1 && $isTaskSchedule === 1) {
// 做任务结算,分润