浏览代码

神秘彩金

doge 1 天之前
父节点
当前提交
e14fba4c21

+ 2 - 2
app/Http/Controllers/admin/ManualAudit.php

@@ -64,7 +64,7 @@ class ManualAudit extends Controller
                 'account' => ['nullable', 'required_without:member_id', 'string', 'max:64'],
                 'account' => ['nullable', 'required_without:member_id', 'string', 'max:64'],
                 'change_type' => ['required', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'change_type' => ['required', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'amount' => ['required', 'numeric', 'min:0.01', 'regex:' . self::AMOUNT_PATTERN],
                 'amount' => ['required', 'numeric', 'min:0.01', 'regex:' . self::AMOUNT_PATTERN],
-                // 人工充值按平台倍数自动计算;其他类型自行填写,留空为0(可直接提现)
+                // 人工充值、“其他”按平台倍数自动计算;其余类型自行填写,留空为0(可直接提现)
                 'wager_amount' => ['nullable', 'numeric', 'min:0', 'regex:' . self::AMOUNT_PATTERN],
                 'wager_amount' => ['nullable', 'numeric', 'min:0', 'regex:' . self::AMOUNT_PATTERN],
                 'remark' => ['nullable', 'string', 'max:255'],
                 'remark' => ['nullable', 'string', 'max:255'],
             ]);
             ]);
@@ -95,7 +95,7 @@ class ManualAudit extends Controller
                 'member_id' => ['nullable', 'required_without:account', 'string', 'max:64'],
                 'member_id' => ['nullable', 'required_without:account', 'string', 'max:64'],
                 'account' => ['nullable', 'required_without:member_id', 'string', 'max:64'],
                 'account' => ['nullable', 'required_without:member_id', 'string', 'max:64'],
                 'amount' => ['required', 'numeric', 'min:0.01', 'regex:' . self::AMOUNT_PATTERN],
                 'amount' => ['required', 'numeric', 'min:0.01', 'regex:' . self::AMOUNT_PATTERN],
-                // 人工充值按平台倍数扣除打码量;其他类型扣除 wager_amount;不传不调整打码量
+                // 人工充值、“其他”按平台倍数扣除打码量;其余类型扣除 wager_amount;不传不调整打码量
                 'recharge_type' => ['nullable', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'recharge_type' => ['nullable', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'wager_amount' => ['nullable', 'numeric', 'min:0', 'regex:' . self::AMOUNT_PATTERN],
                 'wager_amount' => ['nullable', 'numeric', 'min:0', 'regex:' . self::AMOUNT_PATTERN],
                 'remark' => ['nullable', 'string', 'max:255'],
                 'remark' => ['nullable', 'string', 'max:255'],

+ 2 - 2
app/Http/Controllers/admin/Wallet.php

@@ -133,7 +133,7 @@ class Wallet extends Controller
                 'amount' => ['required', 'numeric', 'min:0.01'],
                 'amount' => ['required', 'numeric', 'min:0.01'],
                 'member_id' => ['required', 'string', 'min:1'],
                 'member_id' => ['required', 'string', 'min:1'],
                 'remark' => ['required', 'string', 'min:1'],
                 'remark' => ['required', 'string', 'min:1'],
-                // 人工充值按平台倍数扣除打码量;其他类型扣除 wager_amount;不传不调整打码量
+                // 人工充值、“其他”按平台倍数扣除打码量;其余类型扣除 wager_amount;不传不调整打码量
                 'recharge_type' => ['nullable', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'recharge_type' => ['nullable', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'wager_amount' => ['nullable', 'numeric', 'min:0'],
                 'wager_amount' => ['nullable', 'numeric', 'min:0'],
             ]);
             ]);
@@ -187,7 +187,7 @@ class Wallet extends Controller
                 'member_id' => ['required', 'string', 'min:1'],
                 'member_id' => ['required', 'string', 'min:1'],
                 'remark' => ['required', 'string', 'min:1'],
                 'remark' => ['required', 'string', 'min:1'],
                 'change_type' => ['required', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
                 'change_type' => ['required', 'string', 'in:' . implode(',', BalanceLogService::$manualRecharge)],
-                // 人工充值按平台倍数自动计算;其他类型自行填写,留空为0
+                // 人工充值、“其他”按平台倍数自动计算;其余类型自行填写,留空为0
                 'wager_amount' => ['nullable', 'numeric', 'min:0'],
                 'wager_amount' => ['nullable', 'numeric', 'min:0'],
             ]);
             ]);
             $memberId = request()->input('member_id');
             $memberId = request()->input('member_id');

