update 村联络员-督促小组服务团队入股任,镇农科服务部长-督促小组服务团队入股村管理公司任务,村联络员任务-入股甲方公司.改为手动审核,线下转账

This commit is contained in:
chenbo 2023-11-17 10:52:12 +08:00
parent a822dc5eae
commit 1e97e3f536
4 changed files with 222 additions and 56 deletions

View File

@ -214,14 +214,22 @@ class ApproveController extends BaseAdminController
$task->save();
}
// 小组服务公司股金上交
if ($approve->type == Approve::APPROVE_TYPE_10) {
// 上交股金的公司
// 小组服务公司股金上交 小组服务团队-入股任务 村联络员-督促小组服务团队入股任务 镇农科服务部长-督促小组服务团队入股村管理公司任务
if ($approve->type == Approve::APPROVE_TYPE_10 || $approve->type == Approve::APPROVE_TYPE_11 || $approve->type == Approve::APPROVE_TYPE_13) {
// 小组服务公司
$subordinateCompany = Company::where(['id'=>$approve->department_id])->find();
// 接收股金的公司
// 公司
$parentCompany = Company::where(['village'=>$subordinateCompany['village'], 'company_type'=>17])->find();
}
// 村管理公司股金上交 村联络员任务-入股甲方公司
if ($approve->type == Approve::APPROVE_TYPE_12) {
// 村公司
$subordinateCompany = Company::where(['id'=>$approve->department_id])->find();
// 镇农科公司 负责区域包含有村公司的street码
$parentCompany = Db::query("select id from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$subordinateCompany['street']], true)[0];
}
$amount = $approve->amount; // 上交股金金额
$subordinateCompany->shareholder_money = $amount;
@ -235,7 +243,7 @@ class ApproveController extends BaseAdminController
$approve->remark = $params['remark'];
$approve->save();
// 任务结算
// 小组服务团队-入股任务结算
if ($approve->type == Approve::APPROVE_TYPE_10) {
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
->withJoin(['scheduling'], 'left')
@ -247,6 +255,39 @@ class ApproveController extends BaseAdminController
$taskInfo = $task->toArray();
$this->taskSettlement($taskInfo, $subordinateCompany, $taskSchedulingPaln);
}
// 村联络员-督促小组服务团队入股
if ($approve->type == Approve::APPROVE_TYPE_11) {
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 17)
->where('is_pay',0)
->with(['template_info'])
->select()
->toArray()[0];
TaskLogic::dealVillageTask4($taskSchedulingPaln, $approve);
}
// 村联络员-入股甲方公司
if ($approve->type == Approve::APPROVE_TYPE_12) {
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 17)
->where('is_pay',0)
->with(['template_info'])
->select()
->toArray()[0];
TaskLogic::dealVillageTask5($taskSchedulingPaln, $approve);
}
// 镇农科服务部长-督促小组服务团队入股村管理公司任务
if ($approve->type == Approve::APPROVE_TYPE_13) {
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 41)
->where('is_pay',0)
->with(['template_info'])
->select()
->toArray()[0];
TaskLogic::dealTownTask6($taskSchedulingPaln, $approve);
}
Db::commit();
return $this->success('成功');
}

View File

