镇管理公司任务-任务6,任务7结算
This commit is contained in:
parent
31e438117b
commit
5881c0d584
@ -21,6 +21,8 @@ class TownShareProfit
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
|
||||
Db::commit();
|
||||
@ -40,6 +42,8 @@ class TownShareProfit
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
|
||||
if ($step == 2 && $contractCount >= 15) {
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
|
||||
}
|
||||
@ -58,6 +62,8 @@ class TownShareProfit
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
|
||||
Db::commit();
|
||||
@ -105,6 +111,41 @@ class TownShareProfit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function townTaskType6($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function townTaskType7($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 分润
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@ namespace app\common\logic\task;
|
||||
|
||||
|
||||
use app\common\logic\finance\TownShareProfit;
|
||||
use app\common\model\CompanyComplaintFeedback;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\task\Task;
|
||||
@ -749,7 +750,7 @@ class TaskLogic extends BaseLogic
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
$townTask = Task::where('id', $taskSchedulePlan['task_id'])->find();
|
||||
$groupServiceCompanyList = Company::where(['street' => $townCompany['street']])->select()->toArray();
|
||||
$groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type'=> 18])->select()->toArray();
|
||||
$townTransactionPool = $taskTemplateInfo['transaction_pool']; // 镇交易池
|
||||
$townTotalTradeAmount = 0; // 镇下属小组服务公司 每日实际总交易额
|
||||
$targetAmount = 0; // 镇下属小组服务公司每日 目标总交易额
|
||||
@ -773,16 +774,97 @@ class TaskLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 督促小组服务团队入股村联络员所成立的公司任务 单次任务
|
||||
* 当前任务进行天数 < 第一+第二阶段天数 只刷新任务时间
|
||||
* 当前任务进行天数 = 第一+第二阶段天数 判定任务是否完成 结算 分润
|
||||
*/
|
||||
private static function dealTownTask6($taskSchedulePlan)
|
||||
{
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$taskScheduleInfo = $taskSchedulePlan['scheduling'];
|
||||
$taskDayCount = $taskTemplateInfo['day_count']; // 任务累计进行天数
|
||||
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
|
||||
$stageDayOneAccumulative = $taskTemplateInfo['stage_day_one']; // 第一阶段累计天数
|
||||
$stageDayTwoAccumulative = intval(bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two'])); // 第二阶段累计天数 第一+第二
|
||||
$townCompany = Company::where('id', $taskTemplateInfo['compay_id'])->find(); // 镇管理公司
|
||||
$villageCompanyList = Company::where(['street' => $townCompany['street'], 'company_type'=> 17])->select()->toArray(); // 村管理公司
|
||||
|
||||
// 当前任务进行天数 < 第一+第二阶段天数 只刷新任务时间
|
||||
if ($taskDayCount < $stageDayOneAccumulative) {
|
||||
self::flushTaskTime($taskSchedulePlan);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 当前任务进行天数 = 第一+第二阶段天数 判定任务是否完成 结算 分润
|
||||
if($taskDayCount == $stageDayTwoAccumulative) {
|
||||
// 小组服务公司总数
|
||||
$groupServiceCompanyCount = Company::where(['street' => $townCompany['street'], 'company_type'=> 18])->count();
|
||||
|
||||
// 小组服务完成股金上交数
|
||||
$sharecapitalPaidCount= Db::name('company_sharecapital_change_log')->where(['parent_company_id'=>$villageCompanyList['id']])->count();
|
||||
|
||||
$rate = bcdiv($sharecapitalPaidCount, $groupServiceCompanyCount, 2);
|
||||
|
||||
// 小于50% 未完成 关闭任务
|
||||
if (bccomp($rate, 0.5, 2) == -1) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
} else {
|
||||
// 已完成 计算结算金额
|
||||
$totalMoney = bcadd(bcmul($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['money'], 2) , bcmul($taskTemplateInfo['stage_day_two'], $taskTemplateInfo['money_two'], 2), 2);
|
||||
// =50% - %59.9 x40%
|
||||
if (bccomp($rate, 0.5, 2) == 0 || (bccomp($rate, 0.5, 2) == 1 && bccomp($rate, 0.599, 2) == -1)) {
|
||||
$task['money'] = bcmul($totalMoney, 0.4, 2);
|
||||
}
|
||||
// =60% - %69.9 x50%
|
||||
if (bccomp($rate, 0.6, 2) == 0 || (bccomp($rate, 0.6, 2) == 1 && bccomp($rate, 0.699, 2) == -1)) {
|
||||
$task['money'] = bcmul($totalMoney, 0.5, 2);
|
||||
}
|
||||
|
||||
// =70% - %79.9 x60%
|
||||
if (bccomp($rate, 0.7, 2) == 0 || (bccomp($rate, 0.7, 2) == 1 && bccomp($rate, 0.799, 2) == -1)) {
|
||||
$task['money'] = bcmul($totalMoney, 0.6, 2);
|
||||
}
|
||||
|
||||
// =80% - %89.9 x70%
|
||||
if (bccomp($rate, 0.8, 2) == 0 || (bccomp($rate, 0.8, 2) == 1 && bccomp($rate, 0.899, 2) == -1)) {
|
||||
$task['money'] = bcmul($totalMoney, 0.7, 2);
|
||||
}
|
||||
// >=90% x100%
|
||||
if (bccomp($rate, 0.9, 2) == 0 || bccomp($rate, 0.9, 2) == 1) {
|
||||
$task['money'] = $totalMoney;
|
||||
}
|
||||
// 分润
|
||||
(new TownShareProfit())->townTaskType6($task, $townCompany, $taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 安全任务结算
|
||||
private static function dealTownTask7($taskSchedulePlan)
|
||||
{
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$taskScheduleInfo = $taskSchedulePlan['scheduling'];
|
||||
|
||||
$townCompany = Company::where('id', $taskTemplateInfo['compay_id'])->find(); // 镇管理公司
|
||||
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
|
||||
|
||||
// 片区下公司有任一投诉都判定为未完成
|
||||
$isDone = 1;
|
||||
$companyList = Company::where('street', $townCompany['street'])->select()->toArray();
|
||||
foreach ($companyList as $company) {
|
||||
$complain = CompanyComplaintFeedback::where(['company_id', $company['id']])->whereDay('create_time', 'today')->find();
|
||||
if (!empty($complain)) {
|
||||
$isDone = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 完成任务 结算 分润
|
||||
if ($isDone === 1) {
|
||||
(new TownShareProfit())->townTaskType7($task, $townCompany, $taskSchedulePlan);
|
||||
} else {
|
||||
// 关闭任务
|
||||
(new Task())->closeTask($task['id']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user