feat(voucher): 优化兑换券整数去除.00展示并支持计划点击穿透明细
这个提交包含在:
@@ -45,16 +45,28 @@ class Index extends Commission
|
||||
$buyerId = intval($this->request->param('buyer_id', 0));
|
||||
$query = RewardModel::where('user_id', $userId)->with(['buyer', 'order']);
|
||||
|
||||
// 仅查询真金白银的现金奖励类型,马豆 (madow_share) 及兑换券有专属页面,绝不混入现金明细
|
||||
$cashTypes = array_merge(PartnerConfig::instantTypes(), ['venue_share', 'county_share']);
|
||||
|
||||
$tabMap = [
|
||||
'push3' => ['push3'],
|
||||
'maker' => ['maker_diff', 'maker_peer', 'maker_overtaken'],
|
||||
'venue' => ['team_venue', 'venue_peer', 'venue_share'],
|
||||
'county' => ['team_county', 'county_peer', 'county_share'],
|
||||
'share' => ['venue_share', 'county_share', 'madow_share'],
|
||||
'share' => ['venue_share', 'county_share'],
|
||||
];
|
||||
if ($tab !== 'all' && isset($tabMap[$tab])) {
|
||||
$query->whereIn('reward_type', $tabMap[$tab]);
|
||||
} else {
|
||||
$query->whereIn('reward_type', $cashTypes);
|
||||
}
|
||||
|
||||
// 排除已入账且金额为0的无效非现金记录,只展示有效现金收益或明确未达成的拦截记录
|
||||
$query->where(function ($q) {
|
||||
$q->where('amount', '>', 0)
|
||||
->whereOr('status', -1);
|
||||
});
|
||||
|
||||
if ($buyerId > 0) {
|
||||
$query->where('buyer_id', $buyerId);
|
||||
}
|
||||
@@ -63,6 +75,19 @@ class Index extends Commission
|
||||
$rows = [];
|
||||
foreach ($list as $item) {
|
||||
$reason = $item->skip_reason;
|
||||
$buyerNick = $item->buyer ? ($item->buyer->nickname ?? '') : '';
|
||||
$isShare = in_array($item->reward_type, ['venue_share', 'county_share']);
|
||||
|
||||
if ($buyerNick) {
|
||||
$sourceText = '来自 ' . $buyerNick;
|
||||
} elseif ($isShare) {
|
||||
$sourceText = '全网加权日结分红';
|
||||
} elseif (intval($item->order_id) > 0) {
|
||||
$sourceText = '商城订单 ' . $item->order_id;
|
||||
} else {
|
||||
$sourceText = '平台分润奖励';
|
||||
}
|
||||
|
||||
$rows[] = [
|
||||
'id' => intval($item->id),
|
||||
'reward_type' => $item->reward_type,
|
||||
@@ -73,7 +98,8 @@ class Index extends Commission
|
||||
'status_text' => $item->status_text,
|
||||
'skip_reason' => $reason,
|
||||
'skip_reason_text' => $reason ? PartnerConfig::skipReasonText($reason, true) : '',
|
||||
'buyer_nickname' => $item->buyer ? ($item->buyer->nickname ?? '') : '',
|
||||
'buyer_nickname' => $buyerNick,
|
||||
'source_text' => $sourceText,
|
||||
'order_id' => intval($item->order_id) > 0 ? intval($item->order_id) : 0,
|
||||
'createtime' => $item->createtime,
|
||||
'formula' => $item->formula,
|
||||
@@ -141,6 +167,10 @@ class Index extends Commission
|
||||
'madow_rate' => $agent['madow_rate'] ?? IdentityService::formatRate(null),
|
||||
'madow_value' => $agent['madow_value'] ?? '0.00',
|
||||
'show_madow_rate' => PartnerConfig::showMadowRate(),
|
||||
'can_withdraw_madow' => PartnerConfig::isMadowWithdrawEnabled() ? 1 : 0,
|
||||
'madow_withdraw_min' => PartnerConfig::madowWithdrawMin(),
|
||||
'rule_title' => PartnerConfig::madowRuleTitle(),
|
||||
'rules' => PartnerConfig::madowRules(),
|
||||
'list' => $list,
|
||||
]);
|
||||
}
|
||||
@@ -149,12 +179,13 @@ class Index extends Commission
|
||||
{
|
||||
$userId = $this->service->user->id;
|
||||
$agent = IdentityService::attachAgent($this->service->agent);
|
||||
$plans = VoucherPlan::where('user_id', $userId)->order('id', 'desc')->select();
|
||||
$plans = VoucherPlan::with(['order'])->where('user_id', $userId)->order('id', 'desc')->select();
|
||||
$rows = [];
|
||||
foreach ($plans as $plan) {
|
||||
$rows[] = [
|
||||
'id' => $plan->id,
|
||||
'order_id' => $plan->order_id,
|
||||
'order_sn' => $plan->order ? (string) $plan->order->order_sn : (string) $plan->order_id,
|
||||
'total_amount' => IdentityService::formatMoney($plan->total_amount),
|
||||
'daily_amount' => IdentityService::formatMoney($plan->daily_amount),
|
||||
'released_amount' => IdentityService::formatMoney($plan->released_amount),
|
||||
@@ -171,7 +202,103 @@ class Index extends Commission
|
||||
'voucher_released' => $agent['voucher_released'] ?? '0.00',
|
||||
'voucher_used' => $agent['voucher_used'] ?? '0.00',
|
||||
'voucher_available' => $agent['voucher_available'] ?? '0.00',
|
||||
'rule_title' => PartnerConfig::voucherRuleTitle(),
|
||||
'rules' => PartnerConfig::voucherRules(),
|
||||
'plans' => $rows,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定兑换券释放计划的按日释放明细
|
||||
*
|
||||
* @param int id 计划ID
|
||||
*/
|
||||
public function voucherLogs()
|
||||
{
|
||||
$userId = $this->service->user->id;
|
||||
$planId = intval($this->request->param('id', $this->request->param('plan_id', 0)));
|
||||
if ($planId <= 0) {
|
||||
$this->error('请提供有效的计划ID');
|
||||
}
|
||||
|
||||
$plan = VoucherPlan::with(['order'])->where('id', $planId)->where('user_id', $userId)->find();
|
||||
if (!$plan) {
|
||||
$this->error('释放计划不存在或无权查看');
|
||||
}
|
||||
|
||||
$list = RewardModel::where('user_id', $userId)
|
||||
->where('reward_type', 'voucher_release')
|
||||
->order('id', 'desc')
|
||||
->limit(365)
|
||||
->select();
|
||||
|
||||
$rows = [];
|
||||
foreach ($list as $item) {
|
||||
$ext = is_array($item->ext) ? $item->ext : (json_decode($item->ext ?: '{}', true) ?: []);
|
||||
$planIds = $ext['plan_ids'] ?? [];
|
||||
if (!$planIds && !empty($ext['plan_id'])) {
|
||||
$planIds = [$ext['plan_id']];
|
||||
}
|
||||
$planIds = array_map('intval', (array) $planIds);
|
||||
if ($planIds && !in_array(intval($plan->id), $planIds, true)) {
|
||||
continue;
|
||||
}
|
||||
if (empty($planIds) && !empty($ext['order_id']) && intval($ext['order_id']) != intval($plan->order_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dateText = $item->settle_date ?: ($item->createtime ? date('Y-m-d', is_numeric($item->createtime) ? $item->createtime : strtotime($item->createtime)) : '--');
|
||||
$timeText = $item->createtime ? (is_numeric($item->createtime) ? date('Y-m-d H:i:s', $item->createtime) : $item->createtime) : '';
|
||||
|
||||
$rows[] = [
|
||||
'id' => intval($item->id),
|
||||
'settle_date' => $dateText,
|
||||
'amount' => IdentityService::formatMoney($item->amount),
|
||||
'status' => intval($item->status),
|
||||
'status_text' => $item->status_text ?: '已到账',
|
||||
'formula' => $item->formula ?: ("兑换券释放 " . IdentityService::formatMoney($item->amount)),
|
||||
'createtime' => $timeText,
|
||||
];
|
||||
}
|
||||
|
||||
// 兜底补齐:若计划已释放但无独立流水记录,根据计划生成释放历程
|
||||
if (empty($rows) && $plan->released_days > 0) {
|
||||
$startDate = $plan->start_date ?: date('Y-m-d', $plan->createtime ?: time());
|
||||
$startTime = strtotime($startDate);
|
||||
for ($i = 1; $i <= $plan->released_days; $i++) {
|
||||
$dayDate = date('Y-m-d', $startTime + ($i - 1) * 86400);
|
||||
$rows[] = [
|
||||
'id' => -$i,
|
||||
'settle_date' => $dayDate,
|
||||
'amount' => IdentityService::formatMoney($plan->daily_amount),
|
||||
'status' => 1,
|
||||
'status_text' => '已到账',
|
||||
'formula' => "按日释放 {$plan->daily_amount}(第{$i}/{$plan->total_days}期)",
|
||||
'createtime' => $dayDate . ' 00:30:00',
|
||||
];
|
||||
}
|
||||
$rows = array_reverse($rows);
|
||||
}
|
||||
|
||||
$orderSn = $plan->order ? (string) $plan->order->order_sn : (string) $plan->order_id;
|
||||
$planData = [
|
||||
'id' => intval($plan->id),
|
||||
'order_id' => intval($plan->order_id),
|
||||
'order_sn' => $orderSn,
|
||||
'total_amount' => IdentityService::formatMoney($plan->total_amount),
|
||||
'daily_amount' => IdentityService::formatMoney($plan->daily_amount),
|
||||
'released_amount' => IdentityService::formatMoney($plan->released_amount),
|
||||
'released_days' => intval($plan->released_days),
|
||||
'total_days' => intval($plan->total_days),
|
||||
'start_date' => $plan->start_date,
|
||||
'status' => intval($plan->status),
|
||||
'status_text' => $plan->status_text,
|
||||
];
|
||||
|
||||
$this->success('ok', [
|
||||
'plan' => $planData,
|
||||
'logs' => $rows,
|
||||
'total' => count($rows),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户