+ 3 - 3
app/Services/Agent/AgentReportService.php

@@ -138,13 +138,13 @@ class AgentReportService
         $funds = DB::table('balance_logs')->whereIn('member_id', clone $memberIds)
         $funds = DB::table('balance_logs')->whereIn('member_id', clone $memberIds)
             ->whereBetween('created_at', [$start, $end])
             ->whereBetween('created_at', [$start, $end])
             ->whereIn('change_type', [
             ->whereIn('change_type', [
-                '人工充值', '订单补偿', '人工扣款', '注册赠送', '优惠活动', '即充即送',
+                '人工充值', '订单补偿', '其他', '人工扣款', '注册赠送', '优惠活动', '神秘彩金', '即充即送',
                 '充值返现', '老用户回归', '比比返', '笔笔返', '返水', '回水',
                 '充值返现', '老用户回归', '比比返', '笔笔返', '返水', '回水',
             ])
             ])
             ->selectRaw(<<<'SQL'
             ->selectRaw(<<<'SQL'
-                COALESCE(SUM(CASE WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type = '订单补偿') AND amount > 0 THEN amount ELSE 0 END), 0) AS manual_credit,
+                COALESCE(SUM(CASE WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type IN ('订单补偿', '其他')) AND amount > 0 THEN amount ELSE 0 END), 0) AS manual_credit,
                 COALESCE(SUM(CASE WHEN change_type = '人工扣款' AND amount < 0 THEN ABS(amount) ELSE 0 END), 0) AS manual_debit,
                 COALESCE(SUM(CASE WHEN change_type = '人工扣款' AND amount < 0 THEN ABS(amount) ELSE 0 END), 0) AS manual_debit,
-                COALESCE(SUM(CASE WHEN (change_type IN ('注册赠送','优惠活动','即充即送','充值返现','老用户回归') OR (change_type = '人工充值' AND related_id = 0)) AND amount > 0 THEN amount ELSE 0 END), 0) AS bonus_amount,
+                COALESCE(SUM(CASE WHEN (change_type IN ('注册赠送','优惠活动','神秘彩金','即充即送','充值返现','老用户回归') OR (change_type = '人工充值' AND related_id = 0)) AND amount > 0 THEN amount ELSE 0 END), 0) AS bonus_amount,
                 COALESCE(SUM(CASE WHEN change_type IN ('比比返','笔笔返','返水','回水') AND amount > 0 THEN amount ELSE 0 END), 0) AS rebate_amount
                 COALESCE(SUM(CASE WHEN change_type IN ('比比返','笔笔返','返水','回水') AND amount > 0 THEN amount ELSE 0 END), 0) AS rebate_amount
             SQL)->first();
             SQL)->first();
 
 

+ 3 - 3
app/Services/BalanceLogService.php