@ -720,6 +720,8 @@ class TaskController extends BaseApiController
}
}
// 小组服务团队-入股任务提交
public function commit_service_group_task()
{
try {
@ -757,4 +759,121 @@ class TaskController extends BaseApiController
return $this->fail($e->getMessage());
}
}
// 村联络员-督促小组服务团队入股任务提交
public function commit_village_task_4()
{
try {
$parmas = $this->request->param(); // id annex amount
$task = TaskLogic::detail($parmas);
if (empty($task)) {
$this->fail('任务不存在');
}
$extend = $task['extend'];
$extend['is_commit'] = 1;
$extend['annex'] = $parmas['annex'];
$extend['file_type'] = $parmas['file_type'];
$extend['amount'] = $parmas['amount'];
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time(), 'director_uid' => $this->userId]); // director_uid 指派人
// 创建审批任务
$approveModel = new Approve();
$approveModel->type = Approve::APPROVE_TYPE_11;
$approveModel->flow_id = 1;
$approveModel->name = $task['title'];
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
$approveModel->user_id = $this->userId; // 前台发起人用户id
$approveModel->task_id = $task['id']; // 任务id
$approveModel->department_id = $this->userInfo['company_id']; // 公司id
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
$approveModel->other_type = 6;
$approveModel->amount = $parmas['amount']; // 入股金额
$approveModel->extend = json_encode($extend);
$approveModel->create_time = time();
$approveModel->update_time = time();
$re = $approveModel->save();
return $this->success('ok', []);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
// 村联络员-入股甲方公司任务提交
public function commit_village_task_5()
{
try {
$parmas = $this->request->param(); // id annex amount
$task = TaskLogic::detail($parmas);
if (empty($task)) {
$this->fail('任务不存在');
}
$extend = $task['extend'];
$extend['is_commit'] = 1;
$extend['annex'] = $parmas['annex'];
$extend['file_type'] = $parmas['file_type'];
$extend['amount'] = $parmas['amount'];
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time(), 'director_uid' => $this->userId]); // director_uid 指派人
// 创建审批任务
$approveModel = new Approve();
$approveModel->type = Approve::APPROVE_TYPE_12;
$approveModel->flow_id = 1;
$approveModel->name = $task['title'];
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
$approveModel->user_id = $this->userId; // 前台发起人用户id
$approveModel->task_id = $task['id']; // 任务id
$approveModel->department_id = $this->userInfo['company_id']; // 公司id
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
$approveModel->other_type = 6;
$approveModel->amount = $parmas['amount']; // 入股金额
$approveModel->extend = json_encode($extend);
$approveModel->create_time = time();
$approveModel->update_time = time();
$re = $approveModel->save();
return $this->success('ok', []);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
// 服务部长-督促小组服务团队入股村管理公司
public function commit_town_service_manager_task_6()
{
try {
$parmas = $this->request->param(); // id annex amount
$task = TaskLogic::detail($parmas);
if (empty($task)) {
$this->fail('任务不存在');
}
$extend = $task['extend'];
$extend['is_commit'] = 1;
$extend['annex'] = $parmas['annex'];
$extend['file_type'] = $parmas['file_type'];
$extend['amount'] = $parmas['amount'];
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time(), 'director_uid' => $this->userId]); // director_uid 指派人
// 创建审批任务
$approveModel = new Approve();
$approveModel->type = Approve::APPROVE_TYPE_13;
$approveModel->flow_id = 1;
$approveModel->name = $task['title'];
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
$approveModel->user_id = $this->userId; // 前台发起人用户id
$approveModel->task_id = $task['id']; // 任务id
$approveModel->department_id = $this->userInfo['company_id']; // 公司id
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
$approveModel->other_type = 6;
$approveModel->amount = $parmas['amount']; // 入股金额
$approveModel->extend = json_encode($extend);
$approveModel->create_time = time();
$approveModel->update_time = time();
$re = $approveModel->save();
return $this->success('ok', []);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
}

View File

