From 2b8b846069584555448c34de1732e60a25f1f9b8 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Wed, 2 Dec 2026 10:35:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=8D=E8=8F=9C=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E6=A0=B8=E5=AF=B9=E5=B7=AE=E5=BC=82=E6=89=A3=E9=99=A4=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=BD=A3=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlantingReimbursementIncomeCheck.php | 2 +- .../planting-reimbursements.blade.php | 2 +- .../Business/PlantingWorkOrderPagesTest.php | 16 ++++++++-------- .../PlantingReimbursementIncomeCheckTest.php | 13 ++++++++++++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/modules/EcommerceFinance/Services/PlantingReimbursementIncomeCheck.php b/modules/EcommerceFinance/Services/PlantingReimbursementIncomeCheck.php index 22a619000..41566e9fb 100644 --- a/modules/EcommerceFinance/Services/PlantingReimbursementIncomeCheck.php +++ b/modules/EcommerceFinance/Services/PlantingReimbursementIncomeCheck.php @@ -92,7 +92,7 @@ class PlantingReimbursementIncomeCheck $other[] = self::SOURCE_LABELS[$source] . ' ' . $bill['bill_item'] . ' ' . self::decimal($net) . '元(' . $bill['record_code'] . ')'; } } - $difference = self::cents($row['reimbursement_amount'] ?? null) - $income; + $difference = self::cents($row['reimbursement_amount'] ?? null) - $income - self::cents($row['task_commission'] ?? null); $note = ''; $valid = $sources !== [] && $number !== '' && $start !== null && is_numeric($row['reimbursement_amount'] ?? null); if (! $valid) { diff --git a/resources/views/business/pages/billing-transactions/planting-reimbursements.blade.php b/resources/views/business/pages/billing-transactions/planting-reimbursements.blade.php index c250a44ce..14653c717 100644 --- a/resources/views/business/pages/billing-transactions/planting-reimbursements.blade.php +++ b/resources/views/business/pages/billing-transactions/planting-reimbursements.blade.php @@ -47,7 +47,7 @@
任务空包费(元){{ number_format($plantingSummary['task_empty_package_fee'] / 100, 2) }}
最终报销金额(元){{ number_format($plantingSummary['reimbursement_amount'] / 100, 2) }}
-
核对口径

仅核对已完成的种菜报销,同一工单取最新一版。订单号清理开头引号及空格后完整匹配;账单范围为工单付款月上月25日至今天,仅总账备注“订单收入”,按流水号去重后合计收入减支出。差异为最终报销金额减订单收入合计,超过±0.01元才判定多报销或少报销;平台补贴和优惠券不抵消多报销。无收入时结合平台状态和账单覆盖日期提示核实。顶部卡片与发起人汇总按日期和文本筛选统计全部结论。

+
核对口径

仅核对已完成的种菜报销,同一工单取最新一版。订单号清理开头引号及空格后完整匹配;账单范围为工单付款月上月25日至今天,仅总账备注“订单收入”,按流水号去重后合计收入减支出。差异为最终报销金额减订单收入合计再减任务佣金,超过±0.01元才判定多报销或少报销;平台补贴和优惠券不抵消多报销。无收入时结合平台状态和账单覆盖日期提示核实。顶部卡片与发起人汇总按日期和文本筛选统计全部结论。

@foreach($columns as $key => $label)@endforeach diff --git a/tests/Feature/Business/PlantingWorkOrderPagesTest.php b/tests/Feature/Business/PlantingWorkOrderPagesTest.php index fd05647c7..2353c5d1f 100644 --- a/tests/Feature/Business/PlantingWorkOrderPagesTest.php +++ b/tests/Feature/Business/PlantingWorkOrderPagesTest.php @@ -173,10 +173,10 @@ class PlantingWorkOrderPagesTest extends FeatureTestCase { $rows = []; $bills = []; - foreach (['30.00', '10.00', '17.50'] as $i => $amount) { + foreach (['30.00', '10.00', '20.00'] as $i => $amount) { $rows[] = $this->row(['completed_at' => '2026-11-12 10:00:00', 'paid_at' => '2026-11-10 10:00:00', 'platform' => '淘宝天猫', 'online_order_no' => 'ORDER' . $i, 'work_order_no' => 'GD' . $i, - 'initiator' => '测试发起人', 'task_payment' => '100.00', 'reimbursement_amount' => $amount]); + 'initiator' => '测试发起人', 'task_payment' => '100.00', 'task_commission' => '2.50', 'reimbursement_amount' => $amount]); $bills[] = ['source' => 'taobao-alipay', 'record_code' => 'B' . $i, 'online_order_no' => 'ORDER' . $i, 'occurred_at' => '2026-11-11 10:00:00', 'ledger_remark' => '订单收入', 'bill_item' => '订单收入', 'income' => '17.50', 'expense' => '0.00']; @@ -189,18 +189,18 @@ class PlantingWorkOrderPagesTest extends FeatureTestCase $query = ['month' => '2026-11', 'completed_from' => '2026-11-01', 'income_result' => '多报销']; $this->loginAs()->get($this->url('planting-reimbursements', $query))->assertOk() - ->assertSee('差异为最终报销金额减订单收入合计') + ->assertSee('差异为最终报销金额减订单收入合计再减任务佣金') ->assertSee('GD0')->assertDontSee('GD1')->assertDontSee('GD2') - ->assertViewHas('content', static fn (array $content): bool => $content['plantingIncomeSummary']['多报销'] === ['count' => 1, 'difference' => 1250] - && $content['plantingIncomeSummary']['少报销'] === ['count' => 1, 'difference' => -750] + ->assertViewHas('content', static fn (array $content): bool => $content['plantingIncomeSummary']['多报销'] === ['count' => 1, 'difference' => 1000] + && $content['plantingIncomeSummary']['少报销'] === ['count' => 1, 'difference' => -1000] && $content['plantingIncomeSummary']['一致']['count'] === 1 - && $content['plantingIncomeInitiators']['测试发起人'] === ['count' => 1, 'difference' => 1250]); + && $content['plantingIncomeInitiators']['测试发起人'] === ['count' => 1, 'difference' => 1000]); $response = $this->loginAs()->get(route('business.planting-data.planting-reimbursements.export', ['company_id' => $this->company->id] + $query + [ - 'columns' => 'work_order_no,task_payment,reimbursement_amount,income_total,income_difference,income_result', + 'columns' => 'work_order_no,task_payment,reimbursement_amount,task_commission,income_total,income_difference,income_result', ])); $response->assertOk(); - $this->assertStringContainsString('GD0,100.00,30.00,17.50,12.50,多报销', $response->streamedContent()); + $this->assertStringContainsString('GD0,100.00,30.00,2.50,17.50,10.00,多报销', $response->streamedContent()); $this->assertStringNotContainsString('GD1', $response->streamedContent()); $this->assertStringNotContainsString('GD2', $response->streamedContent()); } diff --git a/tests/Unit/EcommerceFinance/PlantingReimbursementIncomeCheckTest.php b/tests/Unit/EcommerceFinance/PlantingReimbursementIncomeCheckTest.php index c66d35ca7..868833bf2 100644 --- a/tests/Unit/EcommerceFinance/PlantingReimbursementIncomeCheckTest.php +++ b/tests/Unit/EcommerceFinance/PlantingReimbursementIncomeCheckTest.php @@ -17,7 +17,7 @@ class PlantingReimbursementIncomeCheckTest extends TestCase private function row(array $patch = []): array { return array_replace(['platform' => '头条放心购', 'shop_name' => '抖音-测试', 'online_order_no' => " ' 1234567890123456789", - 'paid_at' => '2026-11-12 12:00:00', 'task_payment' => '700.00', 'reimbursement_amount' => '668.00', 'platform_order_status' => 'TRADE_FINISHED'], $patch); + 'paid_at' => '2026-11-12 12:00:00', 'task_payment' => '700.00', 'reimbursement_amount' => '668.00', 'task_commission' => '0.00', 'platform_order_status' => 'TRADE_FINISHED'], $patch); } private function check(array $rows, array $records, ?array $expectedOrders = null): array @@ -104,4 +104,15 @@ class PlantingReimbursementIncomeCheckTest extends TestCase } $this->assertSame('0.00', $result[3]['income_difference']); } + + public function test_task_commission_is_subtracted_once_from_the_final_reimbursement_difference(): void + { + $rows = []; + foreach (['40.00', '39.98', '40.02', '0.00', null] as $commission) { + $rows[] = $this->row(['task_commission' => $commission]); + } + $result = $this->check($rows, [$this->bill()]); + $this->assertSame(['0.00', '0.02', '-0.02', '40.00', '40.00'], array_column($result, 'income_difference')); + $this->assertSame(['一致', '多报销', '少报销', '多报销', '多报销'], array_column($result, 'income_result')); + } } -- 2.47.2
{{ $label }}