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

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

查看文件

@@ -78,7 +78,12 @@ class PartnerRewardService
foreach ($rewards as $reward) {
if (in_array($reward->reward_type, PartnerConfig::instantTypes()) && (float) $reward->amount > 0 && $reward->user_id > 0) {
Wallet::change($reward->user_id, 'commission', -$reward->amount, 'reward_back', [
$walletLog = \app\admin\model\shopro\user\WalletLog::where('user_id', $reward->user_id)
->where('ext', 'like', '%"partner_reward_id":' . intval($reward->id) . '%')
->order('id', 'desc')
->find();
$targetWallet = ($walletLog && $walletLog->type === 'commission') ? 'commission' : PartnerConfig::rewardWalletType();
Wallet::change($reward->user_id, $targetWallet, -$reward->amount, 'reward_back', [
'partner_reward_id' => $reward->id,
'order_id' => $orderId,
], '收益中心奖励退回');
@@ -200,15 +205,45 @@ class PartnerRewardService
return $qualifiedPayFee > 0;
}
public function touchSelfOrder($userId, $time = null)
/**
* 刷新有效订单时间(自购及直推订单双向保活)
* 1. 买家本人(自购)
* 2. 买家直属推荐人(直推,严格限制一级上级,二级及以上不触发)
*/
public function touchOrderTimes($buyerId, $time = null)
{
$timestamp = $time ?: time();
if (!$buyerId) {
return;
}
// 1. 买家本人自购保活
$this->updateAgentOrderTime($buyerId, $timestamp);
// 2. 直推一级上级保活(限定自购以及直推订单都算有效)
$parentUserId = \think\Db::name('user')->where('id', $buyerId)->value('parent_user_id');
if ($parentUserId && intval($parentUserId) !== intval($buyerId)) {
$this->updateAgentOrderTime($parentUserId, $timestamp);
}
}
protected function updateAgentOrderTime($userId, $timestamp)
{
$agent = AgentModel::where('user_id', $userId)->find();
if ($agent) {
$agent->last_self_order_time = $time ?: time();
$agent->save();
$current = intval($agent->last_self_order_time ?? 0);
if ($timestamp >= $current) {
$agent->last_self_order_time = $timestamp;
$agent->save();
}
}
}
public function touchSelfOrder($userId, $time = null)
{
$this->updateAgentOrderTime($userId, $time ?: time());
}
public static function dailyOrderId($settleDate)
{
return -intval(date('Ymd', strtotime($settleDate)));
@@ -287,7 +322,8 @@ class PartnerRewardService
'status' => 1,
]);
if ($row && self::$lastWriteCreated && (float) $amount > 0 && $userId > 0 && $row->status == 1 && in_array($type, PartnerConfig::instantTypes())) {
Wallet::change($userId, 'commission', $amount, $type, [
$walletType = PartnerConfig::rewardWalletType();
Wallet::change($userId, $walletType, $amount, $type, [
'partner_reward_id' => $row->id,
'order_id' => $orderId,
]);