@ -2205,7 +2205,19 @@ class TaskLogic extends BaseLogic
break;
case 'town_task_type_6':
// 督促小组服务团队入股村联络员所成立的公司任务
self::dealTownTask6($taskSchedulePlan);
// 后台手动审核 只判断任务是否超时
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$taskDayCount = $taskTemplateInfo['day_count']; // 任务累计进行天数
$stageDayTwoAccumulative = intval(bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two'])); // 第二阶段累计天数 第一+第二
// 当前任务进行天数 <= 第一+第二阶段天数 只刷新任务时间
if ($taskDayCount <= $stageDayTwoAccumulative) {
self::flushTaskTime($taskSchedulePlan);
return true;
} else {
(new Task())->closeTask($taskSchedulePlan['task_id']);
}
// self::dealTownTask6($taskSchedulePlan);
break;
case 'town_task_type_7':
// 安全工作任务
@ -2555,7 +2567,7 @@ class TaskLogic extends BaseLogic
* 当前任务进行天数 < 第一+第二阶段天数 只刷新任务时间
* 当前任务进行天数 = 第一+第二阶段天数 判定任务是否完成 结算 分润
*/
private static function dealTownTask6($taskSchedulePlan)
public static function dealTownTask6($taskSchedulePlan, $approve)
{
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
@ -2566,25 +2578,16 @@ class TaskLogic extends BaseLogic
$townCompany = Company::where('id', $taskTemplateInfo['company_id'])->find(); // 镇农科公司
$villageCompanyList = Company::where(['street' => $townCompany['street'], 'company_type'=> 17])->select()->toArray(); // 村管理公司
// 当前任务进行天数 < 第一+第二阶段天数 只刷新任务时间
if ($taskDayCount < $stageDayOneAccumulative) {
self::flushTaskTime($taskSchedulePlan);
return true;
}
// 当前任务进行天数 = 第一+第二阶段天数 判定任务是否完成 结算 分润
if($taskDayCount == $stageDayTwoAccumulative) {
// 当前任务进行天数 <= 第一+第二阶段天数 判定任务是否完成 结算 分润
if($taskDayCount <= $stageDayTwoAccumulative) {
// 小组服务公司总数
$groupServiceCompanyCount = Company::where(['street' => $townCompany['street'], 'company_type'=> 18])->count();
if ($groupServiceCompanyCount == 0) {
throw new Exception('小组服务公司数量为0异常'.__FILE__.__LINE__);
}
// 小组服务完成股金上交数
$sharecapitalPaidCount = 0;
foreach ($villageCompanyList as $villageCompany) {
$sharecapitalPaidCount += Db::name('company_sharecapital_change_log')->where(['parent_company_id'=>$villageCompany['id']])->count();
}
$sharecapitalPaidCount = intdiv($approve->amount, 3000);
$rate = bcdiv($sharecapitalPaidCount, $groupServiceCompanyCount, 2);
// 小于50% 未完成 关闭任务
@ -2675,11 +2678,33 @@ class TaskLogic extends BaseLogic
break;
// 督促小组服务团队入股
case 'village_task_type_4':
self::dealVillageTask4($taskSchedulePlan);
// 结算逻辑由手动审核,任务超时则关闭
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$dayCount = $taskTemplateInfo['day_count'];
$stageDayCount = bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two']);
// 任务累计天数 < 第一阶段+第二阶段 刷新任务
if ($dayCount <= $stageDayCount) {
self::flushTaskTime($taskSchedulePlan);
return true;
} else {
(new Task())->closeTask($taskSchedulePlan['task_id']);
}
// self::dealVillageTask4($taskSchedulePlan);
break;
// 入股甲方公司
case 'village_task_type_5':
self::dealVillageTask5($taskSchedulePlan);
// 结算逻辑由手动审核,任务超时则关闭
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$dayCount = $taskTemplateInfo['day_count'];
$stageDayCount = bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two']);
// 任务累计天数 < 第一阶段+第二阶段 刷新任务
if ($dayCount <= $stageDayCount) {
self::flushTaskTime($taskSchedulePlan);
return true;
} else {
(new Task())->closeTask($taskSchedulePlan['task_id']);
}
// self::dealVillageTask5($taskSchedulePlan);
break;
// 信息平台铺设工作
case 'village_task_type_6':
@ -2835,9 +2860,9 @@ class TaskLogic extends BaseLogic
/**
* @param $taskSchedulePlan
* 督促小组服务团队入股
* 督促小组服务团队入股 手动审核通过后才结算
*/
private static function dealVillageTask4($taskSchedulePlan)
public static function dealVillageTask4($taskSchedulePlan, $approve)
{
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
@ -2845,21 +2870,13 @@ class TaskLogic extends BaseLogic
$target = $taskTemplateInfo['extend']['target'];
$stageDayCount = bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two']);
$villageCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$townCompany = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$villageCompany['street']], true)[0];
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
// 任务累计天数 < 第一阶段+第二阶段 刷新任务
if ($dayCount < $stageDayCount) {
self::flushTaskTime($taskSchedulePlan);
return true;
}
// 任务累计天数 = 第一阶段+第二阶段 任务判定,计算金额,结算分润
if ($dayCount == $stageDayCount) {
// 在任务期限内才结算
if($dayCount <= $stageDayCount) {
// 目标入股金额
$targetShareholderedMoney = bcmul($target, 3000, 2);
// 小组服务股金上交金额
$shareholderedMoney = Db::name('company_sharecapital_change_log')->where(['parent_company_id'=>$townCompany['id']])->sum('amount');
$shareholderedMoney = $approve->amount;
$rate = bcdiv($shareholderedMoney, $targetShareholderedMoney, 2);
if (bccomp($rate, 0.5, 2) == -1) {
@ -2871,6 +2888,8 @@ class TaskLogic extends BaseLogic
$task['money'] = self::countSettelmentMoney($rate, $totalMoney);
(new VillageShareProfit())->dealVillageTaskSettlement4($task, $villageCompany, $taskSchedulePlan);
}
}
private static function countSettelmentMoney($rate, $totalMoney)
@ -2904,38 +2923,22 @@ class TaskLogic extends BaseLogic
/**
* @param $taskSchedulePlan
* 入股甲方公司
* 任务累计天数 < 第一+第二阶段天数 刷新任务
* 任务累计天数 = 第一阶段+第二阶段 任务判定,计算金额,结算分润
* 入股甲方公司 手动审核通过后才结算
*/
private static function dealVillageTask5($taskSchedulePlan)
public static function dealVillageTask5($taskSchedulePlan, $approve)
{
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$dayCount = $taskTemplateInfo['day_count'];
$target = $taskTemplateInfo['extend']['target'];
$stageDayCount = bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two']);
// $townCompany = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$villageCompany['street']], true)[0];
// 任务累计天数 < 第一+第二阶段天数 刷新任务
if ($dayCount < $stageDayCount) {
self::flushTaskTime($taskSchedulePlan['task_id']);
return true;
}
// 任务累计天数 = 第一阶段+第二阶段 任务判定,计算金额,结算分润
if ($dayCount == $stageDayCount) {
if ($dayCount <= $stageDayCount) {
// 任务累计天数 = 第一阶段+第二阶段 任务判定,计算金额,结算分润
$villageCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
// 小组公司列表 村地区码与村管理公司一样且在村管理公司负责小队
$groupServiceCompanyList = Company::where(['village' => $villageCompany['village'], 'company_type'=> 18, 'is_contract'=>1])->select()->toArray();
$shareholderedMoney = 0; // 已入股股金总额
// 查询公司股金变动流水记录
$companyIds[] = $villageCompany['id'];
foreach ($groupServiceCompanyList as $company) {
$companyIds[] = $company['id'];
}
// 小组服务和村公司股金上交金额
$shareholderedMoney = Db::name('company_sharecapital_change_log')->whereIn('subordinate_company_id', $companyIds)->where(['parent_company_id'=>$villageCompany['id']])->sum('amount');
$shareholderedMoney = $approve->amount;
// 目标上交股金金额 小组应组建团队数量*3000 + 村 6000
$targetShareholderedMoney = bcadd(bcmul($target, 3000), 6000);
$rate = bcdiv($shareholderedMoney, $targetShareholderedMoney, 2);

View File

@ -24,6 +24,9 @@ class Approve extends BaseModel
const APPROVE_TYPE_8 = 8; // 镇农科负责人任务-政策补贴申请
const APPROVE_TYPE_9 = 9; // 镇农科负责人任务-日常管理及其他临时任务
const APPROVE_TYPE_10 = 10; // 小组团队任务-入股任务
const APPROVE_TYPE_11 = 11; // 村联络员任务-督促小组服务团队入股
const APPROVE_TYPE_12 = 12; // 村联络员任务-入股甲方公司
const APPROVE_TYPE_13 = 13; // 镇农科服务部长任务-督促入股村管理公司
public function task()
{