This commit is contained in:
chenbo 2023-11-20 17:10:46 +08:00
parent 20d01ac6d9
commit d7a76319af

View File

@ -863,32 +863,50 @@ class TaskLogic extends BaseLogic
} }
} }
// 判断收集任务,整体是否已完成
if ($dayCount == 60) {
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
$purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']);
$rate = bcdiv($purchaseSalesCount, $target, 2);
if ($rate >= 1) {
$rate = 1;
}
$totalMoney = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2),55, 2);
$taskInfo['money'] = bcmul($totalMoney, $rate, 2);
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool);
}
// 任务累计天数 大于 第一阶段 小于第一+第二阶段 判断交易任务是否完成,完成则结算,否则关闭任务 // 任务累计天数 大于 第一阶段 小于第一+第二阶段 判断交易任务是否完成,完成则结算,否则关闭任务
if ($dayCount > $taskTemplateInfo['stage_day_one'] && $dayCount < $stageDayTwoCount) { if ($dayCount > $taskTemplateInfo['stage_day_one'] && $dayCount < $stageDayTwoCount) {
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info']; $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
$purchaseSalesCount = bcadd(count($purchaseSalesInfo['planting']), count($purchaseSalesInfo['supply'])); $purchaseSalesCount = bcadd(count($purchaseSalesInfo['planting']), count($purchaseSalesInfo['supply']));
// 判断交易任务是否完成 // 判断交易任务是否完成
self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount); self::judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount);
} }
// 任务累计天数 = 第一+第二阶段 判断信息收集和交易任务是否完成,完成则结算,否则关闭任务 // 任务累计天数 = 第一+第二阶段 判断信息收集和交易任务是否完成,完成则结算,否则关闭任务
if ($dayCount == $stageDayTwoCount) { // if ($dayCount == $stageDayTwoCount) {
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info']; // $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
$purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']); // $purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']);
if ($purchaseSalesCount >= $target) { // if ($purchaseSalesCount >= $target) {
$taskInfo['money'] = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2), $taskTemplateInfo['stage_day_two'], 2); // $taskInfo['money'] = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2), $taskTemplateInfo['stage_day_two'], 2);
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool); // (new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool);
} // }
} // }
// 任务累计天数 大于 第一+第二阶段 每日结算 判断交易任务是否完成,完成则结算,否则关闭任务 // 任务累计天数 大于 第一+第二阶段 每日结算 判断交易任务是否完成,完成则结算,否则关闭任务
if ($dayCount >= $stageDayTwoCount) { if ($dayCount >= $stageDayTwoCount) {
// 判断交易任务是否完成 // 判断交易任务是否完成
self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target); self::judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target);
} }
} }
private static function judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target) private static function judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target)
{ {
// 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易) // 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易)
$phoneList = []; $phoneList = [];
@ -903,12 +921,18 @@ class TaskLogic extends BaseLogic
'end_time' => strtotime(date('Y-m-d', time())) + 86399, 'end_time' => strtotime(date('Y-m-d', time())) + 86399,
'phone' => implode(',', $phoneList) 'phone' => implode(',', $phoneList)
]; ];
$result = ShopRequestLogic::getUserTradeAmount($param); // todo 对接接口
$tradeAmount = $result['data']['procure_amount']; $result = ShopRequestLogic::getUserTradeAmount($param);
if(isset($result['status']) && $result['status']== 400) {
$tradeAmount = 0;
}
if(isset($result['status']) && $result['status']== 200) {
$tradeAmount = $result['data']['trade_amount'];
}
$totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池 $totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池
// 目标金额 = 274 * 收集用户数 // 目标金额 = 274 * 收集用户数
$targetTradeAmount = bcmul($target, 274, 2); $targetTradeAmount = bcmul($target, 274, 2);
@ -946,8 +970,9 @@ class TaskLogic extends BaseLogic
'responsible_area' => $townCompany['responsible_area'], 'responsible_area' => $townCompany['responsible_area'],
'type' => 'street', 'type' => 'street',
]; ];
$result = ShopRequestLogic::getTownTradeAmount($param); // todo 对接接口 $result = ShopRequestLogic::getTownTradeAmount($param);
$tradeAmount = $result['data']['procure_amount'];
$tradeAmount = $result['data']['trade_amount'];
// 总交易额 交易池金额+商城交易额 // 总交易额 交易池金额+商城交易额
$totalAmount = bcadd($townTransactionPool, $tradeAmount, 2); $totalAmount = bcadd($townTransactionPool, $tradeAmount, 2);
@ -1237,17 +1262,21 @@ class TaskLogic extends BaseLogic
// 当前任务进行天数 = 第一阶段天数 判定任务完成情况,结算 // 当前任务进行天数 = 第一阶段天数 判定任务完成情况,结算
if ($dayCount == $templateInfo['stage_day_one']) { if ($dayCount == $templateInfo['stage_day_one']) {
// 请求商城接口,获取完成几家 // 请求商城接口,获取完成几家
$param['start_time'] = strtotime(date('Y-m-d', $templateInfo['cretate_time'])) + 86400; $param['start_time'] = strtotime(date('Y-m-d', strtotime($templateInfo['create_time']))) + 86400;
$param['end_time'] = time(); $param['end_time'] = time();
$param['responsible_area'] = $townCompany['responsible_area']; $param['responsible_area'] = $townCompany['responsible_area'];
$param['type'] = 'street'; $param['type'] = 'street';
$param['type_id'] = 17; $param['type_id'] = 17;
$result = ShopRequestLogic::getSupplyChainMerchantCount($param); $result = ShopRequestLogic::getSupplyChainMerchantCount($param);
if ($result['status'] != 200) { if ($result['status'] != 200) {
Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError()); Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError());
return false; $count = 0;
} } else {
$count = $result['data']['count']; $count = $result['data']['count'];
}
// 完成数小于3关闭任务不做结算 // 完成数小于3关闭任务不做结算
if ($count < 3){ if ($count < 3){
@ -1279,6 +1308,7 @@ class TaskLogic extends BaseLogic
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
// 商城商户入驻申请id 与商户已关联 // 商城商户入驻申请id 与商户已关联
$shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray();
// 遍历农科公司区域下的商户,对每个商户进行判定 // 遍历农科公司区域下的商户,对每个商户进行判定
foreach ($shopMerchantSettleinLogList as $item) { foreach ($shopMerchantSettleinLogList as $item) {
@ -1294,12 +1324,16 @@ class TaskLogic extends BaseLogic
'mer_intention_id' => $merIntentionId, 'mer_intention_id' => $merIntentionId,
'type_id' => 17, 'type_id' => 17,
]; ];
$result = ShopRequestLogic::getProductListing($param); $result = ShopRequestLogic::getProductListing($param);
if ($result['status'] != 200) { if ($result['status'] != 200) {
Log::info(['4.市场部长-供应链商户完成商品上架和库存更新任务-查询商城接口失败', json_encode($result)]); Log::info(['4.市场部长-供应链商户完成商品上架和库存更新任务-查询商城接口失败', json_encode($result)]);
return false; $count = 0;
} } else {
$count = $result['data']['count']; $count = $result['data']['count'];
}
// 达到目标数 完成则结算 // 达到目标数 完成则结算
if ($count >= $templateInfo['extend']['target']){ if ($count >= $templateInfo['extend']['target']){
// 结算金额 任务金额/目标数 * 天数 // 结算金额 任务金额/目标数 * 天数
@ -1323,11 +1357,14 @@ class TaskLogic extends BaseLogic
'type_id' => 17 'type_id' => 17
]; ];
$result1 = ShopRequestLogic::getStockUpdate($param); $result1 = ShopRequestLogic::getStockUpdate($param);
if ($result1['status'] != 200) { if ($result1['status'] != 200) {
Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result)]); Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result)]);
return false; $count = 0;
} } else {
$count = $result1['data']['count']; $count = $result1['data']['count'];
}
if ($count >= 1){ if ($count >= 1){
// 结算金额 任务金额/目标数 * 天数 // 结算金额 任务金额/目标数 * 天数
$taskInfo['money'] = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'])); $taskInfo['money'] = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target']));
@ -1355,12 +1392,14 @@ class TaskLogic extends BaseLogic
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
// 商城商户入驻申请id 与商户已关联 // 商城商户入驻申请id 与商户已关联
$shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray();
// 遍历农科公司区域下的商户,对每个商户进行判定 // 遍历农科公司区域下的商户,对每个商户进行判定
foreach ($shopMerchantSettleinLogList as $item) { foreach ($shopMerchantSettleinLogList as $item) {
// 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算 // 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算
$startTime = strtotime(date('Y-m-d', strtotime($item['create_time']))); // 入驻当日 00:00:00 $startTime = strtotime(date('Y-m-d', strtotime($item['create_time']))); // 入驻当日 00:00:00
$endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 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())){ if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
// 任务判定 // 任务判定
self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo); self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo);
@ -1369,7 +1408,7 @@ class TaskLogic extends BaseLogic
// 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算 // 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算
$startTime1 = $endTime; // 第一阶段 截止日 00:00:00 $startTime1 = $endTime; // 第一阶段 截止日 00:00:00
$stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']); $stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']);
$endTime1 = strtotime("{$stageDayTwoCount} day", $startTime); $endTime1 = strtotime("+{$stageDayTwoCount} day", $startTime);
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo); self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo);
} }
@ -1377,7 +1416,7 @@ class TaskLogic extends BaseLogic
// 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算 // 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算
$startTime2 = $endTime1; // 第二阶段 截止日 00:00:00 $startTime2 = $endTime1; // 第二阶段 截止日 00:00:00
$stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']); $stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']);
$endTime2 = strtotime("{$stageDayThreeCount} day", $startTime); $endTime2 = strtotime("+{$stageDayThreeCount} day", $startTime);
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo); self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo);
} }
@ -1422,10 +1461,10 @@ class TaskLogic extends BaseLogic
$result1 = ShopRequestLogic::getPurchaseAmount($param); $result1 = ShopRequestLogic::getPurchaseAmount($param);
if ($result1['status'] != 200) { if ($result1['status'] != 200) {
Log::info(['4.市场部长-协助供应链商户采购任务-查询商城接口失败', json_encode($result1)]); Log::info(['4.市场部长-协助供应链商户采购任务-查询商城接口失败', json_encode($result1)]);
return false; $result1['data']['procure_amount'] = 0;
} }
if ($result1['data']['procure_amount'] > 0) { if ($result1['data']['procure_amount'] > 0) {
$procureAmount = $result1['procure_amount']; $procureAmount = $result1['data']['procure_amount'];
// 采购金额 实际完成率 // 采购金额 实际完成率
$rate = self::countRate($procureAmount, $step); $rate = self::countRate($procureAmount, $step);
@ -1453,12 +1492,6 @@ class TaskLogic extends BaseLogic
$taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate);
} }
$taskInfo['money'] = $taskMoney; $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)]); Log::info(['5.市场部长-供应链商户完成采购任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]);
(new TownShareProfit())->dealTaskSettlementMarketingDirector4($taskInfo, $townCompany, $taskSchedulePlan); (new TownShareProfit())->dealTaskSettlementMarketingDirector4($taskInfo, $townCompany, $taskSchedulePlan);
} }