@@ -17,15 +17,15 @@ use Illuminate\Support\Facades\Log;
 class BalanceLogService extends BaseService
 class BalanceLogService extends BaseService
 {
 {
     public static string $MODEL = BalanceLog::class;
     public static string $MODEL = BalanceLog::class;
-    //后台充值可选择的类型
-    public static array $manualRecharge = ['人工充值', '注册赠送', '优惠活动'];
+    //后台充值可选择的类型。神秘彩金、其他不参与任何活动(不计等级/首充/返现/赠送),只加打码量:神秘彩金按填写值,其他按平台倍数
+    public static array $manualRecharge = ['人工充值', '注册赠送', '优惠活动', '神秘彩金', '其他'];
     //计入累计充值(等级经验)的类型:后台直接加款的“人工充值”与前台充值一致计入
     //计入累计充值(等级经验)的类型:后台直接加款的“人工充值”与前台充值一致计入
     public static array $levelRechargeTypes = ['充值', '人工充值', '三方充值'];
     public static array $levelRechargeTypes = ['充值', '人工充值', '三方充值'];
     //需要计算回水的类型
     //需要计算回水的类型
     public static array $computeBackFlowChangeTypes = ['充值', '人工充值', '三方充值', '提现', '人工扣款', '三方提现'];
     public static array $computeBackFlowChangeTypes = ['充值', '人工充值', '三方充值', '提现', '人工扣款', '三方提现'];
     //全部类型
     //全部类型
     public static array $RW = [
     public static array $RW = [
-        '充值', '人工充值', '订单补偿', '三方充值', '注册赠送', '优惠活动',
+        '充值', '人工充值', '订单补偿', '三方充值', '注册赠送', '优惠活动', '神秘彩金', '其他',
         '提现', '人工扣款', '三方提现', 
         '提现', '人工扣款', '三方提现', 
         //'体彩投注','体彩退款','体彩和局退款','体彩中奖','体彩输半退款',
         //'体彩投注','体彩退款','体彩和局退款','体彩中奖','体彩输半退款',
         '新澳门六合彩投注','新澳门六合彩退款','新澳门六合彩和局退款','新澳门六合彩中奖',
         '新澳门六合彩投注','新澳门六合彩退款','新澳门六合彩和局退款','新澳门六合彩中奖',

+ 6 - 6
app/Services/FundsSummaryService.php

@@ -163,9 +163,9 @@ class FundsSummaryService
     {
     {
         $query = StatsScope::excludeTestMembers(DB::table('balance_logs'))
         $query = StatsScope::excludeTestMembers(DB::table('balance_logs'))
             ->whereIn('change_type', [
             ->whereIn('change_type', [
-                '充值', '三方充值', '人工充值', '订单补偿', '人工扣款',
+                '充值', '三方充值', '人工充值', '订单补偿', '其他', '人工扣款',
                 '比比返', '笔笔返', '返水', '回水',
                 '比比返', '笔笔返', '返水', '回水',
-                '注册赠送', '优惠活动', '即充即送', '充值返现', '老用户回归',
+                '注册赠送', '优惠活动', '神秘彩金', '即充即送', '充值返现', '老用户回归',
             ]);
             ]);
 
 
         return self::applyDateRange($query, 'created_at', $start, $end)
         return self::applyDateRange($query, 'created_at', $start, $end)
@@ -183,10 +183,10 @@ class FundsSummaryService
                     WHEN change_type = '三方充值' AND amount > 0 THEN member_id END
                     WHEN change_type = '三方充值' AND amount > 0 THEN member_id END
                 ) AS third_party_deposit_people,
                 ) AS third_party_deposit_people,
                 COALESCE(SUM(CASE
                 COALESCE(SUM(CASE
-                    WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type = '订单补偿') AND amount > 0 THEN amount ELSE 0 END), 0
+                    WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type IN ('订单补偿', '其他')) AND amount > 0 THEN amount ELSE 0 END), 0
                 ) AS manual_credit_amount,
                 ) AS manual_credit_amount,
                 COUNT(DISTINCT CASE
                 COUNT(DISTINCT CASE
-                    WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type = '订单补偿') AND amount > 0 THEN member_id END
+                    WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type IN ('订单补偿', '其他')) AND amount > 0 THEN member_id END
                 ) AS manual_credit_people,
                 ) AS manual_credit_people,
                 COALESCE(SUM(CASE
                 COALESCE(SUM(CASE
                     WHEN change_type = '人工扣款' AND amount < 0 THEN ABS(amount) ELSE 0 END), 0
                     WHEN change_type = '人工扣款' AND amount < 0 THEN ABS(amount) ELSE 0 END), 0
@@ -199,13 +199,13 @@ class FundsSummaryService
                 ) AS rebate_people,
                 ) AS rebate_people,
                 COALESCE(SUM(CASE
                 COALESCE(SUM(CASE
                     WHEN (
                     WHEN (
-                        change_type IN ('注册赠送', '优惠活动', '即充即送', '充值返现', '老用户回归')
+                        change_type IN ('注册赠送', '优惠活动', '神秘彩金', '即充即送', '充值返现', '老用户回归')
                         OR (change_type = '人工充值' AND related_id = 0)
                         OR (change_type = '人工充值' AND related_id = 0)
                     ) AND amount > 0 THEN amount ELSE 0 END), 0
                     ) AND amount > 0 THEN amount ELSE 0 END), 0
                 ) AS bonus_amount,
                 ) AS bonus_amount,
                 COUNT(DISTINCT CASE
                 COUNT(DISTINCT CASE
                     WHEN (
                     WHEN (
-                        change_type IN ('注册赠送', '优惠活动', '即充即送', '充值返现', '老用户回归')
+                        change_type IN ('注册赠送', '优惠活动', '神秘彩金', '即充即送', '充值返现', '老用户回归')
                         OR (change_type = '人工充值' AND related_id = 0)
                         OR (change_type = '人工充值' AND related_id = 0)
                     ) AND amount > 0 THEN member_id END
                     ) AND amount > 0 THEN member_id END
                 ) AS bonus_people
                 ) AS bonus_people

