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' => '日结均分(不列出参与用户名单)',
];
}
}

查看文件

@@ -42,7 +42,19 @@ class WalletLog extends Common
'recharge_gift' => '线上充值-赠送余额',
'activity_gift' => '活动-赠送余额',
'order_refund' => '订单退款-退还余额',
'transfer_by_commission' => '服务收益-转入到余额'
'transfer_by_commission' => '服务收益-转入到余额',
'reward_income' => '收益分成-入账',
'reward_back' => '收益分成-退还',
'push3' => '推荐开拓奖',
'maker_diff' => '创客进阶奖',
'maker_peer' => '创客协同奖',
'maker_overtaken' => '创客卓越奖',
'team_venue' => '酒道馆运营奖',
'team_county' => '区县统筹奖',
'venue_peer' => '酒道馆协同奖',
'county_peer' => '区县协同奖',
'venue_share' => '酒道馆加权奖励',
'county_share' => '区县加权奖励'
],
'commission' => [
'withdraw' => '提现',
@@ -64,7 +76,19 @@ class WalletLog extends Common
];
public function getEventMap() {
return $this->eventMap;
$map = $this->eventMap;
if (class_exists('\\addons\\shopro\\service\\partner\\PartnerConfig')) {
$partnerMap = \addons\shopro\service\partner\PartnerConfig::rewardTypeMap();
foreach ($partnerMap as $k => $v) {
if (!isset($map['money'][$k])) {
$map['money'][$k] = $v;
}
if (!isset($map['commission'][$k])) {
$map['commission'][$k] = $v;
}
}
}
return $map;
}
public function scopeMoney($query)
@@ -84,6 +108,9 @@ class WalletLog extends Common
public function getEventTextAttr($value, $data)
{
return $this->eventMap[$data['type']][$data['event']] ?? '';
$type = $data['type'] ?? '';
$event = $data['event'] ?? '';
$eventMap = $this->getEventMap();
return $eventMap[$type][$event] ?? ($eventMap['commission'][$event] ?? '');
}
}