From 930998598207c9f886f5536560d4de15dba3caf4 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 16 Oct 2023 18:28:05 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=B8=82=E5=9C=BA=E9=83=A8=E9=95=BF?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8B=E5=8F=91=E5=92=8C=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/ShopCallController.php | 20 + app/common/logic/ShopRequestLogic.php | 118 ++- app/common/logic/finance/TownShareProfit.php | 108 +++ app/common/logic/task/TaskLogic.php | 778 ++++++++++++++++++- 4 files changed, 989 insertions(+), 35 deletions(-) create mode 100644 app/api/controller/ShopCallController.php diff --git a/app/api/controller/ShopCallController.php b/app/api/controller/ShopCallController.php new file mode 100644 index 000000000..1e0f84c86 --- /dev/null +++ b/app/api/controller/ShopCallController.php @@ -0,0 +1,20 @@ +request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * 查询供应链商户指定商品采购金额 */ public static function getPurchaseAmount($param) { @@ -77,4 +93,100 @@ class ShopRequestLogic extends BaseLogic return false; } } + + /** + * 查询供应链商户指定商品销售金额 + */ + public static function getTradeAmount($param) + { + try { + $requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * 查询镇农科公司区域 指定时间范围内入驻的一般商户数量 + */ + public static function getGeneralMerchantCount($param) + { + try { + $requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * 查询一般商户入驻5天内是否完成商品上架 + */ + public static function getGeneralMerchantProductListing($param) + { + try { + $requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * 查询一般商户入驻5天内是否完成库存更新 + */ + public static function getGeneralMerchantStockUpdate($param) + { + try { + $requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * 查询一般商户指定商品采购金额 + */ + public static function getGeneralMerchantPurchaseAmount($param) + { + try { + $requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * 查询一般商户指定商品销售金额 + */ + public static function getGeneralMerchantTradeAmount($param) + { + try { + $requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [ + 'query' => $param + ]); + return $requestResponse->getContent(); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } } \ No newline at end of file diff --git a/app/common/logic/finance/TownShareProfit.php b/app/common/logic/finance/TownShareProfit.php index 4dd44e5d6..25cd156ff 100644 --- a/app/common/logic/finance/TownShareProfit.php +++ b/app/common/logic/finance/TownShareProfit.php @@ -284,4 +284,112 @@ class TownShareProfit return false; } } + + public function dealTaskSettlementMarketingDirector4(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $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 dealTaskSettlementMarketingDirector5(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $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 dealTaskSettlementMarketingDirector6(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $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 dealTaskSettlementMarketingDirector7(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $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->getFile(). $e->getLine(). $e->getMessage()); + return false; + } + } + + public function dealTaskSettlementMarketingDirector8(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $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 dealTaskSettlementMarketingDirector9(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $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; + } + } } diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 5257d552e..f5fa3e36e 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -547,29 +547,36 @@ class TaskLogic extends BaseLogic case 'town_task_type_marketing_director_2': self::dealTaskMarketingDirector2($taskSchedulePlan); break; + // 协助供应链商户上架商品和库存更新 case 'town_task_type_marketing_director_3': self::dealTaskMarketingDirector3($taskSchedulePlan); break; + // 督促供应链商户完成采购 case 'town_task_type_marketing_director_4': - + self::dealTaskMarketingDirector4($taskSchedulePlan); break; + // 督促供应链商户完成销售 case 'town_task_type_marketing_director_5': - + self::dealTaskMarketingDirector5($taskSchedulePlan); break; + // 招驻一般商户 case 'town_task_type_marketing_director_6': - + self::dealTaskMarketingDirector6($taskSchedulePlan); break; + // 协助一般商户上架商品和库存更新 case 'town_task_type_marketing_director_7': - + self::dealTaskMarketingDirector7($taskSchedulePlan); break; + // 督促一般商户完成采购 case 'town_task_type_marketing_director_8': - + self::dealTaskMarketingDirector8($taskSchedulePlan); break; + // 督促一般商户完成销售 case 'town_task_type_marketing_director_9': - + self::dealTaskMarketingDirector9($taskSchedulePlan); break; case 'town_task_type_marketing_director_10': - + self::dealTaskMarketingDirector10($taskSchedulePlan); break; default: return true; @@ -671,17 +678,20 @@ class TaskLogic extends BaseLogic * 请求商城接口,查询每个商户商品上架构后15天内是否完成库存更新 * */ - public static function dealTaskMarketingDirector3($company, $template, $task, $type) + public static function dealTaskMarketingDirector3($taskSchedulePlan) { + $templateInfo = $taskSchedulePlan['template_info']; + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); // 商城商户入驻申请id 与商户已关联 - $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$company['id']])->select()->toArray(); + $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); // 遍历农科公司区域下的商户,对每个商户进行判定 foreach ($shopMerchantSettleinLogList as $item) { // 入驻5天内是否完成商品上架 $startTime = $item['create_time']; // 入驻时间 - $endTime = bcadd($startTime, bcmul(86400, $template['stage_day_one'])); - // 只在入驻5天后的最后一天结算 + $endTime = bcadd($startTime, bcmul(86400, $templateInfo['stage_day_one'])); + // 只在入驻5天后的最后一天结算,不然会重复结算 if (date('Y-m-d', $endTime) == date('Y-m-d', time())) { $merIntentionId = $item['mer_intention_id']; $param = [ @@ -694,22 +704,16 @@ class TaskLogic extends BaseLogic // 完成则结算 todo 返回字段要对接 if ($result['is_done'] == 1){ // 结算金额 任务金额/目标数 * 天数 - $task['money'] = bcmul($template['stage_day_one'], bcdiv($template['money'], $template['extend']['target'])); - $taskSchedulePlan = TaskSchedulingPlan::where(['id', $task['scheduling_plan_id']]) - ->withJoin(['scheduling'], 'left') - ->where('scheduling.company_type', 41) - ->where('is_pay',0) - ->with(['template_info']) - ->find(); + $taskInfo['money'] = bcmul($templateInfo['stage_day_one'], bcdiv($templateInfo['money'], $templateInfo['extend']['target'])); Log::info(['5.市场部长-供应链商户完成商品上架任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); - (new TownShareProfit())->dealTaskSettlementMarketingDirector3($task, $company, $taskSchedulePlan); + (new TownShareProfit())->dealTaskSettlementMarketingDirector3($taskInfo, $townCompany, $taskSchedulePlan); } } // 商品上架构后15天内是否完成库存更新 $startTime = $item['create_time']; - $endTime = bcadd($startTime, bcmul( 86400, bcadd($template['stage_day_one'], $template['stage_day_two']))) ; + $endTime = bcadd($startTime, bcmul( 86400, bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']))) ; // 只在上架完成15天后的最后一天结算 if (date('Y-m-d', $endTime) == date('Y-m-d', time())) { $merIntentionId = $item['mer_intention_id']; @@ -722,15 +726,9 @@ class TaskLogic extends BaseLogic Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result)]); if ($result1['is_done'] == 1){ // 结算金额 任务金额/目标数 * 天数 - $task['money'] = bcmul($template['stage_day_two'], bcdiv($template['money_two'], $template['extend']['target'])); - $taskSchedulePlan = TaskSchedulingPlan::where(['id', $task['scheduling_plan_id']]) - ->withJoin(['scheduling'], 'left') - ->where('scheduling.company_type', 41) - ->where('is_pay',0) - ->with(['template_info']) - ->find(); + $taskInfo['money'] = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'])); Log::info(['5.市场部长-供应链商户完成商品上架任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); - (new TownShareProfit())->dealTaskSettlementMarketingDirector3($task, $company, $taskSchedulePlan); + (new TownShareProfit())->dealTaskSettlementMarketingDirector3($taskInfo, $townCompany, $taskSchedulePlan); } } } @@ -746,24 +744,740 @@ class TaskLogic extends BaseLogic * 协助供应链商户采购任务 长期 判定与结算 * 根据每个商户入驻时间,推出各个周期范围的起始时间,商户申请id,指定商品id。请求商城接口 */ - public static function dealTaskMarketingDirector4($company, $template, $task) + public static function dealTaskMarketingDirector4($taskSchedulePlan) { + $templateInfo = $taskSchedulePlan['template_info']; + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); // 商城商户入驻申请id 与商户已关联 - $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$company['id']])->select()->toArray(); + $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); // 遍历农科公司区域下的商户,对每个商户进行判定 foreach ($shopMerchantSettleinLogList as $item) { + + // 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算 + $startTime = strtotime(date('Y-m-d', $item['create_time'])); // 入驻当日 00:00:00 + $endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00 + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ + // 任务判定 + self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo); + } + + // 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算 + $startTime1 = $endTime; // 第一阶段 截止日 00:00:00 + $stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']); + $endTime1 = strtotime("{$stageDayTwoCount} day", $startTime); + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ + self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo); + } + + // 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算 + $startTime2 = $endTime1; // 第二阶段 截止日 00:00:00 + $stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']); + $endTime2 = strtotime("{$stageDayThreeCount} day", $startTime); + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ + self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo); + } + + // 长期 间隔天数 = 当前日期的00:00:00时间戳 - 商户入驻时间累计三个阶段天数的日期00:00:00时间戳 + $startTime3 = $endTime2; // 第三阶段 截止日 00:00:00 + $intervalDayCount = intdiv(bcsub( strtotime(date('Y-m-d', time())), $endTime2), 86400); + $endTime3 = strtotime(date('Y-m-d', time())); + // 间隔天数能整除30 表示可以结算 + if ($intervalDayCount % 30 === 0) { + $step = bcadd(3, intdiv($intervalDayCount, 30)); + self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime3, $endTime3, $step, $townCompany, $taskInfo); + } + } + // 未完成的情况下,每天自动关闭任务 + $task = Task::where(['id'=>$taskSchedulePlan['task_id']])->find(); + if ($task['status'] != 3) { + (new Task())->closeTask($task['id']); + } + } + + /** + * @param $templateInfo + * @param $item + * @param $taskSchedulePlan + * @param $startTime + * @param $endTime + * 判定任务是否完成 完成则结算分润 + */ + private static function judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, $step, $townCompany, $taskInfo) + { + // 只在截止日当天才结算 + $merIntentionId = $item['mer_intention_id']; + $directorGoodsId = $item['extend']['goods_id']; + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'mer_intention_id' => $merIntentionId, + 'goods_id' => $directorGoodsId + ]; + $result1 = ShopRequestLogic::getPurchaseAmount($param); + // todo 返回字段要对接 + if ($result1['procure_amount'] > 0) { + $procureAmount = $result1['procure_amount']; + // 采购金额 实际完成率 + $rate = self::countRate($procureAmount, $step); + + if (bccomp($rate, 0.5, 2) == -1) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } else { + $taskMoney = 0; + // 全额完成可获得的总金额 + $totalMoney = bcmul(30, bcdiv($templateInfo['money_three'], $templateInfo['extend']['target'], 2), 2); + // 已完成 计算结算金额 + if ($step == 1) { + $totalMoney = bcmul($templateInfo['stage_day_one'], bcdiv($templateInfo['money'], $templateInfo['extend']['target'], 2), 2); + } + if ($step == 2) { + $totalMoney = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'], 2), 2); + } + if ($step == 3) { + $totalMoney = bcmul(20, bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'], 2), 2) + bcmul(10, bcdiv($templateInfo['money_three'], $templateInfo['extend']['target'], 2), 2); + } + + if ($procureAmount >= 300000) { + $taskMoney = $totalMoney; + } else { + // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 + $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); + } + $taskInfo['money'] = $taskMoney; + $taskSchedulePlan = TaskSchedulingPlan::where(['id', $taskInfo['scheduling_plan_id']]) + ->withJoin(['scheduling'], 'left') + ->where('scheduling.company_type', 41) + ->where('is_pay',0) + ->with(['template_info']) + ->find(); + Log::info(['5.市场部长-供应链商户完成采购任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); + (new TownShareProfit())->dealTaskSettlementMarketingDirector4($taskInfo, $townCompany, $taskSchedulePlan); + } + } + } + + /** + * @param $totalMoney 每完成一次目标金额 + * @param $rate 实际完成率 + * 计算结算金额 全额任务金额*对应发放比例*实际完成率 + */ + private static function countTaskMarketingDirector4TaskMoney($totalMoney, $rate) + { + $taskMoney = 0; + + // =50% - %59 x40% + if (bccomp($rate, 0.5, 2) == 0 || (bccomp($rate, 0.5, 2) == 1 && bccomp($rate, 0.59, 2) == -1) || bccomp($rate, 0.59, 2) == 0) { + $taskMoney = bcmul($rate, bcmul($totalMoney, 0.4, 2), 2); + } + // =60% - %69 x50% + if (bccomp($rate, 0.6, 2) == 0 || (bccomp($rate, 0.6, 2) == 1 && bccomp($rate, 0.69, 2) == -1) || bccomp($rate, 0.69, 2) == 0) { + $taskMoney = bcmul($rate, bcmul($totalMoney, 0.5, 2), 2); + } + + // =70% - %79 x60% + if (bccomp($rate, 0.7, 2) == 0 || (bccomp($rate, 0.7, 2) == 1 && bccomp($rate, 0.79, 2) == -1) || bccomp($rate, 0.79, 2) == 0) { + $taskMoney = bcmul($rate, bcmul($totalMoney, 0.6, 2), 2); + } + + // =80% - %89 x70% + if (bccomp($rate, 0.8, 2) == 0 || (bccomp($rate, 0.8, 2) == 1 && bccomp($rate, 0.89, 2) == -1) || bccomp($rate, 0.89, 2) == 0) { + $taskMoney = bcmul($rate, bcmul($totalMoney, 0.7, 2), 2); + } + // =90%-99% x80% + if (bccomp($rate, 0.9, 2) == 0 || (bccomp($rate, 0.9, 2) == 1 && bccomp($rate, 0.99, 2) == -1) || bccomp($rate, 0.99, 2) == 0) { + $taskMoney = bcmul($rate, bcmul($totalMoney, 0.8, 2), 2); + } + // >=100% x100% + if($rate >= 1) { + $taskMoney = $totalMoney; + } + return $taskMoney; + } + + /** + * 协助供应链商户销售任务 长期 判定与结算 + */ + private static function dealTaskMarketingDirector5($taskSchedulePlan) + { + $templateInfo = $taskSchedulePlan['template_info']; + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); + // 商城商户入驻申请id 与商户已关联 + $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); + // 遍历农科公司区域下的商户,对每个商户进行判定 + foreach ($shopMerchantSettleinLogList as $item) { + + // 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算 + $startTime = strtotime(date('Y-m-d', $item['create_time'])); // 入驻当日 00:00:00 + $endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00 + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ + // 任务判定 + self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo); + } + + // 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算 + $startTime1 = $endTime; // 第一阶段 截止日 00:00:00 + $stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']); + $endTime1 = strtotime("{$stageDayTwoCount} day", $startTime); + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ + self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo); + } + + // 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算 + $startTime2 = $endTime1; // 第二阶段 截止日 00:00:00 + $stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']); + $endTime2 = strtotime("{$stageDayThreeCount} day", $startTime); + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ + self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo); + } + + // 长期 间隔天数 = 当前日期的00:00:00时间戳 - 商户入驻时间累计三个阶段天数的日期00:00:00时间戳 + $startTime3 = $endTime2; // 第三阶段 截止日 00:00:00 + $intervalDayCount = intdiv(bcsub( strtotime(date('Y-m-d', time())), $endTime2), 86400); + $endTime3 = strtotime(date('Y-m-d', time())); + // 间隔天数能整除30 表示可以结算 + if ($intervalDayCount % 30 === 0) { + $step = bcadd(3, intdiv($intervalDayCount, 30)); + self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime3, $endTime3, $step, $townCompany, $taskInfo); + } + } + // 未完成的情况下,每天自动关闭任务 + $task = Task::where(['id'=>$taskSchedulePlan['task_id']])->find(); + if ($task['status'] != 3) { + (new Task())->closeTask($task['id']); + } + } + + /** + * @param $templateInfo + * @param $item + * @param $taskSchedulePlan + * @param $startTime + * @param $endTime + * 判定任务是否完成 完成则结算分润 + */ + private static function judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, $step, $townCompany, $taskInfo) + { + // 只在截止日当天才结算 + $merIntentionId = $item['mer_intention_id']; + $directorGoodsId = $templateInfo['extend']['goods_id']; + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'mer_intention_id' => $merIntentionId, + 'goods_id' => $directorGoodsId + ]; + $result1 = ShopRequestLogic::getTradeAmount($param); + $tradeAmount = $result1['trade_amount']; // todo 返回字段要对接 + + if ($tradeAmount > 0) { + // 采购金额 实际完成率 + $rate = self::countRate($tradeAmount, $step); + + if (bccomp($rate, 0.5, 2) == -1) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } else { + $taskMoney = 0; + // 全额完成可获得的总金额 + $totalMoney = bcmul(30, bcdiv($templateInfo['money_three'], $templateInfo['extend']['target'], 2), 2); + // 已完成 计算结算金额 + if ($step == 1) { + $totalMoney = bcmul($templateInfo['stage_day_one'], bcdiv($templateInfo['money'], $templateInfo['extend']['target'], 2), 2); + } + if ($step == 2) { + $totalMoney = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'], 2), 2); + } + if ($step == 3) { + $totalMoney = bcmul(20, bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'], 2), 2) + bcmul(10, bcdiv($templateInfo['money_three'], $templateInfo['extend']['target'], 2), 2); + } + + if ($tradeAmount >= 300000) { + $taskMoney = $totalMoney; + } else { + // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 + $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); + } + $taskInfo['money'] = $taskMoney; + Log::info(['5.市场部长-供应链商户完成商品销售任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); + (new TownShareProfit())->dealTaskSettlementMarketingDirector5($taskInfo, $townCompany, $taskSchedulePlan); + } + } + } + /** + * 计算实际完成率 + */ + public static function countRate($procureAmount,$step) + { + $targetProcureAmount = 10000; + // 目标采购额每阶段增幅30% + for ($i = 1; $i < $step; $i++) { + $targetProcureAmount = self::increase($targetProcureAmount); + } + $rate = bcdiv($procureAmount, $targetProcureAmount, 2); + return $rate; + } + + /** + * 采购目标金额,增幅为30% + */ + private static function increase($value) + { + return bcmul($value, 1.3,2); + } + + /** + * @param $taskSchedulePlan + * 招驻一般商户 + * 自任务下发第60天结算, + * 15天内>=$target(目标数),100%发放 60*20=1200 + * 30天内>=$target(目标数),90%发放 60*20*90%=1080 + * 60天内>=$target(目标数),80%发放 60*20*80%=960 + * 60天内>50%$target(目标数),40%发放 60*20*40%=640 + */ + private static function dealTaskMarketingDirector6($taskSchedulePlan) + { + $templateInfo = $taskSchedulePlan['template_info']; + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); + $taskMoney = self::countTaskMarketingDirector6TaskMoney($templateInfo, $townCompany); + // 0 未到结算日期 刷新任务 -1 未完成任务,关闭任务 + if ($taskMoney == 0) { + self::flushTaskTime($taskSchedulePlan); // 刷新任务 + } else if($taskMoney == -1) { + (new Task())->closeTask($taskSchedulePlan['task_id']); // 关闭任务 + } else { + // 结算分润 + (new TownShareProfit())->dealTaskSettlementMarketingDirector6($taskInfo, $townCompany, $taskSchedulePlan); + } + + } + private static function countTaskMarketingDirector6TaskMoney($templateInfo, $townCompany) + { + $dayCount = $templateInfo['day_count']; + $totalMoney = bcmul($templateInfo['stage_day_one'], $templateInfo['money']); // 任务最多可得金额 + $target = $templateInfo['extend']['target']; + $taskMoney = 0; + if ($dayCount == $templateInfo['stage_day_one']) { + // 15 自任务下发第15天 + $startTime = $templateInfo['create_time']; + $endTime = strtotime("+15 day", $startTime); + $responsibleArea = $townCompany['responsible_area']; + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $responsibleArea, + ]; + $result = ShopRequestLogic::getGeneralMerchantCount($param); // todo 对接接口字段 + $count = $result['count']; + if ($count >= $target) { + $taskMoney = $totalMoney; + return $taskMoney; + } + // 30 自任务下发第30天 + $startTime = $templateInfo['create_time']; + $endTime = strtotime("+30 day", $startTime); + $responsibleArea = $townCompany['responsible_area']; + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $responsibleArea, + ]; + $result = ShopRequestLogic::getGeneralMerchantCount($param); // todo 对接接口字段 + $count = $result['count']; + if ($count >= $target) { + $taskMoney = bcmul($totalMoney, 0.9, 2); + return $taskMoney; + } + // 60 自任务下发第60天 + $startTime = $templateInfo['create_time']; + $endTime = strtotime("+60 day", $startTime); + $responsibleArea = $townCompany['responsible_area']; + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $responsibleArea, + ]; + $result = ShopRequestLogic::getGeneralMerchantCount($param); // todo 对接接口字段 + $count = $result['count']; + if ($count >= $target) { + $taskMoney = bcmul($totalMoney, 0.8, 2); + return $taskMoney; + } else { + $rate = bcdiv($count, $target, 1); + if (bccomp($rate, 0.5, 1) == 0 || bccomp($rate, 0.5, 1) == 1) { + $taskMoney = bcmul($totalMoney, 0.4, 2); + return $taskMoney; + } + } + $taskMoney = -1; + } + return $taskMoney; + } + + /** + * 协助一般商户商品上架和库存更新 + * 任务累计天数小于第一阶段 关闭任务不做其他操作 + * 任务累计天数==第一阶段 查询第一阶段期间入驻的商户是否完成商品上架任务 + * 任务累计天数>第一阶段 小于第一+第二阶段 关闭任务,不做其他操作 + * 任务累计天数 == 第一+第二阶段 查询第一+第二阶段期间入驻的商户是否完成商品上架任务 + * 长期 当日时间戳 - 第一+第二阶段天数 不能整除30 关闭任务,不做其他操作 + * 长期 当日时间戳 - 第一+第二阶段天数 能整除30 则查询这段时间内所有商户是否完成库存更新任务 + */ + private static function dealTaskMarketingDirector7($taskSchedulePlan) + { + $templateInfo = $taskSchedulePlan['template_info']; + $dayCount = $templateInfo['day_count']; + $stageDayOne = $templateInfo['stage_day_one']; + $stageDayTwoCount= bcadd($stageDayOne, $templateInfo['stage_day_two']); + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); + + // 任务累计天数小于第一阶段 关闭任务不做其他操作 + if ($dayCount < $stageDayOne) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + + // 任务累计天数==第一阶段 查询第一阶段期间入驻的商户是否完成商品上架任务 + if ($dayCount == $stageDayOne) { + $taskIsDone = self::judgeTaskMarketingDirector7(-$townCompany); + // 结算分润 + if($taskIsDone) { + $taskInfo['money'] = bcmul($taskIsDone, $templateInfo['money'], 2); + (new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan); + } else { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + + } + + // 任务累计天数>第一阶段 小于第一+第二阶段 关闭任务,不做其他操作 + if($dayCount > $stageDayOne && $dayCount < $stageDayTwoCount) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + + // 任务累计天数 == 第一+第二阶段 查询第一+第二阶段期间入驻的商户是否完成商品上架任务 + if ($dayCount == $stageDayTwoCount) { + $taskIsDone = self::judgeTaskMarketingDirector7($townCompany); + // 结算分润 + if($taskIsDone) { + $taskInfo['money'] = bcmul($taskIsDone, $templateInfo['money'], 2); + (new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan); + } else { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + } + + // 长期 当日时间戳 - 第一+第二阶段天数 不能整除30 关闭任务,不做其他操作 + if($dayCount > $stageDayTwoCount && $dayCount%30 != 0) { + (new Task())->closeTask($taskInfo['id']); + } + + // 长期 当日时间戳 - 第一+第二阶段天数 能整除30 则查询这段时间内所有商户是否完成库存更新任务 + if($dayCount > $stageDayTwoCount && $dayCount%30 == 0) { + $taskIsDone = true; + $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); + // 遍历农科公司区域下的商户,对每个商户进行判定 + foreach ($shopMerchantSettleinLogList as $item) { + // 库存更新 当前日期00:00:00 往前推30日 + $startTime = strtotime("-30 day", strtotime(date('Y-m-d', time()))); + $endTime = strtotime(date('Y-m-d', time())); + $merIntentionId = $item['mer_intention_id']; + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'mer_intention_id' => $merIntentionId, + ]; + // todo 返回字段要对接 + $result = ShopRequestLogic::getGeneralMerchantStockUpdate($param); + $isDone = $result['is_done']; + Log::info(['4.市场部长-一般商户完成库存更新任务-查询商城接口结果', json_encode($result)]); + // 任一商户未完成,判定为未完成 + if (!$isDone){ + $taskIsDone = false; + } + } + if($taskIsDone) { + $taskInfo['money'] = bcmul(30, $templateInfo['money_three'], 2); + (new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan); + } + } + } + + /** + * 判定一般商户是否完成任务 + */ + private static function judgeTaskMarketingDirector7($townCompany) + { + $taskIsDone = true; + // 商城商户入驻申请id 与商户已关联 + $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); + // 遍历农科公司区域下的商户,对每个商户进行判定 + foreach ($shopMerchantSettleinLogList as $item) { + // 商品上架 $startTime = $item['create_time']; // 入驻时间 - $endTime = bcadd($startTime, bcmul(86400, $template['stage_day_one'])); + $endTime = bcadd($startTime, bcmul(86400, 5)); + // 第一阶段 $merIntentionId = $item['mer_intention_id']; $param = [ 'start_time' => $startTime, 'end_time' => $endTime, 'mer_intention_id' => $merIntentionId, ]; - $result1 = ShopRequestLogic::getStockUpdate($param); // todo 返回字段要对接 + + // todo 返回字段要对接 + $result = ShopRequestLogic::getGeneralMerchantProductListing($param); + $isDone = $result['is_done']; + Log::info(['4.市场部长-一般商户完成商品上架任务-查询商城接口结果', json_encode($result)]); + // 任一商户未完成,判定为未完成 + if (!$isDone) { + $taskIsDone = false; + } + } + return $taskIsDone; + + } + + /** + * @param $taskSchedulePlan + * 督促一般商户完成采购 + * 任务累计天数 < 第一阶段 关闭任务 + * 任务累计天数 = 第一阶段 判定条件完成,结算 + * 长期 任务累计天数 > 第一阶段 且 不整除30 关闭 + * 长期 任务累计天数 > 第一阶段 且 整除30 结算 + */ + private static function dealTaskMarketingDirector8($taskSchedulePlan) + { + $templateInfo = $taskSchedulePlan['template_info']; + $dayCount = $templateInfo['day_count']; + $stageDayOne = $templateInfo['stage_day_one']; + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); + // 任务累计天数 < 第一阶段 关闭任务 + if ($dayCount < $stageDayOne) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + + // 任务累计天数 = 第一阶段 判定条件完成,结算 + if ($dayCount == $stageDayOne) { + // 第一个月 + $startTime = strtotime(date('Y-m-d', $taskInfo['create_time'])); // 任务下发当天 00:00:00 + $endTime = strtotime("+30 day", $startTime); // 30天后的00:00:00 + $taskMoney1 = self::countMonthTaskMoney($templateInfo, $townCompany, 10000, $startTime, $endTime); + + // 第二个月 + $startTime = strtotime(date('Y-m-d', $endTime)); // 第一个月截止日 00:00:00 + $endTime = strtotime("+30 day", $startTime); // 30天后的00:00:00 + $taskMoney2 = self::countMonthTaskMoney($templateInfo, $townCompany, 20000, $startTime, $endTime); + + $taskMoney = bcadd($taskMoney1, $taskMoney2, 2); + if ($taskMoney != 0) { + $taskInfo['money'] = $taskMoney; + (new TownShareProfit())->dealTaskSettlementMarketingDirector8($taskInfo, $townCompany, $taskSchedulePlan); + } else { + // 两次都等于0 关闭任务 + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + } + + // 长期 任务累计天数 > 第一阶段 且 不整除30 关闭 + if ($dayCount > $stageDayOne && $dayCount % 30 != 0) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + + // 长期 任务累计天数 > 第一阶段 且 整除30 结算 + if ($dayCount > $stageDayOne && $dayCount % 30 == 0) { + $totalMoney = bcmul(30, $templateInfo['money_three']); + $startTime = strtotime('-30 day',strtotime(date('Y-m-d', time()))); // 当前日期00:00:00 倒推30天 + $endTime = strtotime(date('Y-m-d', time())); // 当前日期00:00:00 + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $townCompany['responsible_area'], // 镇农科管理区域 + 'goods_id' => $templateInfo['extend']['goods_id'] + ]; + // todo 对接接口实际返回参数 + $result = ShopRequestLogic::getGeneralMerchantPurchaseAmount($param); + $procureAmount = $result['procure_amount']; + + $step = bcdiv(bcsub($dayCount, $stageDayOne), 30); + $target = $templateInfo['extend']['target']; + $rate = self::countRate1($procureAmount, $target, $step); // 实际完成率 + if (bccomp($rate, 0.5, 1) == -1) { + // 完成率低于50% 未完成 关闭任务 + (new Task())->closeTask($taskSchedulePlan['task_id']); + } else { + $taskMoney = 0; + if ($procureAmount >= 100000) { + $taskMoney = $totalMoney; + } else { + // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 + $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); + } + $taskInfo['money'] = $taskMoney; + (new TownShareProfit())->dealTaskSettlementMarketingDirector8($taskInfo, $townCompany, $taskSchedulePlan); + } } } + private static function countMonthTaskMoney($templateInfo, $townCompany, $targetProcureAmount, $startTime, $endTime) + { + $totalMoney = bcmul(30, $templateInfo['money']); + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $townCompany['responsible_area'], // 镇农科管理区域 + 'goods_id' => $templateInfo['extend']['goods_id'] + ]; + // todo 对接接口实际返回参数 + $result = ShopRequestLogic::getGeneralMerchantPurchaseAmount($param); + $procureAmount = $result['procure_amount']; + $rate = bcdiv($procureAmount, $targetProcureAmount, 1); + if (bccomp($rate, 0.5, 1) == -1) { + return 0; + } + $taskMoney = 0; + if ($procureAmount >= 100000) { + $taskMoney = $totalMoney; + } else { + // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 + $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); + } + return $taskMoney; + } + /** + * 计算实际完成率 + */ + public static function countRate1($procureAmount, $target, $step) + { + $targetProcureAmount = bcmul($target, 1000, 2); + // 目标采购额每阶段增幅20% + for ($i = 1; $i < $step; $i++) { + $targetProcureAmount = self::increase1($targetProcureAmount); + } + $rate = bcdiv($procureAmount, $targetProcureAmount, 2); + return $rate; + } + + /** + * 采购目标金额,增幅为30% + */ + private static function increase1($value) + { + return bcmul($value, 1.2,2); + } + + /** + * @param $taskSchedulePlan + * 督促一般商户完成销售 + * 任务累计天数 < 第一阶段 关闭任务 + * 任务累计天数 = 第一阶段 判定条件完成,计算任务金额,分润结算 + * 长期 任务累计天数 > 第一阶段 且 不整除30 关闭 + * 长期 任务累计天数 > 第一阶段 且 整除30 计算任务金额,分润结算 + */ + private static function dealTaskMarketingDirector9($taskSchedulePlan) + { + $templateInfo = $taskSchedulePlan['template_info']; + $dayCount = $templateInfo['day_count']; + $stageDayOne = $templateInfo['stage_day_one']; + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); + + // 任务累计天数 < 第一阶段 关闭任务 + if ($dayCount < $stageDayOne) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + + // 任务累计天数 = 第一阶段 判定条件完成,计算任务金额,分润结算 + if ($dayCount == $stageDayOne) { + // 第一个月 + $startTime = strtotime(date('Y-m-d', $taskInfo['create_time'])); // 任务下发当天 00:00:00 + $endTime = strtotime("+30 day", $startTime); // 30天后的00:00:00 + $taskMoney1 = self::countTradeAmountMonthTaskMoney($templateInfo, $townCompany, 10000, $startTime, $endTime); + + // 第二个月 + $startTime = strtotime(date('Y-m-d', $endTime)); // 第一个月截止日 00:00:00 + $endTime = strtotime("+30 day", $startTime); // 30天后的00:00:00 + $taskMoney2 = self::countTradeAmountMonthTaskMoney($templateInfo, $townCompany, 20000, $startTime, $endTime); + + $taskMoney = bcadd($taskMoney1, $taskMoney2, 2); + if ($taskMoney != 0) { + $taskInfo['money'] = $taskMoney; + (new TownShareProfit())->dealTaskSettlementMarketingDirector8($taskInfo, $townCompany, $taskSchedulePlan); + } else { + // 两次都等于0 关闭任务 + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + } + + // 长期 任务累计天数 > 第一阶段 且 不整除30 关闭 + if ($dayCount > $stageDayOne && $dayCount % 30 != 0) { + (new Task())->closeTask($taskSchedulePlan['task_id']); + } + // 长期 任务累计天数 > 第一阶段 且 整除30 计算任务金额,分润结算 + if ($dayCount > $stageDayOne && $dayCount % 30 == 0) { + $totalMoney = bcmul(30, $templateInfo['money_three']); + $startTime = strtotime('-30 day',strtotime(date('Y-m-d', time()))); // 当前日期00:00:00 倒推30天 + $endTime = strtotime(date('Y-m-d', time())); // 当前日期00:00:00 + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $townCompany['responsible_area'], // 镇农科管理区域 + 'goods_id' => $templateInfo['extend']['goods_id'] + ]; + // todo 对接接口实际返回参数 + $result = ShopRequestLogic::getGeneralMerchantPurchaseAmount($param); + $procureAmount = $result['procure_amount']; + + $step = bcdiv(bcsub($dayCount, $stageDayOne), 30); + $target = $templateInfo['extend']['target']; + $rate = self::countRate1($procureAmount, $target, $step); // 实际完成率 + if (bccomp($rate, 0.5, 1) == -1) { + // 完成率低于50% 未完成 关闭任务 + (new Task())->closeTask($taskSchedulePlan['task_id']); + } else { + $taskMoney = 0; + if ($procureAmount >= 100000) { + $taskMoney = $totalMoney; + } else { + // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 + $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); + } + $taskInfo['money'] = $taskMoney; + (new TownShareProfit())->dealTaskSettlementMarketingDirector8($taskInfo, $townCompany, $taskSchedulePlan); + } + } + } + + private static function countTradeAmountMonthTaskMoney($templateInfo, $townCompany, $targetProcureAmount, $startTime, $endTime) + { + $totalMoney = bcmul(30, $templateInfo['money']); + $param = [ + 'start_time' => $startTime, + 'end_time' => $endTime, + 'responsible_area' => $townCompany['responsible_area'], // 镇农科管理区域 + 'goods_id' => $templateInfo['extend']['goods_id'] + ]; + // todo 对接接口实际返回参数 + $result = ShopRequestLogic::getGeneralMerchantTradeAmount($param); + $procureAmount = $result['procure_amount']; + $rate = bcdiv($procureAmount, $targetProcureAmount, 1); + if (bccomp($rate, 0.5, 1) == -1) { + return 0; + } + $taskMoney = 0; + if ($procureAmount >= 100000) { + $taskMoney = $totalMoney; + } else { + // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 + $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); + } + return $taskMoney; + } + private static function dealTaskMarketingDirector10($taskSchedulePlan) + { + + } /** * @param $taskSchedulePlan * 服务部长任务结算