+ 17 - 5
app/Services/ManualAuditService.php

@@ -20,6 +20,8 @@ class ManualAuditService
     public const DEBIT_CHANGE_TYPE = '人工扣款';
     public const DEBIT_CHANGE_TYPE = '人工扣款';
     /** 上下分选择该充值类型时,按平台配置的提现打码倍数计算打码量 */
     /** 上下分选择该充值类型时,按平台配置的提现打码倍数计算打码量 */
     public const PLATFORM_WAGER_TYPE = '人工充值';
     public const PLATFORM_WAGER_TYPE = '人工充值';
+    /** 按平台倍数计打码量的全部类型:“其他”与人工充值同样按倍数,但不触发充值钩子(不参与任何活动) */
+    public const PLATFORM_WAGER_TYPES = ['人工充值', '其他'];
     public const STATUS_FAILED = ManualAuditRecord::STATUS_FAILED;
     public const STATUS_FAILED = ManualAuditRecord::STATUS_FAILED;
     public const STATUS_SUCCESS = ManualAuditRecord::STATUS_SUCCESS;
     public const STATUS_SUCCESS = ManualAuditRecord::STATUS_SUCCESS;
 
 
@@ -58,8 +60,9 @@ class ManualAuditService
                     ['label' => '失败', 'value' => self::STATUS_FAILED],
                     ['label' => '失败', 'value' => self::STATUS_FAILED],
                     ['label' => '成功', 'value' => self::STATUS_SUCCESS],
                     ['label' => '成功', 'value' => self::STATUS_SUCCESS],
                 ],
                 ],
-                // 人工充值按平台提现打码倍数自动增减打码量,其他类型需填写 wager_amount
+                // 人工充值、其他按平台提现打码倍数自动增减打码量,其余类型需填写 wager_amount
                 'platform_wager_type' => self::PLATFORM_WAGER_TYPE,
                 'platform_wager_type' => self::PLATFORM_WAGER_TYPE,
+                'platform_wager_types' => self::PLATFORM_WAGER_TYPES,
                 'withdraw_wager_multiple' => WageringService::multiple(),
                 'withdraw_wager_multiple' => WageringService::multiple(),
             ],
             ],
         ];
         ];
