Merge branch 'dev' into preview
This commit is contained in:
commit
cc1039465a
app
adminapi
api/controller
CronController.phpInformationController.phpTaskController.phpVehicleController.phpXunFeiController.php
common
logic
model
@ -8,6 +8,7 @@ use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveController extends BaseAdminController
|
||||
@ -17,6 +18,10 @@ class ApproveController extends BaseAdminController
|
||||
return $this->dataLists(new ApproveLists());
|
||||
}
|
||||
|
||||
public function lists2()
|
||||
{
|
||||
return $this->success('成功',(new ApproveLists())->lists2());
|
||||
}
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
@ -25,6 +30,7 @@ class ApproveController extends BaseAdminController
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
// 拒绝通过 要让用户今天可以继续做任务
|
||||
if ($params['check_status'] == 3) {
|
||||
@ -32,7 +38,27 @@ class ApproveController extends BaseAdminController
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
$this->pass($approve);
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
$taskTemplate = TaskTemplate::where(['id'=>$approve->business_id])->find();
|
||||
// 提前完成
|
||||
if ($taskTemplate['day_count'] < $taskTemplate['stage_day_one']) {
|
||||
if (bccomp($params['amount'], 300000, 2) == -1) {
|
||||
$this->fail('该任务提前完成条件:销售总额必须达到30万元及以上');
|
||||
} else {
|
||||
// 提前完成标识
|
||||
$extend = json_decode($taskTemplate['extend'], true);
|
||||
$extend['early_finish'] = 1;
|
||||
$taskTemplate->extend = json_encode($extend);
|
||||
$taskTemplate->save();
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve);
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
return $this->success('审核成功');
|
||||
@ -42,7 +68,7 @@ class ApproveController extends BaseAdminController
|
||||
}
|
||||
}
|
||||
// 通过
|
||||
private function pass($approve)
|
||||
private function pass($approve, $params=[])
|
||||
{
|
||||
Db::startTrans();
|
||||
$approve->check_status = 2;
|
||||
@ -76,7 +102,7 @@ class ApproveController extends BaseAdminController
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan, $approve);
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_6) {
|
||||
@ -89,6 +115,26 @@ class ApproveController extends BaseAdminController
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask8($taskSchedulePlan);
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
// 需要手动输入销售总额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_8) {
|
||||
// 需要手动输入申请的政策补贴金额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_9) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::masterTask8Settlement($taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝
|
||||
|
@ -21,7 +21,8 @@ class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'in' => ['type']
|
||||
'in' => ['type'],
|
||||
'='=>['check_status']
|
||||
];
|
||||
}
|
||||
|
||||
@ -47,12 +48,42 @@ class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
|
||||
$task = Task::where('id', $data['task_id'])->find();
|
||||
return Company::where(['id' => $task['company_id']])->value('company_name');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function lists2(): array
|
||||
{
|
||||
$list = Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->with('task')
|
||||
->field('*')
|
||||
->append(['area_manager', 'company_name'], true)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
$extend = json_decode($data['extend'], true);
|
||||
$company = Db::query("select * from la_company where FIND_IN_SET(:street,responsible_area)", ['street'=>$extend['street']], true);
|
||||
return $company[0]['company_name'];
|
||||
})
|
||||
->toArray();
|
||||
$count = Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())->count();
|
||||
|
||||
return [
|
||||
'lists' => $list,
|
||||
'count' => $count,
|
||||
'page_no' => $this->pageNo,
|
||||
'page_size' => $this->pageSize,
|
||||
];
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
|
@ -21,33 +21,13 @@ use app\job\TaskAdd;
|
||||
*/
|
||||
class CronController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['settlement','task_add', 'town_task_add', 'town_task_settlement'];
|
||||
|
||||
/**
|
||||
* 小组服务公司任务结算
|
||||
*/
|
||||
public function settlement(){
|
||||
// $all=TaskSchedulingPlan::where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 18)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
||||
return $this->success('小组服务公司定时任务结算执行成功');
|
||||
|
||||
}
|
||||
public array $notNeedLogin = ['settlement','task_add', 'town_task_add', 'town_task_settlement','village_task_add', 'village_task_settlement'];
|
||||
|
||||
/**
|
||||
* 小组服务公司任务下发
|
||||
*/
|
||||
public function task_add(){
|
||||
//任务下发
|
||||
//任务下发
|
||||
// $time=strtotime(date('Y-m-d',strtotime('-1 day')));
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// $tiem_end=$time+86399;
|
||||
@ -78,55 +58,23 @@ class CronController extends BaseApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇农科公司任务结算
|
||||
* 小组服务公司任务结算
|
||||
*/
|
||||
public function town_task_settlement()
|
||||
{
|
||||
Log::info('镇农科公司定时任务结算执行-开始'.date('Y-m-d H:i:s'));
|
||||
//today 今日未结算的任务计划
|
||||
$taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
public function settlement(){
|
||||
// $all=TaskSchedulingPlan::where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 41)
|
||||
->where('scheduling.company_type', 18)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($taskSchedulingPlanList as $taskSchedulingPlan){
|
||||
queue(TownTaskSettlementJob::class, $taskSchedulingPlan);
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
Log::info('镇农科公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
|
||||
return $this->success('镇农科公司定时任务结算执行成功');
|
||||
}
|
||||
Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
||||
return $this->success('小组服务公司定时任务结算执行成功');
|
||||
|
||||
/**
|
||||
* 镇农科公司任务下发
|
||||
*/
|
||||
public function town_task_add()
|
||||
{
|
||||
//任务下发
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// 查询系统 所有镇农科公司 未下发 的 任务安排
|
||||
$taskSchedulingList = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->where('company_type', 41)->with('company_info')->select()->toArray();
|
||||
|
||||
$taskSchedulingIds = [];
|
||||
$companyIds = [];
|
||||
foreach ($taskSchedulingList as $k => $taskScheduling) {
|
||||
$templateList = TaskTemplate::where('status', 1)->where('task_scheduling', $taskScheduling['id'])->limit(30)->select()->toArray();
|
||||
$taskSchedulingIds[] = $taskScheduling['id'];
|
||||
$companyIds[] = $taskScheduling['company_id'];
|
||||
foreach ($templateList as $template) {
|
||||
queue(TownTaskAdd::class, $template);
|
||||
// TaskLogic::TownCronAdd($template); // 手动下发用
|
||||
}
|
||||
|
||||
if (empty($templateList)) {
|
||||
unset($taskSchedulingList[$k]);
|
||||
}
|
||||
}
|
||||
Company::where('id', 'in', $companyIds)->inc('day_count')->update();
|
||||
TaskScheduling::where('id', 'in', $taskSchedulingIds)->update(['cron_time' => time()]);
|
||||
Log::info('镇农科公司定时任务下发执行成功' . date('Y-m-d H:i:s'));
|
||||
return $this->success('镇农科公司定时任务下发执行成功');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,4 +133,61 @@ class CronController extends BaseApiController
|
||||
Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
|
||||
return $this->success('村管理公司定时任务结算执行成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇农科公司任务下发
|
||||
*/
|
||||
public function town_task_add()
|
||||
{
|
||||
//任务下发
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// 查询系统 所有镇农科公司 未下发 的 任务安排
|
||||
$taskSchedulingList = TaskScheduling::where('cron_time', '<', $time)
|
||||
->where('status', 1)
|
||||
->where('company_type', 41)
|
||||
->with('company_info')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$taskSchedulingIds = [];
|
||||
$companyIds = [];
|
||||
foreach ($taskSchedulingList as $k => $taskScheduling) {
|
||||
$templateList = TaskTemplate::where('status', 1)->where('task_scheduling', $taskScheduling['id'])->limit(30)->select()->toArray();
|
||||
$taskSchedulingIds[] = $taskScheduling['id'];
|
||||
$companyIds[] = $taskScheduling['company_id'];
|
||||
foreach ($templateList as $template) {
|
||||
queue(TownTaskAdd::class, $template);
|
||||
// TaskLogic::TownCronAdd($template); // 手动下发用
|
||||
}
|
||||
|
||||
if (empty($templateList)) {
|
||||
unset($taskSchedulingList[$k]);
|
||||
}
|
||||
}
|
||||
Company::where('id', 'in', $companyIds)->inc('day_count')->update();
|
||||
TaskScheduling::where('id', 'in', $taskSchedulingIds)->update(['cron_time' => time()]);
|
||||
Log::info('镇农科公司定时任务下发执行成功' . date('Y-m-d H:i:s'));
|
||||
return $this->success('镇农科公司定时任务下发执行成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇农科公司任务结算
|
||||
*/
|
||||
public function town_task_settlement()
|
||||
{
|
||||
Log::info('镇农科公司定时任务结算执行-开始'.date('Y-m-d H:i:s'));
|
||||
//today 今日未结算的任务计划
|
||||
$taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 41)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($taskSchedulingPlanList as $taskSchedulingPlan){
|
||||
queue(TownTaskSettlementJob::class, $taskSchedulingPlan);
|
||||
}
|
||||
Log::info('镇农科公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
|
||||
return $this->success('镇农科公司定时任务结算执行成功');
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\model\Company;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\informationg\UserInformationgDemand;
|
||||
@ -12,7 +13,7 @@ use think\response\Json;
|
||||
|
||||
class InformationController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['farmerInfo','farmerLandInfo'];
|
||||
public array $notNeedLogin = ['groupServiceInfo','captainInfo','farmerInfo','farmerInfoByPhone','farmerLandInfo','farmerPondInfo','farmerList'];
|
||||
|
||||
public function list()
|
||||
{
|
||||
@ -133,6 +134,178 @@ class InformationController extends BaseApiController
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
//获取吓阻服务公司用户信息
|
||||
public function groupServiceInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
$userData = User::field('id,company_id,nickname as name,avatar')->where('id',$params['user_id'])->findOrEmpty();
|
||||
if($userData->isEmpty()){
|
||||
return $this->fail('用户数据不存在');
|
||||
}
|
||||
$companyData = Company::field('id,company_name,company_type')->where('id',$userData['company_id'])->findOrEmpty();
|
||||
if($companyData->isEmpty() || $companyData['company_type'] != 18){
|
||||
return $this->fail('当前用户不是小组服务公司用户');
|
||||
}
|
||||
$userData['company_name'] = $companyData['company_name'];
|
||||
//获取小组服务公司下面的队长
|
||||
$captainList = User::field('id,nickname as name,avatar,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name')->where('company_id',$userData['company_id'])->where('is_captain',1)->select()->each(function($item){
|
||||
$item['address'] = $item['province_name'].$item['city_name'].$item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'];
|
||||
unset($item['province'],$item['province_name'],$item['city'],$item['city_name'],$item['area'],$item['area_name'],$item['street'],$item['street_name'],$item['village'],$item['village_name'],$item['brigade'],$item['brigade_name']);
|
||||
$farmerList = UserInformationg::where('create_user_id', $item['id'])->field('id')->select()->each(function($val){
|
||||
//获取农户档案详情
|
||||
$information = UserInformationgDemand::field('id,category_child,data')->where('information_id', $val['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//总面积
|
||||
$val['land_total_area'] = 0;
|
||||
$val['pond_total_area'] = 0;
|
||||
$val['animal_total_area'] = 0;
|
||||
$val['poultry_total_area'] = 0;
|
||||
//种养类型
|
||||
$val['is_zz_user'] = false;
|
||||
$val['is_sc_user'] = false;
|
||||
$val['is_jc_user'] = false;
|
||||
$val['is_jq_user'] = false;
|
||||
foreach($information as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$val['is_zz_user'] = true;
|
||||
$val['land_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$val['is_sc_user'] = true;
|
||||
$val['pond_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$val['is_jc_user'] = true;
|
||||
$val['animal_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$val['is_jq_user'] = true;
|
||||
$val['poultry_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$val['total_area'] = $val['land_total_area'] + $val['pond_total_area'] + $val['animal_total_area'] + $val['poultry_total_area'];
|
||||
return $val;
|
||||
})->toArray();
|
||||
$item['farmer_total'] = count($farmerList);
|
||||
$item['farmer_area'] = array_sum(array_column($farmerList,'total_area'));
|
||||
$item['farmer_zz_total'] = 0;
|
||||
$item['farmer_sc_total'] = 0;
|
||||
$item['farmer_jc_total'] = 0;
|
||||
$item['farmer_jq_total'] = 0;
|
||||
$item['farmer_zz_area'] = 0;
|
||||
$item['farmer_sc_area'] = 0;
|
||||
$item['farmer_jc_area'] = 0;
|
||||
$item['farmer_jq_area'] = 0;
|
||||
foreach($farmerList as $v){
|
||||
if($v['is_zz_user']){
|
||||
$item['farmer_zz_total'] += 1;
|
||||
}
|
||||
if($v['is_sc_user']){
|
||||
$item['farmer_sc_total'] += 1;
|
||||
}
|
||||
if($v['is_jc_user']){
|
||||
$item['farmer_jc_total'] += 1;
|
||||
}
|
||||
if($v['is_jq_user']){
|
||||
$item['farmer_jq_total'] += 1;
|
||||
}
|
||||
$item['farmer_zz_area'] += $v['land_total_area'];
|
||||
$item['farmer_sc_area'] += $v['pond_total_area'];
|
||||
$item['farmer_jc_area'] += $v['animal_total_area'];
|
||||
$item['farmer_jq_area'] += $v['poultry_total_area'];
|
||||
}
|
||||
return $item;
|
||||
})->toArray();
|
||||
$userData['captain_list'] = $captainList;
|
||||
return $this->success('请求成功',$userData->toArray());
|
||||
}
|
||||
|
||||
//获取生产队长信息
|
||||
public function captainInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
$userData = User::field('id,nickname as name,avatar,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name')->where('id',$params['user_id'])->where('is_captain',1)->findOrEmpty();
|
||||
if($userData->isEmpty()){
|
||||
return $this->fail('用户数据不存在');
|
||||
}
|
||||
$userData['address'] = $userData['province_name'].$userData['city_name'].$userData['area_name'].$userData['street_name'].$userData['village_name'].$userData['brigade_name'];
|
||||
unset($userData['province'],$userData['province_name'],$userData['city'],$userData['city_name'],$userData['area'],$userData['area_name'],$userData['street'],$userData['street_name'],$userData['village'],$userData['village_name'],$userData['brigade'],$userData['brigade_name']);
|
||||
//获取生产队长下面的农户
|
||||
$farmerList = UserInformationg::where('create_user_id', $params['user_id'])->field('id,name,phone,area_id,street_id,village_id,brigade_id,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->select()->each(function($item){
|
||||
$item['address'] = $item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'];
|
||||
unset($item['area_id'],$item['area_name'],$item['street_id'],$item['street_name'],$item['village_id'],$item['village_name'],$item['brigade_id'],$item['brigade_name']);
|
||||
//获取农户档案详情
|
||||
$information = UserInformationgDemand::field('id,category_child,data')->where('information_id', $item['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//总面积
|
||||
$item['land_total_area'] = 0;
|
||||
$item['pond_total_area'] = 0;
|
||||
$item['animal_total_area'] = 0;
|
||||
$item['poultry_total_area'] = 0;
|
||||
//种养类型
|
||||
$item['is_zz_user'] = false;
|
||||
$item['is_sc_user'] = false;
|
||||
$item['is_jc_user'] = false;
|
||||
$item['is_jq_user'] = false;
|
||||
foreach($information as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$item['is_zz_user'] = true;
|
||||
$item['land_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$item['is_sc_user'] = true;
|
||||
$item['pond_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$item['is_jc_user'] = true;
|
||||
$item['animal_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$item['is_jq_user'] = true;
|
||||
$item['poultry_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$item['total_area'] = $item['land_total_area'] + $item['pond_total_area'] + $item['animal_total_area'] + $item['poultry_total_area'];
|
||||
return $item;
|
||||
})->toArray();
|
||||
$userData['farmer_total'] = count($farmerList);
|
||||
$userData['farmer_area'] = array_sum(array_column($farmerList,'total_area'));
|
||||
$userData['farmer_zz_total'] = 0;
|
||||
$userData['farmer_sc_total'] = 0;
|
||||
$userData['farmer_jc_total'] = 0;
|
||||
$userData['farmer_jq_total'] = 0;
|
||||
$userData['farmer_zz_area'] = 0;
|
||||
$userData['farmer_sc_area'] = 0;
|
||||
$userData['farmer_jc_area'] = 0;
|
||||
$userData['farmer_jq_area'] = 0;
|
||||
foreach($farmerList as $v){
|
||||
if($v['is_zz_user']){
|
||||
$userData['farmer_zz_total'] += 1;
|
||||
}
|
||||
if($v['is_sc_user']){
|
||||
$userData['farmer_sc_total'] += 1;
|
||||
}
|
||||
if($v['is_jc_user']){
|
||||
$userData['farmer_jc_total'] += 1;
|
||||
}
|
||||
if($v['is_jq_user']){
|
||||
$userData['farmer_jq_total'] += 1;
|
||||
}
|
||||
$userData['farmer_zz_area'] += $v['land_total_area'];
|
||||
$userData['farmer_sc_area'] += $v['pond_total_area'];
|
||||
$userData['farmer_jc_area'] += $v['animal_total_area'];
|
||||
$userData['farmer_jq_area'] += $v['poultry_total_area'];
|
||||
}
|
||||
$userData['farmer_list'] = $farmerList;
|
||||
return $this->success('请求成功',$userData->toArray());
|
||||
}
|
||||
|
||||
//获取农户信息,该接口溯源系统调用
|
||||
public function farmerInfo(): Json
|
||||
{
|
||||
@ -142,7 +315,13 @@ class InformationController extends BaseApiController
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
//获取农户信息
|
||||
$farmerInfo = UserInformationg::where('id', $params['user_id'])->field('id,create_user_id,company_id,name,phone,area_id,street_id,village_id,brigade_id,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->findOrEmpty()->toArray();
|
||||
$farmerInfo = UserInformationg::alias('f')
|
||||
->leftJoin('company c','f.company_id = c.id')
|
||||
->leftJoin('user u','u.id = f.create_user_id')
|
||||
->leftJoin('user g','g.id = c.user_id')
|
||||
->where('f.id', $params['user_id'])
|
||||
->field('f.id,f.create_user_id,f.company_id,f.name,f.phone,f.area_id,f.street_id,f.village_id,f.brigade_id,f.area_id area_name,f.street_id street_name,f.village_id village_name,f.brigade_id brigade_name,c.company_name,f.address,u.nickname as captain_name,g.nickname as group_name')
|
||||
->findOrEmpty()->toArray();
|
||||
if(empty($farmerInfo)){
|
||||
return $this->fail('用户不存在_worker');
|
||||
}
|
||||
@ -195,6 +374,19 @@ class InformationController extends BaseApiController
|
||||
return $this->success('请求成功',$farmerInfo);
|
||||
}
|
||||
|
||||
//通过手机号码查找农户
|
||||
public function farmerInfoByPhone(): Json
|
||||
{
|
||||
$params = $this->request->post(['phone']);
|
||||
if(empty($params['phone'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = UserInformationg::where('phone',$params['phone'])
|
||||
->field('id,name,phone,area_id,street_id,village_id,brigade_id,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name,address')
|
||||
->findOrEmpty();
|
||||
return !$data->isEmpty() ? $this->success('请求成功',$data->toArray()) : $this->fail('请求失败');
|
||||
}
|
||||
|
||||
//获取农户土地信息
|
||||
public function farmerLandInfo(): Json
|
||||
{
|
||||
@ -204,7 +396,7 @@ class InformationController extends BaseApiController
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
//获取农户信息
|
||||
$data = UserInformationgDemand::field('id,data')->where('id',$params['land_id'])->where('information_id', $params['user_id'])->where('category_id',6)->where('category_child','7')->findOrEmpty()->toArray();
|
||||
$data = UserInformationgDemand::field('id,data')->where('id',$params['land_id'])->where('information_id', $params['user_id'])->where('category_id',6)->where('category_child',7)->findOrEmpty()->toArray();
|
||||
if(empty($data)){
|
||||
return $this->fail('数据不存在_worker');
|
||||
}
|
||||
@ -214,4 +406,131 @@ class InformationController extends BaseApiController
|
||||
];
|
||||
return $this->success('请求成功',$resData);
|
||||
}
|
||||
|
||||
//获取农户鱼塘信息
|
||||
public function farmerPondInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id','pond_id']);
|
||||
if(empty($params['user_id']) || empty($params['pond_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
//获取农户信息
|
||||
$data = UserInformationgDemand::field('id,data')->where('id',$params['pond_id'])->where('information_id', $params['user_id'])->where('category_id',6)->where('category_child',32)->findOrEmpty()->toArray();
|
||||
if(empty($data) || empty($data['data'])){
|
||||
return $this->fail('数据不存在_worker');
|
||||
}
|
||||
if($data['data']['breeding_type'] != 1){
|
||||
return $this->fail('数据错误_work');
|
||||
}
|
||||
$resData = [
|
||||
'pond_id' => $data['id'],
|
||||
'pond_area' => $data['data']['area']
|
||||
];
|
||||
return $this->success('请求成功',$resData);
|
||||
}
|
||||
|
||||
//获取农户列表
|
||||
public function farmerList(): Json
|
||||
{
|
||||
$params = $this->request->post(['farmer_name','farmer_phone','group_name','captain_name','page_no','page_size']);
|
||||
if(empty($params['page_no']) || empty($params['page_size'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$search = [];
|
||||
if(!empty($params['farmer_name'])){
|
||||
$search[] = ['f.name','like','%'.$params['farmer_name'].'%'];
|
||||
}
|
||||
if(!empty($params['farmer_phone'])){
|
||||
$search[] = ['f.phone','like','%'.$params['farmer_phone'].'%'];
|
||||
}
|
||||
if(!empty($params['group_name'])){
|
||||
$search[] = ['g.nickname','like','%'.$params['group_name'].'%'];
|
||||
}
|
||||
if(!empty($params['captain_name'])){
|
||||
$search[] = ['u.nickname','like','%'.$params['captain_name'].'%'];
|
||||
}
|
||||
$data = UserInformationg::alias('f')
|
||||
->field('f.id,f.create_user_id,f.company_id,f.name,f.phone,f.area_id,f.street_id,f.village_id,f.brigade_id,c.company_name,u.nickname as captain_name,g.nickname as group_name,f.area_id area_name,f.street_id street_name,f.village_id village_name,f.brigade_id brigade_name,f.address')
|
||||
->leftJoin('company c','f.company_id = c.id')
|
||||
->leftJoin('user u','u.id = f.create_user_id')
|
||||
->leftJoin('user g','g.id = c.user_id')
|
||||
->where($search)
|
||||
->page($params['page_no'],$params['page_size'])->order('id desc')->select()
|
||||
->each(function($item){
|
||||
$item['address'] = $item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'].$item['address'];
|
||||
unset($item['area_name'],$item['street_name'],$item['village_name'],$item['brigade_name'],$item['area_id'],$item['street_id'],$item['village_id'],$item['brigade_id']);
|
||||
$userInformationgDemand = UserInformationgDemand::field('id,category_child,data')->where('information_id', $item['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//是否是种植户
|
||||
$is_zz_user = false;
|
||||
//是否是水产养殖户
|
||||
$is_sc_user = false;
|
||||
//是否是家禽养殖户
|
||||
$is_jq_user = false;
|
||||
//是否是大型动物养殖户
|
||||
$is_dw_user = false;
|
||||
//土地总面积
|
||||
$total_land_area = 0;
|
||||
//池塘总面积
|
||||
$total_pond_area = 0;
|
||||
//家禽养殖场总面积
|
||||
$total_henhouse_area = 0;
|
||||
//动物养殖场总面积
|
||||
$total_pasture_area = 0;
|
||||
foreach($userInformationgDemand as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$is_zz_user = true;
|
||||
$total_land_area += floatval($v['data']['area']);
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$is_sc_user = true;
|
||||
$total_pond_area += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$is_jq_user = true;
|
||||
$total_henhouse_area += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$is_dw_user = true;
|
||||
$total_pasture_area += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$str = [];
|
||||
$area = [];
|
||||
if($is_zz_user){
|
||||
$str[] = '种植户';
|
||||
$area[] = $total_land_area;
|
||||
}
|
||||
if($is_sc_user){
|
||||
$str[] = '水产养殖户';
|
||||
$area[] = $total_pond_area;
|
||||
}
|
||||
if($is_jq_user){
|
||||
$str[] = '家禽养殖户';
|
||||
$area[] = $total_henhouse_area;
|
||||
}
|
||||
if($is_dw_user){
|
||||
$str[] = '家畜养殖户';
|
||||
$area[] = $total_pasture_area;
|
||||
}
|
||||
$item['farmer_type'] = implode('/',$str);
|
||||
$item['farmer_area'] = implode('/',$area);
|
||||
return $item;
|
||||
})->toArray();
|
||||
$count = UserInformationg::alias('f')
|
||||
->field('f.id,f.create_user_id,f.company_id,f.name,f.phone,f.area_id,f.street_id,f.village_id,f.brigade_id,c.company_name,u.nickname as captain_name,g.nickname as group_name,f.area_id area_name,f.street_id street_name,f.village_id village_name,f.brigade_id brigade_name,f.address')
|
||||
->leftJoin('company c','f.company_id = c.id')
|
||||
->leftJoin('user u','u.id = f.create_user_id')
|
||||
->leftJoin('user g','g.id = c.user_id')
|
||||
->where($search)
|
||||
->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $params['page_no'],
|
||||
'page_size' => $params['page_size'],
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -323,6 +323,10 @@ class TaskController extends BaseApiController
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
if (empty($parmas['annex']) && empty($parmas['video_annex'])) {
|
||||
$this->fail('没有上传凭证,无法提交审核');
|
||||
}
|
||||
|
||||
$extend = ['other' => ['is_commit' => 1, 'note' => $parmas['note'], 'annex'=>$parmas['annex'], 'video_annex' => $parmas['video_annex']]];
|
||||
Db::startTrans();
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
@ -368,6 +372,7 @@ class TaskController extends BaseApiController
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$task = TaskLogic::detail($param);
|
||||
$task['template_info'] = TaskTemplate::where(['id' => $task['template_id']])->find();
|
||||
return $this->success('成功', $task);
|
||||
}
|
||||
|
||||
@ -503,7 +508,7 @@ class TaskController extends BaseApiController
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_6;
|
||||
$approveModel->type = Approve::APPROVE_TYPE_5;
|
||||
$approveModel->flow_id = 1;
|
||||
$approveModel->name = $task['title'];
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
@ -544,8 +549,8 @@ class TaskController extends BaseApiController
|
||||
'other'=> [
|
||||
'is_commit' => 1,
|
||||
'note' => $parmas['note'],
|
||||
'annex' => ['annex'],
|
||||
'video_annex' => ['video_annex'],
|
||||
'annex' => $parmas['annex'],
|
||||
'video_annex' => $parmas['video_annex'],
|
||||
]
|
||||
];
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
@ -557,7 +562,132 @@ class TaskController extends BaseApiController
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_5;
|
||||
$approveModel->type = Approve::APPROVE_TYPE_6;
|
||||
$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 = '0';
|
||||
$approveModel->check_admin_ids = $areaManagerId; // 当前审批人ID 片区经理的admin_id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->extend = json_encode($extend);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
} else {
|
||||
// 有则更新状态
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->save();
|
||||
}
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提前完成,截止提交时间,前面的钱一次性结算,往后至任务结束每天发放
|
||||
*/
|
||||
public function commit_town_master_task_type_2()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex video_annex
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
if (empty($parmas['annex']) && empty($parmas['video_annex'])) {
|
||||
$this->fail('没有上传凭证,无法提交审核');
|
||||
}
|
||||
|
||||
$extend = [
|
||||
'other'=> [
|
||||
'is_commit' => 1,
|
||||
'note' => $parmas['note'],
|
||||
'annex' => $parmas['annex'],
|
||||
'video_annex' => $parmas['video_annex'],
|
||||
]
|
||||
];
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
|
||||
// 片区经理
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
|
||||
// 查询是否 已有审批通过的
|
||||
$approveModel = Approve::where(['business_id' => $task['template_id'], 'check_status' => 2])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_7;
|
||||
$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->business_id = $task['template_id']; // 关联模板id,结算时用于判断这个任务是否提前完成
|
||||
$approveModel->department_id = '0';
|
||||
$approveModel->check_admin_ids = $areaManagerId; // 当前审批人ID 片区经理的admin_id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
} else {
|
||||
// 有则更新状态
|
||||
return $this->fail('该任务已完成,请勿重复提交');
|
||||
}
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交 镇农科负责人-信息收集
|
||||
* 将信息收集存入task_template表中
|
||||
*/
|
||||
publiC function commit_town_master_task_type_3()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$task = Task::where(['id'=>$param['id']])->find();
|
||||
$taskTemplate = TaskTemplate::where(['id'=>$task['template_id']])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交 镇农科负责人-政策补贴申请
|
||||
* 上传凭证,后台审批,填写实际完成金额
|
||||
*/
|
||||
publiC function commit_town_master_task_type_7()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex video_annex
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
if (empty($parmas['annex']) && empty($parmas['video_annex'])) {
|
||||
$this->fail('没有上传凭证,无法提交审核');
|
||||
}
|
||||
|
||||
$extend = [
|
||||
'other'=> [
|
||||
'is_commit' => 1,
|
||||
'note' => $parmas['note'],
|
||||
'annex' => $parmas['annex'],
|
||||
'video_annex' => $parmas['video_annex'],
|
||||
]
|
||||
];
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
|
||||
// 片区经理
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_6;
|
||||
$approveModel->flow_id = 1;
|
||||
$approveModel->name = $task['title'];
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
|
@ -58,7 +58,7 @@ class VehicleController extends BaseApiController
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
//判断是否是镇街公司
|
||||
if($party_b['company_type'] != 16){
|
||||
if($party_b['company_type'] != 41){
|
||||
return ['code'=>0,'msg'=>'非镇街公司不能签约'];
|
||||
}
|
||||
//发送生成合同给物流信息
|
||||
@ -236,12 +236,12 @@ class VehicleController extends BaseApiController
|
||||
return $this->fail('当前小组服务公司未签约');
|
||||
}
|
||||
//获取签约信息
|
||||
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->find();
|
||||
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
if($contract->isEmpty()){
|
||||
return $this->fail('未找到签约镇街公司');
|
||||
}
|
||||
$party_a = Company::field('id,company_name,master_name,master_phone,master_email,is_contract,organization_code,company_type')->where('id',$contract['party_a'])->find();
|
||||
if(empty($contract) || empty($party_a)){
|
||||
return $this->fail('未找到签约镇街公司');
|
||||
}
|
||||
if($party_a['company_type'] != 16){
|
||||
if($party_a['company_type'] != 41){
|
||||
return $this->fail('不能与非镇街公司签约');
|
||||
}
|
||||
if($party_a['is_contract'] != 1){
|
||||
@ -386,7 +386,7 @@ class VehicleController extends BaseApiController
|
||||
if(empty($company)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($company['company_type'] != 16){
|
||||
if($company['company_type'] != 41){
|
||||
return $this->fail('非镇街公司不能访问');
|
||||
}
|
||||
//获取小组服务公司申请信息
|
||||
@ -587,7 +587,7 @@ class VehicleController extends BaseApiController
|
||||
if(empty($company)){
|
||||
return $this->fail('请求错误');
|
||||
}
|
||||
if($company['company_type'] != 16){
|
||||
if($company['company_type'] != 41){
|
||||
return $this->fail('非镇街公司不能访问');
|
||||
}
|
||||
$data = VehicleContract::field('id,contract_no,contract_url,status,create_time,update_time')->where('contract_logistic_id','<>',0)->where('company_b_id',$company['id'])->select();
|
||||
@ -666,6 +666,9 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
//2、获取小组服务公司签约的镇街公司
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
if($zjCompany->isEmpty()){
|
||||
return $this->fail('未获取到小组服务公司签约的镇街公司');
|
||||
}
|
||||
//3、获取镇街公司向平台租赁的且未二次租赁给小组公司的车辆
|
||||
$zjRentCars = VehicleRent::field('car_id')->where('company_id',$zjCompany['party_a'])->where('status',0)->select()->toArray();
|
||||
$zjRentCars = array_column($zjRentCars,'car_id');
|
||||
|
@ -216,6 +216,7 @@ class XunFeiController extends BaseApiController
|
||||
if (!in_array($ext, $extArray)) {
|
||||
return $this->fail('录音格式错误');
|
||||
}
|
||||
// ********** 临时方案 ********** //
|
||||
$encoding = 'raw';
|
||||
if ($ext == 'mp3') {
|
||||
$encoding = 'lame';
|
||||
@ -356,7 +357,7 @@ class XunFeiController extends BaseApiController
|
||||
$audioFile = $dir . '/' . $file_name;
|
||||
$business = [
|
||||
'aue' => 'lame', //mp3格式
|
||||
'vcn' => 'x4_lingxiaoyao_en', //发音人
|
||||
'vcn' => 'aisjinger', //发音人
|
||||
'auf' => 'audio/L16;rate=16000', //音频采样率
|
||||
'speed' => 50, //语速
|
||||
'volume' => 100, //音量
|
||||
|
@ -199,4 +199,20 @@ class ShopRequestLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询镇农科公司负责片区内的种养殖商户和供应链商户交易额
|
||||
*/
|
||||
public static function getTownTradeAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -157,18 +157,19 @@ class TownShareProfit
|
||||
|
||||
$remark = '来自任务【' . $taskSchedulePlan['template_info']['title'] . '】,';
|
||||
|
||||
//负责人收益 todo
|
||||
//负责人收益
|
||||
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 1) {
|
||||
|
||||
$serviceManagerUser = (new User())->searchMaster($company['id']);
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-市场部长用户信息', $serviceManagerUser]);
|
||||
}
|
||||
//市场部长收益
|
||||
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 2) {
|
||||
$serviceManagerUser = User::where(['company_id' => $company['id'], 'group_id' => 16])->find();
|
||||
$serviceManagerUser = (new User())->searchMarketingManager($company['id']);;
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-市场部长用户信息', $serviceManagerUser]);
|
||||
}
|
||||
//服务部长收益 任务金额的50%为服务部长的收益
|
||||
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 3) {
|
||||
$serviceManagerUser = User::where(['company_id' => $company['id'], 'group_id' => 14])->find();
|
||||
$serviceManagerUser = (new User())->searchServiceManager($company['id']);;
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-服务部长用户信息', $serviceManagerUser]);
|
||||
}
|
||||
|
||||
@ -410,4 +411,114 @@ class TownShareProfit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster2(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster4(Task $taskInfo, Company $townCompany, $taskSchedulePlan, $leftTransactionPool)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
// 更新镇交易池
|
||||
(new TaskTemplate())->updateTransactionPool($taskSchedulePlan['template_info']['id'], $leftTransactionPool);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster5(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster6(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster7(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster8(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace app\common\logic\task;
|
||||
use app\common\logic\finance\TownShareProfit;
|
||||
use app\common\logic\finance\VillageShareProfit;
|
||||
use app\common\logic\ShopRequestLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\CompanyComplaintFeedback;
|
||||
use app\common\model\contract\Contract;
|
||||
@ -438,14 +439,19 @@ class TaskLogic extends BaseLogic
|
||||
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
$directorUid = 0; // 指派给
|
||||
if ($taskTemplate['extend']['task_role'] == 1) {
|
||||
$marketingManagerUser = (new User())->searchMaster($taskTemplate['company_id']);
|
||||
Log::info(['镇农科公司定时任务下发-负责人user信息', $marketingManagerUser]);
|
||||
$directorUid = $marketingManagerUser['id'];
|
||||
}
|
||||
if ($taskTemplate['extend']['task_role'] == 2) {
|
||||
$marketingManagerUser = User::where(['company_id'=>$taskTemplate['company_id'], 'group_id'=> 16])->find();
|
||||
$marketingManagerUser = (new User())->searchMarketingManager($taskTemplate['company_id']);
|
||||
Log::info(['镇农科公司定时任务下发-市场部长user信息', $marketingManagerUser]);
|
||||
$directorUid = $marketingManagerUser['id'];
|
||||
}
|
||||
|
||||
if ($taskTemplate['extend']['task_role'] == 3) {
|
||||
$serviceManagerUser = User::where(['company_id'=>$taskTemplate['company_id'], 'group_id'=> 14])->find();
|
||||
$serviceManagerUser = (new User())->searchServiceManager($taskTemplate['company_id']);
|
||||
Log::info(['镇农科公司定时任务下发-服务部长user信息', $serviceManagerUser]);
|
||||
$directorUid = $serviceManagerUser['id'];
|
||||
}
|
||||
@ -507,6 +513,9 @@ class TaskLogic extends BaseLogic
|
||||
$data = $arr;
|
||||
|
||||
// 不同角色,计算任务金额有差异
|
||||
if($taskTemplate['extend']['task_role'] == 1) {
|
||||
$data['money'] = self::countTownMasterTaskMoney($taskTemplate);
|
||||
}
|
||||
if($taskTemplate['extend']['task_role'] == 2) {
|
||||
$data['money'] = self::countTownTaskMarketingMoney($taskTemplate);
|
||||
}
|
||||
@ -623,6 +632,45 @@ class TaskLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static function countTownMasterTaskMoney($template)
|
||||
{
|
||||
$v_day_count = $template['day_count'];
|
||||
$v_day_count = $v_day_count + 1;
|
||||
$stageDayOneAccumulative = $template['stage_day_one']; // 第一阶段天数
|
||||
$stageDayTwoAccumulative = bcadd($template['stage_day_one'], $template['stage_day_two']); // 第二阶段天数 第一+第二
|
||||
$stageDayThreeAccumulative = bcadd($stageDayTwoAccumulative, $template['stage_day_three']); // 第三阶段天数 第二阶段累计值+第三
|
||||
|
||||
// 单次和循环任务
|
||||
if ($template['types'] == 1 || $template['types'] == 3) {
|
||||
if ($v_day_count <= $stageDayOneAccumulative) {
|
||||
// 第一阶段金额
|
||||
return $template['money'];
|
||||
} else if ($stageDayOneAccumulative < $v_day_count && $v_day_count<= $stageDayTwoAccumulative) {
|
||||
// 第二阶段金额
|
||||
return $template['money_two'];
|
||||
} else if ( $stageDayTwoAccumulative < $v_day_count && $v_day_count <= $stageDayThreeAccumulative) {
|
||||
// 第三阶段金额
|
||||
return $template['new_money_three'];
|
||||
}
|
||||
} elseif ($template['types'] == 2) {
|
||||
// 长期任务
|
||||
|
||||
if ($v_day_count<= $stageDayOneAccumulative) {
|
||||
// 第一阶段金额
|
||||
return $template['money'];
|
||||
} elseif ( $stageDayOneAccumulative < $v_day_count && $v_day_count <= $stageDayTwoAccumulative) {
|
||||
// 第二阶段金额
|
||||
return $template['money_two'];
|
||||
} else if ( $stageDayTwoAccumulative < $v_day_count && $v_day_count <=$stageDayThreeAccumulative) {
|
||||
// 第三阶段金额
|
||||
return $template['new_money_three'];
|
||||
} else {
|
||||
// 长期金额
|
||||
return $template['money_three'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 先判定任务是否已完成 再按每个任务对应的结算方式结算
|
||||
* $taskSchedulePlan 包含 task_tempalte、task_schedule、task_schedule_plan 三张表的信息
|
||||
@ -632,9 +680,9 @@ class TaskLogic extends BaseLogic
|
||||
try {
|
||||
Log::info(['镇农科公司定时任务结算执行-任务计划', $taskSchedulePlan]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
// 负责人任务结算 todo
|
||||
// 负责人任务结算
|
||||
if ($taskTemplateInfo['extend']['task_role'] == 1) {
|
||||
|
||||
self::masterTaskSettlement($taskSchedulePlan);
|
||||
}
|
||||
// 市场部长任务结算
|
||||
if ($taskTemplateInfo['extend']['task_role'] == 2) {
|
||||
@ -651,6 +699,322 @@ class TaskLogic extends BaseLogic
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇农科负责人任务结算
|
||||
*/
|
||||
private static function masterTaskSettlement($taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
// 任务类型用的数据字典主键id,将id和value作映射,避免测试和正式环境数据字典数据不一致时出问题
|
||||
$townTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id');
|
||||
switch ($townTaskTypeList[$taskTemplateInfo['type']]){
|
||||
// 应用软件推广
|
||||
case 'town_task_type_master_2':
|
||||
self::masterTask2Settlement($taskSchedulePlan);
|
||||
break;
|
||||
// 信息收集与促销
|
||||
case 'town_task_type_master_3':
|
||||
self::masterTask3Settlement($taskSchedulePlan);
|
||||
break;
|
||||
// 种养殖基地订单匹配
|
||||
case 'town_task_type_master_4':
|
||||
self::masterTask4Settlement($taskSchedulePlan);
|
||||
break;
|
||||
// 村联络员招募
|
||||
case 'town_task_type_master_5':
|
||||
self::masterTask5Settlement($taskSchedulePlan);
|
||||
break;
|
||||
// 促成村联络员入股甲方
|
||||
case 'town_task_type_master_6':
|
||||
self::masterTask6Settlement($taskSchedulePlan);
|
||||
break;
|
||||
// 政策补贴申请
|
||||
case 'town_task_type_master_7':
|
||||
self::masterTask7Settlement($taskSchedulePlan);
|
||||
break;
|
||||
// 日常管理及其他临时任务
|
||||
case 'town_task_type_master_8':
|
||||
// 如果当天做了临时任务的情况下,需要通过审批才结算
|
||||
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
|
||||
if(isset($task['extend']['is_commit']) && $task['extend']['is_commit'] == 1) {
|
||||
return true;
|
||||
}
|
||||
self::masterTask8Settlement($taskSchedulePlan);
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error(['镇农科任务结算失败',$e->getFile(), $e->getLine(), $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用软件推广 单次任务
|
||||
* 提前完成,截止提交时间,前面的钱一次性结算,往后至任务结束每天发放
|
||||
*/
|
||||
private static function masterTask2Settlement($taskSchedulePlan)
|
||||
{
|
||||
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$dayCount = $taskTemplateInfo['day_count'];
|
||||
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
// 任务累计天数 < 第一阶段天数 如果任务状态为已完成,则一次性结算截止到今日的金额。
|
||||
if($dayCount < $taskTemplateInfo['stage_day_one']) {
|
||||
// 如果任务状态为已完成,表示今天用户有提交提前完成的凭证并且已通过审批,则一次性结算截止到今日的金额。
|
||||
if ($taskInfo['status'] == 3) {
|
||||
$taskInfo['money'] = bcmul($dayCount, $taskTemplateInfo['money'], 2);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster2($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
} else {
|
||||
// 任务状态为未完成,查看该任务模板是否有提前完成标识,有则每日结算当天的金额。
|
||||
$extend = $taskTemplateInfo['extend'];
|
||||
if (isset($extend['early_finish']) && $extend['early_finish'] == 1) {
|
||||
$taskInfo['money'] = $taskTemplateInfo['money'];
|
||||
(new TownShareProfit())->dealTaskSettlementMaster2($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
// 刷新任务时间
|
||||
self::flushTaskTime($taskSchedulePlan);
|
||||
}
|
||||
|
||||
// 任务最后一天结算
|
||||
if ($dayCount == $taskTemplateInfo['stage_day_one']) {
|
||||
if (isset($extend['early_finish']) && $extend['early_finish'] == 1) {
|
||||
$taskInfo['money'] = $taskTemplateInfo['money'];
|
||||
(new TownShareProfit())->dealTaskSettlementMaster2($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
} else {
|
||||
// 状态为已完成,表示后台已通过审批
|
||||
if ($taskInfo['status'] == 3) {
|
||||
// 结算分润
|
||||
$approve = Approve::where(['business_id'=>$taskTemplateInfo['id']])->find();
|
||||
$amount = $approve['amount'];
|
||||
// 计算实际完成率
|
||||
$rate = bcdiv($amount, 300000, 2);
|
||||
if (bccomp($rate, 0.5, 2) == 1) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
return false;
|
||||
}
|
||||
$totalMoney = bcmul($taskTemplateInfo['money'], $taskTemplateInfo['stage_day_one'], 2);
|
||||
$taskInfo['money'] = self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster2($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// todo
|
||||
private static function masterTask3Settlement($taskSchedulePlan)
|
||||
{
|
||||
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$dayCount = $taskTemplateInfo['day_count'];
|
||||
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
// 任务累计天数 小于 第一阶段 关闭任务
|
||||
if ($dayCount < $taskTemplateInfo['stage_day_one']) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 任务累计天数 = 第一阶段 收集信息 >= 1家
|
||||
if ($dayCount == $taskTemplateInfo['stage_day_one']) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $taskSchedulePlan
|
||||
* 督促种养殖商户和供应链商户交易
|
||||
*/
|
||||
private static function masterTask4Settlement($taskSchedulePlan)
|
||||
{
|
||||
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
|
||||
// 任务交易池,用于叠加交易额
|
||||
$townTransactionPool = $taskTemplateInfo['transaction_pool'];
|
||||
// 行政村数量
|
||||
$villageCount = Db::name('geo_village')->where(['street_code' => $townCompany['street']])->count();
|
||||
// 每日目标金额
|
||||
$targetAmount = bcmul($villageCount, 329 , 2);
|
||||
// 查询镇农科辖区 当日的 种养殖商户和供应链商户交易额
|
||||
$param = [
|
||||
'start_time' => strtotime(date('Y-m-d', time())),
|
||||
'end_time' => strtotime(date('Y-m-d', time())) + 86399,
|
||||
'responsible_area' => $townCompany['responsible_area'],
|
||||
'type' => 'street',
|
||||
];
|
||||
$result = ShopRequestLogic::getTownTradeAmount($param); // todo 对接接口
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
|
||||
// 总交易额 交易池金额+商城交易额
|
||||
$totalAmount = bcadd($townTransactionPool, $tradeAmount, 2);
|
||||
|
||||
// 完成条件: 总交易额 >= 每日目标金额
|
||||
if (bccomp($totalAmount, $targetAmount, 2) == 0 || bccomp($totalAmount, $targetAmount, 2) == 1) {
|
||||
$leftTransactionPool = bcsub($totalAmount, $targetAmount, 2);
|
||||
// 任务结算
|
||||
(new TownShareProfit())->dealTaskSettlementMaster4($taskInfo, $townCompany, $taskSchedulePlan, $leftTransactionPool);
|
||||
} else {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
}
|
||||
|
||||
private static function masterTask5Settlement($taskSchedulePlan)
|
||||
{
|
||||
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$dayCount = $taskTemplateInfo['day_count'];
|
||||
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
// 行政村数量
|
||||
$villageCount = Db::name('geo_village')->where(['street_code' => $townCompany['street']])->count();
|
||||
// 村公司
|
||||
$villageCompanyList = Db::query("select id from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 17,'street'=>$townCompany['street']], true);
|
||||
$ids = array_column($villageCompanyList, 'id');
|
||||
// 村联络员数量
|
||||
$liaisonManCount = User::where(['group_id'=>17])->whereIn('company_id', $ids)->count();
|
||||
|
||||
// 第一周期天数
|
||||
$stageOneDayCount = bcmul($villageCount, 4);
|
||||
|
||||
// 任务累计天数 小于 第一周期天数 关闭任务
|
||||
if ($dayCount < $stageOneDayCount) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// 任务累计天数第一个周期结算
|
||||
if ($dayCount == $stageOneDayCount) {
|
||||
$rate = bcdiv($liaisonManCount, $villageCount, 2);
|
||||
if (bccomp($rate, 0.5, 2) == 1) {
|
||||
// 按个数结算
|
||||
$taskInfo['money'] = bcmul($liaisonManCount, 120, 2);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster5($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
} else {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
}
|
||||
|
||||
// 任务累计天数 大于 第一周期天数, 每天结算
|
||||
if ($dayCount > $stageOneDayCount) {
|
||||
$rate = bcdiv($liaisonManCount, $villageCount, 2);
|
||||
if (bccomp($rate, 0.5, 2) == 1) {
|
||||
// 按实际完成率结算
|
||||
$taskInfo['money'] = bcmul($rate, $taskTemplateInfo['money_three'], 2);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster5($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
} else {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $taskSchedulePlan
|
||||
* 促成村联络员入股甲方 单次
|
||||
* 任务累计天数 小于 第一阶段 刷新任务时间
|
||||
* 任务累计天数 = 第一阶段 结算
|
||||
*/
|
||||
private static function masterTask6Settlement($taskSchedulePlan)
|
||||
{
|
||||
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$dayCount = $taskTemplateInfo['day_count'];
|
||||
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
// 行政村数量
|
||||
$villageCount = Db::name('geo_village')->where(['street_code' => $townCompany['street']])->count();
|
||||
// 小组服务公司总数
|
||||
$groupServiceCompanyList = Company::where(['company_type'=> 18])->whereIn('street', $townCompany['responsible_area'])->select()->toArray();
|
||||
$groupServiceCompanyCount = count($groupServiceCompanyList);
|
||||
|
||||
// 任务累计天数 小于 第一阶段 刷新任务时间
|
||||
if ($dayCount < $taskTemplateInfo['stage_day_one']) {
|
||||
self::flushTaskTime($taskSchedulePlan);
|
||||
}
|
||||
|
||||
// 任务累计天数 = 第一阶段 结算
|
||||
if ($dayCount == $taskTemplateInfo['stage_day_one']) {
|
||||
// 目标任务金额 行政村数量*6000 + 小组服务团队数量*3000
|
||||
$targetShareholderedMoney = bcadd(bcmul($villageCount, 6000, 2), bcmul($groupServiceCompanyCount, 3000, 2), 2);
|
||||
|
||||
$companyIds = [];
|
||||
foreach ($groupServiceCompanyList as $groupServiceCompany) {
|
||||
$companyIds[] = $groupServiceCompany['id'];
|
||||
}
|
||||
|
||||
// 村公司
|
||||
$villageCompanyList = Db::query("select id from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 17,'street'=>$townCompany['street']], true);
|
||||
foreach ($villageCompanyList as $villageCompany) {
|
||||
$companyIds[] = $villageCompany['id'];
|
||||
}
|
||||
|
||||
// 已入股股金总额
|
||||
$shareholderedMoney = CompanyAccountLog::where(['change_object'=>CompanyAccountLog::SHAREHOLDER, 'change_type'=>CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY])
|
||||
->whereIn('company_id', $companyIds)
|
||||
->sum('change_amount');
|
||||
|
||||
$rate = bcdiv($shareholderedMoney, $targetShareholderedMoney, 2);
|
||||
|
||||
if (bccomp($rate, 0.5, 2) == -1) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
return true;
|
||||
}
|
||||
$totalMoney = bcmul($taskTemplateInfo['money'], $taskTemplateInfo['stage_day_one'], 2);
|
||||
$taskInfo['money'] = self::countSettelmentMoney($rate, $totalMoney);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster6($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $taskSchedulePlan
|
||||
* 政策补贴申请 单次
|
||||
*/
|
||||
private static function masterTask7Settlement($taskSchedulePlan)
|
||||
{
|
||||
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$dayCount = $taskTemplateInfo['day_count'];
|
||||
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
|
||||
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
if($dayCount < $taskTemplateInfo['stage_day_one']) {
|
||||
self::flushTaskTime($taskSchedulePlan);
|
||||
}
|
||||
|
||||
if ($dayCount == $taskTemplateInfo['stage_day_one']) {
|
||||
// 审批通过后,任务状态会变更为已完成状态,审批是会根据凭证填入实际申请的政策补贴金额,根据该金额计算任务结算金额
|
||||
if ($taskInfo['status'] == 3) {
|
||||
$approve = Approve::where(['task_id' => $taskSchedulePlan['task_id']])->find();
|
||||
if ($approve->check_status == 2) {
|
||||
$amount = $approve['amount']; // 审批通过后的金额
|
||||
$rate = bcdiv($amount, $taskTemplateInfo['extend']['target'], 2);
|
||||
if (bccomp($rate, 0.5, 2) == -1) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
$totalMoney = bcmul($taskTemplateInfo['money'], $taskTemplateInfo['stage_day_one'], 2);
|
||||
$taskInfo['money'] = self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster7($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
}
|
||||
} else {
|
||||
// 关闭任务
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function masterTask8Settlement($taskSchedulePlan)
|
||||
{
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
$villageCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
|
||||
$task['money'] = $taskTemplateInfo['money_three'];
|
||||
(new TownShareProfit())->dealTaskSettlementMaster8($task, $villageCompany, $taskSchedulePlan);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $taskSchedulePlan
|
||||
* 市场部长任务结算
|
||||
@ -2129,7 +2493,10 @@ class TaskLogic extends BaseLogic
|
||||
$groupServiceCompanyCount = Company::where(['street' => $townCompany['street'], 'company_type'=> 18])->count();
|
||||
|
||||
// 小组服务完成股金上交数
|
||||
$sharecapitalPaidCount= Db::name('company_sharecapital_change_log')->where(['parent_company_id'=>$villageCompanyList['id']])->count();
|
||||
$sharecapitalPaidCount = 0;
|
||||
foreach ($villageCompanyList as $villageCompany) {
|
||||
$sharecapitalPaidCount += Db::name('company_sharecapital_change_log')->where(['parent_company_id'=>$villageCompany['id']])->count();
|
||||
}
|
||||
|
||||
$rate = bcdiv($sharecapitalPaidCount, $groupServiceCompanyCount, 2);
|
||||
|
||||
@ -2501,7 +2868,7 @@ class TaskLogic extends BaseLogic
|
||||
$stageDayOneTotalTaskMoney = bcmul($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['money'], 2);
|
||||
$stageDayTwoTotalTaskMoney = bcmul($taskTemplateInfo['stage_day_two'], $taskTemplateInfo['money_two'], 2);
|
||||
$taskMoney = bcadd($stageDayOneTotalTaskMoney, $stageDayTwoTotalTaskMoney, 2);
|
||||
$taskInfo['money'] = $taskMoney;
|
||||
$task['money'] = $taskMoney;
|
||||
(new VillageShareProfit())->dealVillageTaskSettlement6($task, $villageCompany, $taskSchedulePlan);
|
||||
}
|
||||
|
||||
|
@ -256,9 +256,8 @@ class TaskTemplateLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
|
||||
// $params['extend']['task_role'] 扩展字段 任务角色 1总负责人 2市场部长 3服务部长
|
||||
$taskScheduleAmount = 200;
|
||||
$taskScheduleAmount = 700;
|
||||
if ($params['extend']['task_role'] == 1) {
|
||||
$taskScheduleAmount = 300;
|
||||
$serviceManagerUser = (new User())->searchMaster($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
self::setError('公司还没有负责人,无法指派任务');
|
||||
|
@ -19,6 +19,11 @@ class Approve extends BaseModel
|
||||
const APPROVE_TYPE_5 = 5; // 村联络员任务-信息平台铺设工作任务
|
||||
const APPROVE_TYPE_6 = 6; // 村联络员任务-日常管理及其他临时任务
|
||||
|
||||
const APPROVE_TYPE_7 = 7; // 镇农科负责人任务-应用软件推广
|
||||
|
||||
const APPROVE_TYPE_8 = 8; // 镇农科负责人任务-政策补贴申请
|
||||
const APPROVE_TYPE_9 = 9; // 镇农科负责人任务-日常管理及其他临时任务
|
||||
|
||||
public function task()
|
||||
{
|
||||
return $this->hasOne(Task::class, 'id', 'task_id');
|
||||
|
Loading…
x
Reference in New Issue
Block a user