diff --git a/app/adminapi/controller/task_template/TaskTemplateController.php b/app/adminapi/controller/task_template/TaskTemplateController.php index a90c397ea..b94dc0f4e 100644 --- a/app/adminapi/controller/task_template/TaskTemplateController.php +++ b/app/adminapi/controller/task_template/TaskTemplateController.php @@ -105,7 +105,7 @@ class TaskTemplateController extends BaseAdminController $params = (new TaskTemplateValidate())->post()->goCheck('delete'); $task = Task::where(['template_id' =>$params['id']])->whereDay('start_time', 'today')->find(); if(!empty($task)) { - $this->fail('该任务今天已在进行中,无法删除'); + return $this->fail('该任务今天已在进行中,无法删除'); } TaskTemplateLogic::delete($params); return $this->success('删除成功', [], 1, 1); @@ -140,4 +140,29 @@ class TaskTemplateController extends BaseAdminController ]; return $this->data($data); } + + public function checkRole() + { + $params = $this->request->param(); + if ($params['task_role'] == 1) { + $serviceManagerUser = (new User())->searchMaster($params['company_id']); + if (empty($serviceManagerUser)) { + return $this->fail('公司还没有负责人,无法指派任务'); + } + } + if ($params['task_role'] == 2) { + $serviceManagerUser = (new User())->searchMarketingManager($params['company_id']); + if (empty($serviceManagerUser)) { + return $this->fail('公司还没有市场部长,无法指派任务'); + } + } + + if ($params['task_role'] == 3) { + $serviceManagerUser = (new User())->searchServiceManager($params['company_id']); + if (empty($serviceManagerUser)) { + return $this->fail('公司还没有服务部长,无法指派任务'); + } + } + return $this->success('成功'); + } } \ No newline at end of file diff --git a/app/api/controller/CeshiController.php b/app/api/controller/CeshiController.php index 9e98e7260..6bcb6430f 100644 --- a/app/api/controller/CeshiController.php +++ b/app/api/controller/CeshiController.php @@ -306,12 +306,12 @@ class CeshiController extends BaseApiController $all = TaskSchedulingPlan::whereDay('end_time','today') ->withJoin(['scheduling'], 'left') ->where('scheduling.company_type', 18) - ->where('scheduling.company_id', 43) - ->where('is_pay',0) + ->where('scheduling.company_id', 34) +// ->where('is_pay',0) ->with(['template_info']) ->select() ->toArray(); - dd($all); + foreach($all as $k=>$data){ try { TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 1]); @@ -377,34 +377,37 @@ class CeshiController extends BaseApiController $task_35 = Task::where('id', $data['task_id'])->field('director_uid,status,money,start_time,end_time')->with('director_info')->find(); if($task_35){ $day= $data['template_info']['stage_day_one'] + $data['template_info']['stage_day_two']; - if($task_35['status']==3 && $data['template_info']['day_count']<=$day){ - $name = $task_35['director_info']['nickname']; - $arr['status'] = 1; - $arr['money'] = $task_35['money']; - $arr['company_account_type'] = 2; - }else{ - /** - * 判断入股任务 单次类型 是否超时 - * 未超时时刷新开始结束时间 - * 超时则关闭 - */ - if($data['template_info']['day_count']<=$day){ - TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 0]); - try{ - Task::where('id', $data['task_id'])->update(['create_time' => $task_35['start_time']+86400,'update_time' =>time(),'start_time'=>$task_35['start_time']+86400,'end_time'=>$task_35['start_time']+86400+86399]); - }catch(\Exception $e){ - $start_time = strtotime(date('Y-m-d')); - Task::where('id', $data['task_id'])->update(['create_time' => $start_time+86400,'update_time' =>time(),'start_time'=>$start_time+86400,'end_time'=> $start_time + 86400+86399]); - } - return false; - } - - if($data['template_info']['day_count']>$day){ - Task::where('id', $data['task_id'])->update(['status' =>5]); - Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data)); - return false; - } +// if($task_35['status']==3 && $data['template_info']['day_count']<=$day){ +// $name = $task_35['director_info']['nickname']; +// $arr['status'] = 1; +// $arr['money'] = $task_35['money']; +// $arr['company_account_type'] = 2; +// }else{ + if ($task_35['status'] == 3) { + return true; } + /** + * 判断入股任务 单次类型 是否超时 + * 未超时时刷新开始结束时间 + * 超时则关闭 + */ + if($data['template_info']['day_count']<=$day){ + TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 0]); + try{ + Task::where('id', $data['task_id'])->update(['create_time' => $task_35['start_time']+86400,'update_time' =>time(),'start_time'=>$task_35['start_time']+86400,'end_time'=>$task_35['start_time']+86400+86399]); + }catch(\Exception $e){ + $start_time = strtotime(date('Y-m-d')); + Task::where('id', $data['task_id'])->update(['create_time' => $start_time+86400,'update_time' =>time(),'start_time'=>$start_time+86400,'end_time'=> $start_time + 86400+86399]); + } + return false; + } + + if($data['template_info']['day_count']>$day){ + Task::where('id', $data['task_id'])->update(['status' =>5]); + Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data)); + return false; + } +// } }else{ Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为空:' . json_encode($data)); return false; @@ -423,7 +426,7 @@ class CeshiController extends BaseApiController if($data['template_info']['day_count'] >= $day){ Task::where('id', $data['task_id'])->update(['status' =>5]); - Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data)); + Log::info( $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data)); return false; } @@ -579,7 +582,7 @@ class CeshiController extends BaseApiController { Log::info('村管理公司定时任务结算执行-开始'.date('Y-m-d H:i:s')); //today 今日未结算的任务计划 - $taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today') + $taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','yesterday') ->withJoin(['scheduling'], 'left') ->where('scheduling.company_type', 17) ->where('scheduling.company_id', 33) @@ -587,11 +590,11 @@ class CeshiController extends BaseApiController ->with(['template_info']) ->select() ->toArray(); - dd($taskSchedulingPlanList); + foreach($taskSchedulingPlanList as $taskSchedulingPlan){ - if ($taskSchedulingPlan['template_info']['type'] == 69) { + TaskLogic::villageTaskSettlement($taskSchedulingPlan); - } + // queue(VillageTaskSettlementJob::class, $taskSchedulingPlan); } Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s')); diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 9263b5976..92f3a597c 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -3131,6 +3131,12 @@ class TaskLogic extends BaseLogic if ($dayCount > $stageDayThreeCount) { self::finishVillageTask7($startTime, $endTime, 567, 30, $taskTemplateInfo['money_three'], $villageCompany, $taskSchedulePlan); } + + $task = Task::where('id', $taskSchedulePlan['task_id'])->find(); + // 未完成 关闭任务 + if ($task['status'] != 3) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } } /** @@ -3152,7 +3158,7 @@ class TaskLogic extends BaseLogic ]; $result = ShopRequestLogic::getPlantingAndBreedingMerchantTradeAmount($param); - + $task = Task::where('id', $taskSchedulePlan['task_id'])->find(); $tradeAmount = $result['data']['trade_amount']; Log::info(['村管理公司定时任务结算执行-种养殖基地订单匹配-交易额', $tradeAmount]); // 交易池 diff --git a/app/common/logic/task_template/TaskTemplateLogic.php b/app/common/logic/task_template/TaskTemplateLogic.php index 045805740..fa0cd380f 100644 --- a/app/common/logic/task_template/TaskTemplateLogic.php +++ b/app/common/logic/task_template/TaskTemplateLogic.php @@ -136,7 +136,7 @@ class TaskTemplateLogic extends BaseLogic Db::startTrans(); try { $company = Company::find($params['company_id']); - if ($company->company_type == 41) { + if ($company->company_type == 16) { // 创建 镇合伙人公司 任务模板 $taskScheduleAmount = 700; } else {