@@ -117,7 +120,7 @@ class ManualAuditService
     }
     }
 
 
     /**
     /**
-     * @param string|null $rechargeType 下分对应的充值类型:人工充值按平台倍数扣除打码量,其他类型扣除 $wagerAmount;为空不调整打码量
+     * @param string|null $rechargeType 下分对应的充值类型:人工充值、“其他”按平台倍数扣除打码量;其余类型扣除 $wagerAmount;为空不调整打码量
      */
      */
     public static function debit(
     public static function debit(
         string $requestId,
         string $requestId,
@@ -147,13 +150,22 @@ class ManualAuditService
      */
      */
     public static function wagerDelta(bool $isDebit, string $amount, string $changeType, ?string $rechargeType, ?string $wagerAmount): array
     public static function wagerDelta(bool $isDebit, string $amount, string $changeType, ?string $rechargeType, ?string $wagerAmount): array
     {
     {
-        $custom = bcadd((string)($wagerAmount ?? '0'), '0', 10);
+        // 仅自填分支解析 wager_amount:按平台倍数的类型忽略该值;校验器的 numeric 会放行 "1e2" 等 bcmath 不接受的写法
+        $custom = static function () use ($wagerAmount): string {
+            try {
+                return bcadd((string)($wagerAmount ?? '0'), '0', 10);
+            } catch (\ValueError) {
+                throw new Exception('打码量格式不正确', HttpStatus::CUSTOM_ERROR);
+            }
+        };
         if (!$isDebit) {
         if (!$isDebit) {
             if ($changeType === self::PLATFORM_WAGER_TYPE) return [WageringService::platformRequirement($amount), false];
             if ($changeType === self::PLATFORM_WAGER_TYPE) return [WageringService::platformRequirement($amount), false];
-            return [$custom, true];
+            // “其他”不走充值钩子,平台倍数的打码量需在此处写入
+            if (in_array($changeType, self::PLATFORM_WAGER_TYPES, true)) return [WageringService::platformRequirement($amount), true];
+            return [$custom(), true];
         }
         }
         if ($rechargeType === null || $rechargeType === '') return ['0', false];
         if ($rechargeType === null || $rechargeType === '') return ['0', false];
-        $value = $rechargeType === self::PLATFORM_WAGER_TYPE ? WageringService::platformRequirement($amount) : $custom;
+        $value = in_array($rechargeType, self::PLATFORM_WAGER_TYPES, true) ? WageringService::platformRequirement($amount) : $custom();
         return [bcsub('0', $value, 10), true];
         return [bcsub('0', $value, 10), true];
     }
     }
 
 

+ 2 - 2
app/Services/MemberBonusLogService.php

@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Schema;
 /** 会员彩金的展示类型与筛选共用映射,资金账本仍保留原记账类型。 */
 /** 会员彩金的展示类型与筛选共用映射,资金账本仍保留原记账类型。 */
 final class MemberBonusLogService
 final class MemberBonusLogService
 {
 {
-    public const LEDGER_TYPES = ['即充即送', '老用户回归', '余额宝利息', '注册赠送', '优惠活动', '充值返现', '笔笔返', '回水'];
+    public const LEDGER_TYPES = ['即充即送', '老用户回归', '余额宝利息', '注册赠送', '优惠活动', '神秘彩金', '充值返现', '笔笔返', '回水'];
     private const PROMOTIONS = [
     private const PROMOTIONS = [
         PromotionRules::LOSS => '净亏邀请',
         PromotionRules::LOSS => '净亏邀请',
         PromotionRules::FIRST_DEPOSIT => '首充奖励',
         PromotionRules::FIRST_DEPOSIT => '首充奖励',
@@ -31,7 +31,7 @@ final class MemberBonusLogService
     public static function types(): array
     public static function types(): array
     {
     {
         return ['即充即送', '转盘', '老用户回归', '余额宝利息', '净亏邀请', '首充奖励',
         return ['即充即送', '转盘', '老用户回归', '余额宝利息', '净亏邀请', '首充奖励',
-            '邀请升级奖励', '充值渠道赠送', '注册赠送', '优惠活动', '充值返现', '笔笔返', '回水'];
+            '邀请升级奖励', '充值渠道赠送', '注册赠送', '优惠活动', '神秘彩金', '充值返现', '笔笔返', '回水'];
     }
     }
 
 
     private function promotionLogs(?int $type = null): QueryBuilder
     private function promotionLogs(?int $type = null): QueryBuilder

+ 2 - 2
app/Services/MemberDailyReportService.php

@@ -64,9 +64,9 @@ class MemberDailyReportService
         foreach (DB::table('balance_logs')->whereBetween('created_at', [$start, $end])->groupBy('member_id')
         foreach (DB::table('balance_logs')->whereBetween('created_at', [$start, $end])->groupBy('member_id')
             ->selectRaw(<<<'SQL'
             ->selectRaw(<<<'SQL'
                 member_id,
                 member_id,
-                COALESCE(SUM(CASE WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type = '订单补偿') AND amount > 0 THEN amount ELSE 0 END), 0) AS manual_credit,
+                COALESCE(SUM(CASE WHEN ((change_type = '人工充值' AND related_id IS NULL) OR change_type IN ('订单补偿', '其他')) AND amount > 0 THEN amount ELSE 0 END), 0) AS manual_credit,
                 COALESCE(SUM(CASE WHEN change_type = '人工扣款' AND amount < 0 THEN ABS(amount) ELSE 0 END), 0) AS manual_debit,
                 COALESCE(SUM(CASE WHEN change_type = '人工扣款' AND amount < 0 THEN ABS(amount) ELSE 0 END), 0) AS manual_debit,
-                COALESCE(SUM(CASE WHEN (change_type IN ('注册赠送','优惠活动','即充即送','充值返现','老用户回归') OR (change_type = '人工充值' AND related_id = 0)) AND amount > 0 THEN amount ELSE 0 END), 0) AS bonus_amount,
+                COALESCE(SUM(CASE WHEN (change_type IN ('注册赠送','优惠活动','神秘彩金','即充即送','充值返现','老用户回归') OR (change_type = '人工充值' AND related_id = 0)) AND amount > 0 THEN amount ELSE 0 END), 0) AS bonus_amount,
                 COALESCE(SUM(CASE WHEN change_type IN ('比比返','笔笔返','返水','回水') AND amount > 0 THEN amount ELSE 0 END), 0) AS rebate_amount
                 COALESCE(SUM(CASE WHEN change_type IN ('比比返','笔笔返','返水','回水') AND amount > 0 THEN amount ELSE 0 END), 0) AS rebate_amount
             SQL)->get() as $row) {
             SQL)->get() as $row) {
             foreach (['manual_credit', 'manual_debit', 'bonus_amount', 'rebate_amount'] as $field) {
             foreach (['manual_credit', 'manual_debit', 'bonus_amount', 'rebate_amount'] as $field) {

+ 2 - 2
app/Services/Reporting/ReportSync.php

@@ -221,9 +221,9 @@ class ReportSync
         if ($source === 'balance_logs') {
         if ($source === 'balance_logs') {
             $amount = Money::decimal($row['amount']); $type = (string) $row['change_type'];
             $amount = Money::decimal($row['amount']); $type = (string) $row['change_type'];
             if (bccomp($amount, '0', 10) > 0 && in_array($type, ['充值', '三方充值'], true)) $kind = 'deposit';
             if (bccomp($amount, '0', 10) > 0 && in_array($type, ['充值', '三方充值'], true)) $kind = 'deposit';
-            elseif (bccomp($amount, '0', 10) > 0 && in_array($type, ['注册赠送', '优惠活动', '即充即送', '充值返现', '老用户回归', '比比返', '笔笔返', '返水', '回水', '余额宝利息', '流水解冻'], true) && (int) ($row['type'] ?? 1) === 1) $kind = 'bonus';
+            elseif (bccomp($amount, '0', 10) > 0 && in_array($type, ['注册赠送', '优惠活动', '神秘彩金', '即充即送', '充值返现', '老用户回归', '比比返', '笔笔返', '返水', '回水', '余额宝利息', '流水解冻'], true) && (int) ($row['type'] ?? 1) === 1) $kind = 'bonus';
             elseif ($type === '人工充值') $kind = isset($row['related_id']) && (string) $row['related_id'] === '0' ? 'bonus' : 'manual_credit';
             elseif ($type === '人工充值') $kind = isset($row['related_id']) && (string) $row['related_id'] === '0' ? 'bonus' : 'manual_credit';
-            elseif ($type === '订单补偿') $kind = 'manual_credit';
+            elseif (in_array($type, ['订单补偿', '其他'], true)) $kind = 'manual_credit';
             elseif ($type === '人工扣款') { $kind = 'manual_debit'; $amount = bcsub('0', $amount, 10); }
             elseif ($type === '人工扣款') { $kind = 'manual_debit'; $amount = bcsub('0', $amount, 10); }
             elseif ($type === '分享佣金领取') {
             elseif ($type === '分享佣金领取') {
                 $claim = DB::table('share_claims')->where('credited_log_id', $row['id'])->where('status', 'approved')->first();
                 $claim = DB::table('share_claims')->where('credited_log_id', $row['id'])->where('status', 'approved')->first();

+ 2 - 2
app/Services/ShareEarningReportService.php

@@ -45,7 +45,7 @@ class ShareEarningReportService
             ->selectRaw('SUM(CASE WHEN change_type IN (?, ?) THEN amount ELSE 0 END) AS deposit', ['充值', '三方充值'])
             ->selectRaw('SUM(CASE WHEN change_type IN (?, ?) THEN amount ELSE 0 END) AS deposit', ['充值', '三方充值'])
             ->selectRaw('ABS(SUM(CASE WHEN change_type IN (?, ?, ?) THEN amount ELSE 0 END)) AS withdraw', ['提现', '三方提现', '人工提现'])
             ->selectRaw('ABS(SUM(CASE WHEN change_type IN (?, ?, ?) THEN amount ELSE 0 END)) AS withdraw', ['提现', '三方提现', '人工提现'])
             ->selectRaw('ABS(SUM(CASE WHEN change_type LIKE ? THEN amount ELSE 0 END)) AS consume', ['%投注%'])
             ->selectRaw('ABS(SUM(CASE WHEN change_type LIKE ? THEN amount ELSE 0 END)) AS consume', ['%投注%'])
-            ->selectRaw('SUM(CASE WHEN change_type IN (?, ?, ?, ?, ?, ?) THEN amount ELSE 0 END) AS bonus', ['注册赠送', '优惠活动', '返水', '回水', '笔笔返', '比比返'])
+            ->selectRaw('SUM(CASE WHEN change_type IN (?, ?, ?, ?, ?, ?, ?) THEN amount ELSE 0 END) AS bonus', ['注册赠送', '优惠活动', '神秘彩金', '返水', '回水', '笔笔返', '比比返'])
             ->groupBy(['invitee.id', 'invitee.stat_date']);
             ->groupBy(['invitee.id', 'invitee.stat_date']);
         $validMin = (float)(ShareSetting::query()->value('valid_member_min_deposit') ?? 0);
         $validMin = (float)(ShareSetting::query()->value('valid_member_min_deposit') ?? 0);
         $metricRows = DB::query()->fromSub($memberMetrics, 'member_metric')
         $metricRows = DB::query()->fromSub($memberMetrics, 'member_metric')
@@ -245,7 +245,7 @@ class ShareEarningReportService
             'deposit' => fn ($query) => $query->whereIn('change_type', ['充值', '三方充值']),
             'deposit' => fn ($query) => $query->whereIn('change_type', ['充值', '三方充值']),
             'withdraw' => fn ($query) => $query->whereIn('change_type', ['提现', '三方提现', '人工提现']),
             'withdraw' => fn ($query) => $query->whereIn('change_type', ['提现', '三方提现', '人工提现']),
             'consume' => fn ($query) => $query->where('change_type', 'like', '%投注%'),
             'consume' => fn ($query) => $query->where('change_type', 'like', '%投注%'),
-            'bonus' => fn ($query) => $query->whereIn('change_type', ['注册赠送', '优惠活动', '返水', '回水', '笔笔返', '比比返']),
+            'bonus' => fn ($query) => $query->whereIn('change_type', ['注册赠送', '优惠活动', '神秘彩金', '返水', '回水', '笔笔返', '比比返']),
         ];
         ];
         foreach ($sets as $field => $scope) {
         foreach ($sets as $field => $scope) {
             $query = BalanceLog::query()->whereIn('member_id', $memberIds);
             $query = BalanceLog::query()->whereIn('member_id', $memberIds);

+ 1 - 0
tests/Integration/AdminBonusLogTest.php

@@ -141,6 +141,7 @@ class AdminBonusLogTest extends TestCase
         $this->log(105, '充值返现');
         $this->log(105, '充值返现');
         $this->log(106, '笔笔返');
         $this->log(106, '笔笔返');
         $this->log(107, '回水');
         $this->log(107, '回水');
+        $this->log(108, '神秘彩金');
         // Unclaimed/coupon rewards and zero-valued channel rewards have no credited log.
         // Unclaimed/coupon rewards and zero-valued channel rewards have no credited log.
         DB::table('promotion_rewards')->insert(['activity_id'=>9,'credited_log_id'=>null]);
         DB::table('promotion_rewards')->insert(['activity_id'=>9,'credited_log_id'=>null]);
         DB::table('recharge_bonus_rewards')->insert(['credited_log_id'=>null]);
         DB::table('recharge_bonus_rewards')->insert(['credited_log_id'=>null]);

+ 2 - 1
tests/Integration/AgentDashboardTest.php

@@ -131,6 +131,7 @@ class AgentDashboardTest extends TestCase
         foreach ([['人工充值', null, 40], ['订单补偿', null, 2], ['人工扣款', null, -3], ['注册赠送', null, 1], ['优惠活动', null, 2],
         foreach ([['人工充值', null, 40], ['订单补偿', null, 2], ['人工扣款', null, -3], ['注册赠送', null, 1], ['优惠活动', null, 2],
             ['即充即送', null, 3], ['充值返现', null, 4], ['老用户回归', null, 5], ['人工充值', 0, 6], ['人工充值', 123, 999],
             ['即充即送', null, 3], ['充值返现', null, 4], ['老用户回归', null, 5], ['人工充值', 0, 6], ['人工充值', 123, 999],
             ['比比返', null, 1], ['笔笔返', null, 2], ['返水', null, 3], ['回水', null, 4], ['结算', null, 999],
             ['比比返', null, 1], ['笔笔返', null, 2], ['返水', null, 3], ['回水', null, 4], ['结算', null, 999],
+            ['其他', null, 7], ['神秘彩金', null, 8], // 其他计入人工加款,神秘彩金计入彩金
         ] as [$type, $relatedId, $amount]) {
         ] as [$type, $relatedId, $amount]) {
             DB::table('balance_logs')->insert(['member_id' => 'own', 'change_type' => $type, 'related_id' => $relatedId,
             DB::table('balance_logs')->insert(['member_id' => 'own', 'change_type' => $type, 'related_id' => $relatedId,
                 'amount' => $amount, 'created_at' => "$from 00:00:00"]);
                 'amount' => $amount, 'created_at' => "$from 00:00:00"]);
@@ -144,7 +145,7 @@ class AgentDashboardTest extends TestCase
         // 股东的全平台统计包含后台模拟会员(注单 999 / 999 / 999),不含游客和测试会员
         // 股东的全平台统计包含后台模拟会员(注单 999 / 999 / 999),不含游客和测试会员
         $this->assertSame([4, '1069.0000', '1042.0000', '1009.0000'], array_values(array_intersect_key($platform, $betFields)));
         $this->assertSame([4, '1069.0000', '1042.0000', '1009.0000'], array_values(array_intersect_key($platform, $betFields)));
         $this->assertSame([2, '30.0000', '8.0000', '3.0000'], array_values(array_intersect_key($own, $betFields)));
         $this->assertSame([2, '30.0000', '8.0000', '3.0000'], array_values(array_intersect_key($own, $betFields)));
-        $this->assertSame(['42.0000', '3.0000', '21.0000', '10.0000'], array_values(array_intersect_key($platform, $fundFields)));
+        $this->assertSame(['49.0000', '3.0000', '29.0000', '10.0000'], array_values(array_intersect_key($platform, $fundFields)));
         $this->assertSame(array_intersect_key($platform, $fundFields), array_intersect_key($own, $fundFields));
         $this->assertSame(array_intersect_key($platform, $fundFields), array_intersect_key($own, $fundFields));
     }
     }
 
 

+ 20 - 0
tests/Integration/WageringTest.php

@@ -276,6 +276,26 @@ class WageringTest extends TestCase
         $this->assertSame('20.0000000000', WageringService::platformRequirement('10'));
         $this->assertSame('20.0000000000', WageringService::platformRequirement('10'));
         $this->assertSame(['30.0000000000', true], ManualAuditService::wagerDelta(false, '10', '注册赠送', null, '30'));
         $this->assertSame(['30.0000000000', true], ManualAuditService::wagerDelta(false, '10', '注册赠送', null, '30'));
         $this->assertSame(['0.0000000000', true], ManualAuditService::wagerDelta(false, '10', '优惠活动', null, null));
         $this->assertSame(['0.0000000000', true], ManualAuditService::wagerDelta(false, '10', '优惠活动', null, null));
+        foreach (['神秘彩金', '其他'] as $type) {
+            $this->assertContains($type, BalanceLogService::$manualRecharge);
+            $this->assertContains($type, BalanceLogService::$RW);
+            $this->assertNotContains($type, BalanceLogService::$levelRechargeTypes, '不参与任何活动');
+        }
+        $this->assertSame(['30.0000000000', true], ManualAuditService::wagerDelta(false, '10', '神秘彩金', null, '30'));
+        $this->assertSame(['-5.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '神秘彩金', '5'));
+        // 其他:按平台倍数,忽略填写值;不走充值钩子所以需在此处写入
+        $this->assertSame(['20.0000000000', true], ManualAuditService::wagerDelta(false, '10', '其他', null, '999'));
+        $this->assertSame(['-20.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '其他', '999'));
+        // 按平台倍数的类型不解析 wager_amount;自填类型遇到 bcmath 不接受的写法给出业务错误而非 500
+        $this->assertSame(['20.0000000000', true], ManualAuditService::wagerDelta(false, '10', '其他', null, '1e2'));
+        $this->assertSame(['-20.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '其他', '1e2'));
+        $this->assertSame(['0', false], ManualAuditService::wagerDelta(true, '10', '人工扣款', null, '1e2'));
+        try {
+            ManualAuditService::wagerDelta(false, '10', '神秘彩金', null, '1e2');
+            $this->fail('自填打码量格式错误应被拒绝');
+        } catch (\Exception $e) {
+            $this->assertSame('打码量格式不正确', $e->getMessage());
+        }
         $this->assertSame(['-20.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '人工充值', '999'));
         $this->assertSame(['-20.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '人工充值', '999'));
         $this->assertSame(['-5.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '优惠活动', '5'));
         $this->assertSame(['-5.0000000000', true], ManualAuditService::wagerDelta(true, '10', '人工扣款', '优惠活动', '5'));
         $this->assertSame(['0', false], ManualAuditService::wagerDelta(true, '10', '人工扣款', null, null));
         $this->assertSame(['0', false], ManualAuditService::wagerDelta(true, '10', '人工扣款', null, null));