fixed 村联络员任务-种养殖基地订单匹配 改为每日结算。新增log,记录请求商城接口返回情况。
This commit is contained in:
parent
5aca95ef79
commit
ebdfc81b16
@ -927,6 +927,7 @@ class TaskLogic extends BaseLogic
|
||||
}
|
||||
if(isset($result['status']) && $result['status']== 200) {
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
Log::info(['4.负责人-信息收集与促销-查询商城返回-交易额', $tradeAmount]);
|
||||
}
|
||||
|
||||
$totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池
|
||||
@ -972,7 +973,7 @@ class TaskLogic extends BaseLogic
|
||||
$result = ShopRequestLogic::getTownTradeAmount($param);
|
||||
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
|
||||
Log::info(['4.负责人-督促种养殖商户和供应链商户交易-查询商城返回-销售额', $tradeAmount]);
|
||||
// 总交易额 交易池金额+商城交易额
|
||||
$totalAmount = bcadd($townTransactionPool, $tradeAmount, 2);
|
||||
|
||||
@ -1275,11 +1276,13 @@ class TaskLogic extends BaseLogic
|
||||
|
||||
$result = ShopRequestLogic::getSupplyChainMerchantCount($param);
|
||||
|
||||
|
||||
if ($result['status'] != 200) {
|
||||
Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError());
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = $result['data']['count'];
|
||||
Log::info(['招驻供应链商户-查询供应链商户统计接口-统计值', $result]);
|
||||
}
|
||||
|
||||
|
||||
@ -1339,6 +1342,7 @@ class TaskLogic extends BaseLogic
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = $result['data']['count'];
|
||||
Log::info(['市场部长-供应链商户完成商品上架任务-查询商城接口-返回', json_encode($result)]);
|
||||
}
|
||||
|
||||
// 达到目标数 完成则结算
|
||||
@ -1366,10 +1370,11 @@ class TaskLogic extends BaseLogic
|
||||
$result1 = ShopRequestLogic::getStockUpdate($param);
|
||||
|
||||
if ($result1['status'] != 200) {
|
||||
Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result)]);
|
||||
Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result1)]);
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = $result1['data']['count'];
|
||||
Log::info(['市场部长-供应链商户完成库存更新任务-查询商城接口-返回', json_encode($result1)]);
|
||||
}
|
||||
|
||||
if ($count >= 1){
|
||||
@ -1472,6 +1477,7 @@ class TaskLogic extends BaseLogic
|
||||
Log::info(['4.市场部长-协助供应链商户采购任务-查询商城接口失败', json_encode($result1)]);
|
||||
$result1['data']['procure_amount'] = 0;
|
||||
}
|
||||
Log::info(['4.市场部长-协助供应链商户采购任务-查询商城接口-返回', $result1['data']['procure_amount']]);
|
||||
if ($result1['data']['procure_amount'] > 0) {
|
||||
$procureAmount = $result1['data']['procure_amount'];
|
||||
// 采购金额 实际完成率
|
||||
@ -1625,6 +1631,7 @@ class TaskLogic extends BaseLogic
|
||||
$result1 = ShopRequestLogic::getTradeAmount($param);
|
||||
if ($result1['status'] == 200) {
|
||||
$tradeAmount = $result1['data']['procure_amount'];
|
||||
Log::info(['4.市场部长-协助供应链商户销售任务-查询商城返回-交易额', $tradeAmount]);
|
||||
} else {
|
||||
Log::info(['4.市场部长-协助供应链商户销售任务-查询商城接口失败', json_encode($result1)]);
|
||||
$tradeAmount = 0;
|
||||
@ -1738,6 +1745,7 @@ class TaskLogic extends BaseLogic
|
||||
$result = ShopRequestLogic::getGeneralMerchantCount($param);
|
||||
if ($result['status'] == 200) {
|
||||
$count = $result['data']['count'];
|
||||
Log::info(['4.市场部长-招驻一般商户-查询商城返回-户数', $count]);
|
||||
} else {
|
||||
$count = 0;
|
||||
}
|
||||
@ -1761,6 +1769,7 @@ class TaskLogic extends BaseLogic
|
||||
$result = ShopRequestLogic::getGeneralMerchantCount($param);
|
||||
Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError());
|
||||
$count = $result['data']['count'];
|
||||
Log::info(['4.市场部长-招驻一般商户-查询商城返回-户数', $count]);
|
||||
if ($count >= $target) {
|
||||
$taskMoney = bcmul($totalMoney, 0.9, 2);
|
||||
return $taskMoney;
|
||||
@ -1780,6 +1789,7 @@ class TaskLogic extends BaseLogic
|
||||
$result = ShopRequestLogic::getGeneralMerchantCount($param);
|
||||
Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError());
|
||||
$count = $result['data']['count'];
|
||||
Log::info(['4.市场部长-招驻一般商户-查询商城返回-户数', $count]);
|
||||
if ($count >= $target) {
|
||||
$taskMoney = bcmul($totalMoney, 0.8, 2);
|
||||
return $taskMoney;
|
||||
@ -1908,7 +1918,7 @@ class TaskLogic extends BaseLogic
|
||||
];
|
||||
|
||||
$result = ShopRequestLogic::getGeneralMerchantProductListing($param);
|
||||
Log::info(['4.市场部长-一般商户完成商品上架任务-查询商城接口结果失败', json_encode($result)]);
|
||||
Log::info(['4.市场部长-一般商户完成商品上架任务-查询商城接口结果', json_encode($result)]);
|
||||
$count = $result['data']['count'];
|
||||
// 任一商户未完成,判定为未完成
|
||||
if ($count < 200) {
|
||||
@ -1982,7 +1992,7 @@ class TaskLogic extends BaseLogic
|
||||
];
|
||||
$result = ShopRequestLogic::getGeneralMerchantPurchaseAmount($param);
|
||||
$procureAmount = $result['data']['procure_amount'];
|
||||
|
||||
Log::info(['4.市场部长-督促一般商户完成采购-查询商城返回-采购额', $procureAmount]);
|
||||
$step = bcdiv(bcsub($dayCount, $stageDayOne), 30);
|
||||
$target = $templateInfo['extend']['target'];
|
||||
$rate = self::countRate1($procureAmount, $target, $step); // 实际完成率
|
||||
@ -2017,6 +2027,7 @@ class TaskLogic extends BaseLogic
|
||||
];
|
||||
$result = ShopRequestLogic::getGeneralMerchantPurchaseAmount($param);
|
||||
$procureAmount = $result['data']['procure_amount'];
|
||||
Log::info(['4.市场部长-督促一般商户完成采购-查询商城返回-采购额', $procureAmount]);
|
||||
$rate = bcdiv($procureAmount, $targetProcureAmount, 1);
|
||||
if (bccomp($rate, 0.5, 1) == -1) {
|
||||
return 0;
|
||||
@ -2115,7 +2126,7 @@ class TaskLogic extends BaseLogic
|
||||
];
|
||||
$result = ShopRequestLogic::getGeneralMerchantPurchaseAmount($param);
|
||||
$procureAmount = $result['data']['procure_amount'];
|
||||
|
||||
Log::info(['4.市场部长-督促一般商户完成采购-查询商城返回-采购额', $procureAmount]);
|
||||
$step = bcdiv(bcsub($dayCount, $stageDayOne), 30);
|
||||
$target = $templateInfo['extend']['target'];
|
||||
$rate = self::countRate1($procureAmount, $target, $step); // 实际完成率
|
||||
@ -2150,6 +2161,7 @@ class TaskLogic extends BaseLogic
|
||||
];
|
||||
$result = ShopRequestLogic::getGeneralMerchantTradeAmount($param);
|
||||
$tradeAmount = $result['data']['procure_amount'];
|
||||
Log::info(['4.市场部长-督促一般商户完成销售-查询商城返回-销售额', $tradeAmount]);
|
||||
$rate = bcdiv($tradeAmount, $targetProcureAmount, 1);
|
||||
if (bccomp($rate, 0.5, 1) == -1) {
|
||||
return 0;
|
||||
@ -2753,7 +2765,7 @@ class TaskLogic extends BaseLogic
|
||||
public static function villageTaskSettlement($taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Log::info(['存管理公司定时任务结算执行-任务计划', $taskSchedulePlan]);
|
||||
Log::info(['村管理公司定时任务结算执行-任务计划', $taskSchedulePlan]);
|
||||
$taskTemplateInfo = $taskSchedulePlan['template_info'];
|
||||
// 任务类型用的数据字典主键id,将id和value作映射,避免测试和正式环境数据字典数据不一致时出问题
|
||||
$villageTaskTypeList = DictData::where(['type_value' => 'village_task_type', 'status' => 1])->column('value', 'id');
|
||||
@ -3061,15 +3073,12 @@ class TaskLogic extends BaseLogic
|
||||
|
||||
/**
|
||||
* @param $taskSchedulePlan
|
||||
* 种养殖基地订单匹配
|
||||
* 任务累计天数 < stage1 关闭任务
|
||||
* 任务累计天数 = stage1 从商城查询种养殖商户的交易额,判定是否完成任务,完成则结算
|
||||
* 任务累计天数 < stage1+stage2 关闭任务,不结算
|
||||
* 任务累计天数 = stage1+stage2 从商城查询种养殖商户的交易额,判定是否完成任务,完成则结算
|
||||
* 任务累计天数 < stage1 + stage2 + stage3 关闭任务,不结算
|
||||
* 任务累计天数 = stage1 + stage2 + stage3 从商城查询种养殖商户的交易额,判定是否完成任务,完成
|
||||
* 任务累计天数 - (stage1 + stage2 + stage3) 不能整除30 关闭任务
|
||||
* 任务累计天数 - (stage1 + stage2 + stage3) 整除30 从商城查询种养殖商户的交易额,判定是否完成任务,完成
|
||||
* 种养殖基地订单匹配 每日结算,阶段不同,目标金额不同,任务金额不同
|
||||
* 第一考核周期每日目标金额 434,第二考核周期每日目标金额 567.
|
||||
* 任务累计天数 <= stage1 从商城查询种养殖商户的交易额,判定是否完成第一考核周期的每日目标金额,完成则结算第一阶段的任务金额
|
||||
* stage1 < 任务累计天数 <= stage1+stage2 从商城查询种养殖商户的交易额,判定是否完成第二考核周期的每日目标金额,完成则结算第二阶段的任务金额
|
||||
* stage1+stage2 < 任务累计天数 <= stage1 + stage2 + stage3 从商城查询种养殖商户的交易额,判定是否完成第二考核周期的每日目标金额,完成则结算第三阶段的任务金额
|
||||
* 任务累计天数 > (stage1 + stage2 + stage3) 从商城查询种养殖商户的交易额,从商城查询种养殖商户的交易额,判定是否完成第二考核周期的每日目标金额,完成则结算长期阶段的任务金额
|
||||
*/
|
||||
private static function dealVillageTask7($taskSchedulePlan)
|
||||
{
|
||||
@ -3081,53 +3090,46 @@ class TaskLogic extends BaseLogic
|
||||
$stageDayThreeCount = bcadd($stageDayTwoCount, $taskTemplateInfo['stage_day_three']);
|
||||
$villageCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
|
||||
|
||||
|
||||
$startTime = strtotime(date('Y-m-d',time())); // 当天00:00:00
|
||||
$endTime = $startTime + 86399;
|
||||
// 任务累计天数 < stage1 关闭任务
|
||||
if ($dayCount < $stageDayOne) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// if ($dayCount < $stageDayOne) {
|
||||
// (new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
// }
|
||||
|
||||
// 任务累计天数 = stage1 从商城查询种养殖商户的交易额,判定是否完成任务,完成则结算
|
||||
if ($dayCount == $stageDayOne) {
|
||||
$startTime = strtotime(date('Y-m-d',strtotime($taskTemplateInfo['create_time'])))+86400; // 创建任务的第二天00:00:00开始
|
||||
$endTime = strtotime('+30 day', $startTime);
|
||||
self::finishVillageTask7($startTime, $endTime, 13000, $taskTemplateInfo['stage_day_one'], $taskTemplateInfo['money'], $villageCompany, $taskSchedulePlan);
|
||||
// 任务累计天数 <= stage1 从商城查询种养殖商户的交易额,判定是否完成第一阶段的每日目标金额,完成则结算第一阶段的任务金额
|
||||
if ($dayCount <= $stageDayOne) {
|
||||
self::finishVillageTask7($startTime, $endTime, 434, $taskTemplateInfo['stage_day_one'], $taskTemplateInfo['money'], $villageCompany, $taskSchedulePlan);
|
||||
}
|
||||
|
||||
// 任务累计天数 < stage1+stage2 关闭任务,不结算
|
||||
if ($dayCount < $stageDayTwoCount) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// if ($dayCount < $stageDayTwoCount) {
|
||||
// (new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
// }
|
||||
|
||||
// 任务累计天数 = stage1+stage2 从商城查询种养殖商户的交易额,判定是否完成任务,完成则结算
|
||||
if ($dayCount == $stageDayTwoCount) {
|
||||
$startTime = strtotime('-30 day', $endTime);
|
||||
$endTime = strtotime(date('Y-m-d', time()));
|
||||
self::finishVillageTask7($startTime, $endTime, 17000, $taskTemplateInfo['stage_day_two'], $taskTemplateInfo['money_two'], $villageCompany, $taskSchedulePlan);
|
||||
// stage1 < 任务累计天数 <= stage1+stage2 从商城查询种养殖商户的交易额,判定是否完成第二考核周期的每日目标金额,完成则结算第二阶段的任务金额
|
||||
if ($stageDayOne < $dayCount && $dayCount <= $stageDayTwoCount) {
|
||||
self::finishVillageTask7($startTime, $endTime, 567, $taskTemplateInfo['stage_day_two'], $taskTemplateInfo['money_two'], $villageCompany, $taskSchedulePlan);
|
||||
}
|
||||
|
||||
// 任务累计天数 < stage1 + stage2 + stage3 关闭任务,不结算
|
||||
if ($dayCount < $stageDayThreeCount) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// if ($dayCount < $stageDayThreeCount) {
|
||||
// (new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
// }
|
||||
|
||||
// 任务累计天数 = stage1 + stage2 + stage3 从商城查询种养殖商户的交易额,判定是否完成任务,完成
|
||||
if ($dayCount == $stageDayThreeCount) {
|
||||
$startTime = strtotime('-30 day', $endTime);
|
||||
$endTime = strtotime(date('Y-m-d', time()));
|
||||
self::finishVillageTask7($startTime, $endTime, 17000, $taskTemplateInfo['stage_day_three'], $taskTemplateInfo['new_money_three'], $villageCompany, $taskSchedulePlan);
|
||||
// stage1+stage2 < 任务累计天数 <= stage1 + stage2 + stage3 从商城查询种养殖商户的交易额,判定是否完成第二考核周期的每日目标金额,完成则结算第三阶段的任务金额
|
||||
if ($stageDayTwoCount < $dayCount && $dayCount <= $stageDayThreeCount) {
|
||||
self::finishVillageTask7($startTime, $endTime, 567, $taskTemplateInfo['stage_day_three'], $taskTemplateInfo['new_money_three'], $villageCompany, $taskSchedulePlan);
|
||||
}
|
||||
|
||||
// 任务累计天数 - (stage1 + stage2 + stage3) 不能整除30 关闭任务
|
||||
if ($dayCount > $stageDayThreeCount && $dayCount % 30 != 0) {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// if ($dayCount > $stageDayThreeCount && $dayCount % 30 != 0) {
|
||||
// (new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
// }
|
||||
|
||||
// 任务累计天数 - (stage1 + stage2 + stage3) 整除30 从商城查询种养殖商户的交易额,,判定是否完成任务,完成
|
||||
if ($dayCount > $stageDayThreeCount && $dayCount % 30 == 0) {
|
||||
$startTime = strtotime('-30 day', $endTime);
|
||||
$endTime = strtotime(date('Y-m-d', time()));
|
||||
self::finishVillageTask7($startTime, $endTime, 17000, 30, $taskTemplateInfo['money_three'], $villageCompany, $taskSchedulePlan);
|
||||
// 任务累计天数 > (stage1 + stage2 + stage3) 从商城查询种养殖商户的交易额,从商城查询种养殖商户的交易额,判定是否完成第二考核周期的每日目标金额,完成则结算长期阶段的任务金额
|
||||
if ($dayCount > $stageDayThreeCount) {
|
||||
self::finishVillageTask7($startTime, $endTime, 567, 30, $taskTemplateInfo['money_three'], $villageCompany, $taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3149,14 +3151,15 @@ class TaskLogic extends BaseLogic
|
||||
'village' => $villageCompany['village'],
|
||||
|
||||
];
|
||||
$result = ShopRequestLogic::getPlantingAndBreedingMerchantTradeAmount($param); // todo 商城接口那边需要确定种养殖基地是何种类型的商户
|
||||
$result = ShopRequestLogic::getPlantingAndBreedingMerchantTradeAmount($param);
|
||||
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
Log::info(['村管理公司定时任务结算执行-种养殖基地订单匹配-交易额', $tradeAmount]);
|
||||
// 交易池
|
||||
$transactionPool = $taskSchedulePlan['template_info']['transaction_pool'];
|
||||
$totalTradeAmount = bcadd($transactionPool, $tradeAmount, 2);
|
||||
if ($totalTradeAmount >= $targetAmount) {
|
||||
$task['money'] = bcmul($dayNum, $perMoney, 2);
|
||||
$task['money'] = $perMoney;
|
||||
$leftTransactionPool = bcsub($totalTradeAmount, $targetAmount, 2);
|
||||
(new VillageShareProfit())->dealVillageTaskSettlement7($task, $villageCompany, $taskSchedulePlan, $leftTransactionPool);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user