update 任务3结算
This commit is contained in:
parent
0c36e8dbc0
commit
ee78dc4a7d
@ -846,37 +846,10 @@ class TaskLogic extends BaseLogic
|
||||
|
||||
// 任务累计天数 大于 第一阶段 小于第一+第二阶段 判断交易任务是否完成,完成则结算,否则关闭任务
|
||||
if ($dayCount > $taskTemplateInfo['stage_day_one'] && $dayCount < $stageDayTwoCount) {
|
||||
// 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易)
|
||||
$phoneList = [];
|
||||
foreach ($purchaseSalesInfo['planting'] as $item) {
|
||||
$phoneList[] = $item['phone'];
|
||||
}
|
||||
foreach ($purchaseSalesInfo['supply'] as $item) {
|
||||
$phoneList[] = $item['shopkeeperPhone'];
|
||||
}
|
||||
$param = [
|
||||
'start_time' => strtotime(date('Y-m-d', time())),
|
||||
'end_time' => strtotime(date('Y-m-d', time())) + 86399,
|
||||
'phone' => implode(',', $phoneList)
|
||||
];
|
||||
$result = ShopRequestLogic::getUserTradeAmount($param); // todo 对接接口
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
|
||||
$totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池
|
||||
|
||||
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
|
||||
$purchaseSalesCount = bcadd(count($purchaseSalesInfo['planting']), count($purchaseSalesInfo['supply']));
|
||||
// 目标金额 = 274 * 收集用户数
|
||||
$targetTradeAmount = bcmul($purchaseSalesCount, 274, 2);
|
||||
|
||||
// 完成条件: 交易金额 >= 目标金额
|
||||
if (bccomp($totalAmount, $targetTradeAmount, 2) ==0 || bccomp($totalAmount, $targetTradeAmount, 2) ==1) {
|
||||
$taskInfo['money'] = bcdiv($taskTemplateInfo['money_two'], 2, 2);
|
||||
$leftTransactionPool = bcsub($totalAmount, $targetTradeAmount, 2);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $leftTransactionPool);
|
||||
} else {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// 判断交易任务是否完成
|
||||
self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount);
|
||||
}
|
||||
|
||||
// 任务累计天数 = 第一+第二阶段 判断信息收集和交易任务是否完成,完成则结算,否则关闭任务
|
||||
@ -891,37 +864,43 @@ class TaskLogic extends BaseLogic
|
||||
|
||||
// 任务累计天数 大于 第一+第二阶段 每日结算 判断交易任务是否完成,完成则结算,否则关闭任务
|
||||
if ($dayCount >= $stageDayTwoCount) {
|
||||
// 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易)
|
||||
$phoneList = [];
|
||||
foreach ($purchaseSalesInfo['planting'] as $item) {
|
||||
$phoneList[] = $item['phone'];
|
||||
}
|
||||
foreach ($purchaseSalesInfo['supply'] as $item) {
|
||||
$phoneList[] = $item['shopkeeperPhone'];
|
||||
}
|
||||
$param = [
|
||||
'start_time' => strtotime(date('Y-m-d', time())),
|
||||
'end_time' => strtotime(date('Y-m-d', time())) + 86399,
|
||||
'phone' => implode(',', $phoneList)
|
||||
];
|
||||
$result = ShopRequestLogic::getUserTradeAmount($param); // todo 对接接口
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
|
||||
$totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池
|
||||
|
||||
// 目标金额 = 274 * 总目标数
|
||||
$targetTradeAmount = bcmul($target, 274, 2);
|
||||
|
||||
// 完成条件: 交易金额 >= 目标金额
|
||||
if (bccomp($totalAmount, $targetTradeAmount, 2) ==0 || bccomp($totalAmount, $targetTradeAmount, 2) ==1) {
|
||||
$taskInfo['money'] = bcdiv($taskTemplateInfo['money_two'], 2, 2);
|
||||
$leftTransactionPool = bcsub($totalAmount, $targetTradeAmount, 2);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $leftTransactionPool);
|
||||
} else {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
// 判断交易任务是否完成
|
||||
self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target);
|
||||
}
|
||||
}
|
||||
|
||||
private static function judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target)
|
||||
{
|
||||
// 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易)
|
||||
$phoneList = [];
|
||||
foreach ($purchaseSalesInfo['planting'] as $item) {
|
||||
$phoneList[] = $item['phone'];
|
||||
}
|
||||
foreach ($purchaseSalesInfo['supply'] as $item) {
|
||||
$phoneList[] = $item['shopkeeperPhone'];
|
||||
}
|
||||
$param = [
|
||||
'start_time' => strtotime(date('Y-m-d', time())),
|
||||
'end_time' => strtotime(date('Y-m-d', time())) + 86399,
|
||||
'phone' => implode(',', $phoneList)
|
||||
];
|
||||
$result = ShopRequestLogic::getUserTradeAmount($param); // todo 对接接口
|
||||
$tradeAmount = $result['data']['trade_amount'];
|
||||
|
||||
$totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池
|
||||
|
||||
|
||||
// 目标金额 = 274 * 收集用户数
|
||||
$targetTradeAmount = bcmul($target, 274, 2);
|
||||
|
||||
// 完成条件: 交易金额 >= 目标金额
|
||||
if (bccomp($totalAmount, $targetTradeAmount, 2) ==0 || bccomp($totalAmount, $targetTradeAmount, 2) ==1) {
|
||||
$taskInfo['money'] = bcdiv($taskTemplateInfo['money_two'], 2, 2);
|
||||
$leftTransactionPool = bcsub($totalAmount, $targetTradeAmount, 2);
|
||||
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $leftTransactionPool);
|
||||
} else {
|
||||
(new Task())->closeTask($taskSchedulePlan['task_id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user