fix(账户余额): 修复非镜像平台每日余额查询 (#1287)

This commit is contained in:
qiuxiang 2026-11-19 18:40:47 +08:00
parent 3240342fa4
commit e6ce84759e
2 changed files with 33 additions and 1 deletions

View File

@ -1518,7 +1518,7 @@ class StoreReceivingBalanceOverviewService
->where('company_id', company_id())
->where('bill_type', $platform);
if ($flow === null) {
$query->where(function (Builder $query): void {
$query->where(function (EloquentBuilder $query): void {
$query->where('income', '>', 0)->orWhere('expense', '>', 0);
});
} else {

View File

@ -4,8 +4,10 @@ namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use Mockery;
use Modules\EcommerceFinance\Models\AccountBill;
use Modules\EcommerceFinance\Services\PeriodBalanceReconciliationService;
use Modules\EcommerceFinance\Services\StoreReceivingBalanceOverviewService;
use ReflectionMethod;
use Tests\Feature\FeatureTestCase;
class StoreReceivingBalanceOverviewEndpointTest extends FeatureTestCase
@ -191,6 +193,36 @@ class StoreReceivingBalanceOverviewEndpointTest extends FeatureTestCase
->assertJsonPath('pagination.total', 1);
}
public function test_account_bill_daily_rows_include_both_flows_when_direction_is_unspecified(): void
{
$this->company->makeCurrent();
AccountBill::create([
'company_id' => $this->company->id,
'bill_type' => 'xiaohongshu',
'record_code' => 'daily-balance-null-flow',
'store_name' => '小红书-测试店',
'order_no' => 'DAILY-BALANCE-1',
'amount' => 5.0,
'bill_item' => '销售',
'occurred_at' => '2026-10-15 12:00:00',
'income' => 5.0,
'expense' => 0.0,
'payload' => [],
]);
$service = $this->app->make(StoreReceivingBalanceOverviewService::class);
$method = new ReflectionMethod($service, 'accountBillRows');
$method->setAccessible(true);
$rows = iterator_to_array(
$method->invoke($service, 'xiaohongshu', '2026-10-01', '2026-10-31', null),
);
$this->assertCount(1, $rows);
$this->assertSame('小红书-测试店', $rows[0]['store_name']);
$this->assertSame(5.0, $rows[0]['income']);
$this->assertSame(0.0, $rows[0]['expense']);
}
public function test_overview_page_uses_the_vue_mount_point(): void
{
$this->user->attachPermission(