feat(partner): 调整酒道馆与区县代理日结均分池为1分钟增量结算

这个提交包含在:
chen
2026-09-18 11:30:39 +08:00
父节点 195a098101
当前提交 85947e43ae
共有 6 个文件被更改,包括 377 次插入 和 43 次删除

查看文件

@@ -323,25 +323,57 @@ class Order extends Common
}
if ($settleDate) {
$dayStart = strtotime($settleDate . ' 00:00:00');
$dayEnd = strtotime($settleDate . ' 23:59:59');
foreach ($shareTypes as $type) {
$shareRows = \app\admin\model\shopro\partner\Reward::where('settle_date', $settleDate)
$shareRows = \app\admin\model\shopro\partner\Reward::where(function ($q) use ($settleDate, $dayStart, $dayEnd) {
$q->where('settle_date', $settleDate)
->whereOr(function ($q2) use ($dayStart, $dayEnd) {
$q2->whereNull('settle_date')->whereBetween('createtime', [$dayStart, $dayEnd]);
});
})
->where('reward_type', $type)
->where('status', 1)
->where('user_id', '>', 0)
->select();
$userCount = count($shareRows);
$distinctUsers = [];
$totalAmount = 0;
$totalMadow = 0;
foreach ($shareRows as $sr) {
$totalAmount = round($totalAmount + (float) ($sr->amount ?? 0), 2);
$totalMadow = function_exists('bcadd')
? (float) bcadd((string) $totalMadow, (string) ($sr->madow ?? 0), 8)
: ($totalMadow + (float) ($sr->madow ?? 0));
$distinctUsers[intval($sr->user_id)] = true;
}
$userCount = count($distinctUsers);
if ($userCount <= 0) {
// 分母为 0 进平台的记录
$platform = \app\admin\model\shopro\partner\Reward::where('settle_date', $settleDate)
$platRows = \app\admin\model\shopro\partner\Reward::where(function ($q) use ($settleDate, $dayStart, $dayEnd) {
$q->where('settle_date', $settleDate)
->whereOr(function ($q2) use ($dayStart, $dayEnd) {
$q2->whereNull('settle_date')->whereBetween('createtime', [$dayStart, $dayEnd]);
});
})
->where('reward_type', $type)
->where('status', 1)
->where('user_id', 0)
->find();
if (!$platform) {
->select();
if (empty($platRows) || count($platRows) <= 0) {
continue;
}
$platAmount = (float) ($platform->amount ?? 0);
$platMadow = (float) ($platform->madow ?? 0);
$platAmount = 0;
$platMadow = 0;
foreach ($platRows as $pr) {
$platAmount = round($platAmount + (float) ($pr->amount ?? 0), 2);
$platMadow = function_exists('bcadd')
? (float) bcadd((string) $platMadow, (string) ($pr->madow ?? 0), 8)
: ($platMadow + (float) ($pr->madow ?? 0));
}
$platform = $platRows[0];
$amountText = $type === 'madow_share'
? \addons\shopro\service\partner\IdentityService::formatMadow($platMadow) . ' 马豆'
: '¥' . number_format($platAmount, 2, '.', '');
@@ -367,26 +399,15 @@ class Order extends Common
'unit' => $type === 'madow_share' ? '马豆' : '元',
'formula' => (string) ($platform->formula ?? ''),
'skip_reason_text' => '',
'tip' => '付款日日结均分:当日无人参与,奖池进平台',
'tip' => '当日无人参与,奖池进平台',
];
continue;
}
$totalAmount = 0;
$totalMadow = 0;
foreach ($shareRows as $sr) {
$totalAmount = round($totalAmount + (float) ($sr->amount ?? 0), 2);
$totalMadow = function_exists('bcadd')
? (float) bcadd((string) $totalMadow, (string) ($sr->madow ?? 0), 8)
: ($totalMadow + (float) ($sr->madow ?? 0));
}
$first = $shareRows[0];
$eachAmount = number_format((float) ($first->amount ?? 0), 2, '.', '');
$eachMadow = \addons\shopro\service\partner\IdentityService::formatMadow($first->madow ?? 0);
$ext = is_array($first->ext) ? $first->ext : [];
if (!empty($ext['share_user_count'])) {
$userCount = intval($ext['share_user_count']);
}
$eachAmount = function_exists('bcdiv') ? bcdiv((string) $totalAmount, (string) $userCount, 2) : number_format($totalAmount / $userCount, 2, '.', '');
$eachMadowVal = function_exists('bcdiv') ? bcdiv((string) $totalMadow, (string) $userCount, 8) : ($totalMadow / $userCount);
$eachMadow = \addons\shopro\service\partner\IdentityService::formatMadow($eachMadowVal);
$items[] = [
'display' => 'share',
@@ -409,7 +430,7 @@ class Order extends Common
'unit' => $type === 'madow_share' ? '马豆' : '元',
'formula' => (string) ($first->formula ?? ''),
'skip_reason_text' => '',
'tip' => '付款日日结均分(不列出参与用户名单)',
'tip' => '日结均分(不列出参与用户名单)',
];
}
}