72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\EcommerceFinance;
|
|
|
|
use App\Http\Controllers\Business\Pages;
|
|
use ReflectionMethod;
|
|
use Tests\TestCase;
|
|
|
|
class PerformanceDifferenceRemarkTest extends TestCase
|
|
{
|
|
private function remark(array $attributes): ?string
|
|
{
|
|
$row = (object) array_merge([
|
|
'platform' => '拼多多',
|
|
'match_status' => '已匹配',
|
|
'income_amount' => 0,
|
|
'discount_amount' => 0,
|
|
'offset_amount' => 0,
|
|
'refund_amount' => 0,
|
|
'product_amount' => 0,
|
|
'paid_amount' => 0,
|
|
'difference' => 0,
|
|
'planting_amount' => null,
|
|
'remark' => null,
|
|
], $attributes);
|
|
|
|
return (new ReflectionMethod(Pages::class, 'receiptDifferenceRemark'))->invoke(null, $row);
|
|
}
|
|
|
|
public function test_pinduoduo_full_refund_wins_before_other_difference_rules(): void
|
|
{
|
|
$this->assertSame('订单实付含已退款部分', $this->remark([
|
|
'income_amount' => 7.00,
|
|
'discount_amount' => 17.00,
|
|
'refund_amount' => -7.00,
|
|
'product_amount' => 42.00,
|
|
'paid_amount' => 6.99,
|
|
'difference' => 17.01,
|
|
]));
|
|
}
|
|
|
|
public function test_pinduoduo_partial_refund_marks_platform_payment_discount(): void
|
|
{
|
|
$this->assertSame('差额=平台支付立减', $this->remark([
|
|
'income_amount' => 896.00,
|
|
'refund_amount' => -552.36,
|
|
'product_amount' => 936.00,
|
|
'paid_amount' => 894.21,
|
|
'difference' => 1.79,
|
|
]));
|
|
|
|
$this->assertSame('差额=平台支付立减', $this->remark([
|
|
'income_amount' => 16.43,
|
|
'refund_amount' => -12.00,
|
|
'product_amount' => 21.90,
|
|
'paid_amount' => 16.42,
|
|
'difference' => 0.01,
|
|
]));
|
|
}
|
|
|
|
public function test_large_unexplained_pinduoduo_difference_stays_pending(): void
|
|
{
|
|
$this->assertSame('差额待核实', $this->remark([
|
|
'income_amount' => 130.00,
|
|
'refund_amount' => -50.00,
|
|
'product_amount' => 150.00,
|
|
'paid_amount' => 100.00,
|
|
'difference' => 30.00,
|
|
]));
|
|
}
|
|
}
|