fix: 抖音君特友店7月期初取店铺后台余额 (#1028)
君特友家具专卖店采用店铺后台确认的287706.90元作为2026年7月期初,并按月滚动。
This commit is contained in:
parent
92585c04a0
commit
db8cf2df9e
@ -12,7 +12,21 @@ use RuntimeException;
|
||||
|
||||
class DouyinAuthoritativeBillRepository
|
||||
{
|
||||
private const MERCHANT_BACKOFFICE_ZERO_STORE = '索菲亚妙选家具专卖店';
|
||||
/**
|
||||
* 店铺后台已确认、但抖音6表未提供快照的 2026-06-30 期末余额。
|
||||
*
|
||||
* @var array<string,array{balance:float,source:string}>
|
||||
*/
|
||||
private const MERCHANT_BACKOFFICE_JUNE_ENDING_BALANCES = [
|
||||
'索菲亚妙选家具专卖店' => [
|
||||
'balance' => 0.0,
|
||||
'source' => 'merchant_backoffice_zero',
|
||||
],
|
||||
'君特友家具专卖店' => [
|
||||
'balance' => 287706.90,
|
||||
'source' => 'merchant_backoffice_june_ending',
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly DatabaseManager $databases,
|
||||
@ -188,7 +202,7 @@ class DouyinAuthoritativeBillRepository
|
||||
|
||||
$store = trim((string) ($filters['store_name'] ?? ''));
|
||||
$normalizedStore = JushuitanShopBalanceRepository::normalizeStoreName($store);
|
||||
$merchantBackofficeZero = $normalizedStore === self::MERCHANT_BACKOFFICE_ZERO_STORE;
|
||||
$confirmedBackoffice = self::MERCHANT_BACKOFFICE_JUNE_ENDING_BALANCES[$normalizedStore] ?? null;
|
||||
$balance = 0.0;
|
||||
$hasSnapshot = false;
|
||||
|
||||
@ -210,8 +224,12 @@ class DouyinAuthoritativeBillRepository
|
||||
}
|
||||
}
|
||||
|
||||
if (! $hasSnapshot && ! $merchantBackofficeZero) {
|
||||
return ['balance' => 0.0, 'date' => null, 'source' => 'none'];
|
||||
if (! $hasSnapshot) {
|
||||
if ($confirmedBackoffice === null) {
|
||||
return ['balance' => 0.0, 'date' => null, 'source' => 'none'];
|
||||
}
|
||||
|
||||
$balance = round($confirmedBackoffice['balance'], 2);
|
||||
}
|
||||
|
||||
if ($start->gt($baselineMonth)) {
|
||||
@ -234,7 +252,7 @@ class DouyinAuthoritativeBillRepository
|
||||
'balance' => $balance,
|
||||
'date' => $start->subDay()->format('Y-m-d'),
|
||||
'source' => $start->equalTo($baselineMonth)
|
||||
? ($hasSnapshot ? 'june_ending' : 'merchant_backoffice_zero')
|
||||
? ($hasSnapshot ? 'june_ending' : $confirmedBackoffice['source'])
|
||||
: 'previous_period',
|
||||
];
|
||||
}
|
||||
|
||||
@ -371,13 +371,11 @@ export default {
|
||||
if(this.billType==='douyin'){
|
||||
const openingSource=this.summary.opening_balance_source;
|
||||
const openingDate=this.summary.opening_balance_date;
|
||||
const openingNote=openingSource==='none'
|
||||
?'未找到 2026-06-30 期末余额'
|
||||
:(openingSource==='june_ending'
|
||||
?`截至 ${openingDate} 抖音6表期末余额`
|
||||
:(openingSource==='merchant_backoffice_zero'
|
||||
?'店铺后台7月期初为0'
|
||||
:`截至 ${openingDate} 上一账期期末`));
|
||||
let openingNote=`截至 ${openingDate} 上一账期期末`;
|
||||
if(openingSource==='none')openingNote='未找到 2026-06-30 期末余额';
|
||||
else if(openingSource==='june_ending')openingNote=`截至 ${openingDate} 抖音6表期末余额`;
|
||||
else if(openingSource==='merchant_backoffice_zero')openingNote='店铺后台7月期初为0';
|
||||
else if(openingSource==='merchant_backoffice_june_ending')openingNote='店铺后台6月期末余额';
|
||||
return [
|
||||
{label:'期初余额',value:this.moneyWan(this.summary.opening_balance),note:openingNote,className:''},
|
||||
{label:'收入合计',value:this.moneyWan(this.summary.income),note:`${this.summary.count} 笔交易`,className:'is-income'},
|
||||
|
||||
@ -255,6 +255,49 @@ class DouyinAuthoritativeBillTest extends TestCase
|
||||
$this->assertNull($missing['summary']['opening_balance_date']);
|
||||
}
|
||||
|
||||
public function test_junteryou_uses_confirmed_backoffice_opening_and_rolls_forward(): void
|
||||
{
|
||||
$store = '抖音-君特友家具专卖店';
|
||||
$julyIncome = array_replace($this->row('2000000000000000401', '42898.74'), [
|
||||
'店铺' => $store,
|
||||
'结算时间' => '2026-07-15 10:00:00',
|
||||
]);
|
||||
$julyExpense = array_replace($this->row('2000000000000000402', '0.00', '307745.42'), [
|
||||
'店铺' => $store,
|
||||
'账单项目' => '平台服务费',
|
||||
'结算时间' => '2026-07-16 10:00:00',
|
||||
]);
|
||||
$augustIncome = array_replace($this->row('2000000000000000403', '10.00'), [
|
||||
'店铺' => $store,
|
||||
'结算时间' => '2026-08-15 10:00:00',
|
||||
]);
|
||||
$this->import([$julyIncome, $julyExpense], 2, '42898.74', '307745.42', null, '2026-07');
|
||||
$this->import([$augustIncome], 1, '10.00', '0.00', null, '2026-08');
|
||||
|
||||
$repo = app(StoreReceivingDouyinBillMirrorRepository::class);
|
||||
$july = $repo->paginate([
|
||||
'store_name' => $store,
|
||||
'start' => '2026-07-01',
|
||||
'end' => '2026-07-31',
|
||||
], 'occurred_at', 'asc', 1, 10);
|
||||
$august = $repo->paginate([
|
||||
'store_name' => $store,
|
||||
'start' => '2026-08-01',
|
||||
'end' => '2026-08-31',
|
||||
], 'occurred_at', 'asc', 1, 10);
|
||||
|
||||
$this->assertSame(287706.90, $july['summary']['opening_balance']);
|
||||
$this->assertSame('2026-06-30', $july['summary']['opening_balance_date']);
|
||||
$this->assertSame('merchant_backoffice_june_ending', $july['summary']['opening_balance_source']);
|
||||
$this->assertSame(42898.74, $july['summary']['income']);
|
||||
$this->assertSame(307745.42, $july['summary']['expense']);
|
||||
$this->assertSame(22860.22, $july['summary']['balance']);
|
||||
$this->assertSame(22860.22, $august['summary']['opening_balance']);
|
||||
$this->assertSame('2026-07-31', $august['summary']['opening_balance_date']);
|
||||
$this->assertSame('previous_period', $august['summary']['opening_balance_source']);
|
||||
$this->assertSame(22870.22, $august['summary']['balance']);
|
||||
}
|
||||
|
||||
private function import(
|
||||
array $rows,
|
||||
int $count,
|
||||
|
||||
@ -214,6 +214,8 @@ class AccountBillsTableTest extends TestCase
|
||||
$this->assertStringContainsString("if(this.billType==='douyin')", $source);
|
||||
$this->assertStringContainsString('抖音6表期末余额', $source);
|
||||
$this->assertStringContainsString('店铺后台7月期初为0', $source);
|
||||
$this->assertStringContainsString("openingSource==='merchant_backoffice_june_ending'", $source);
|
||||
$this->assertStringContainsString('店铺后台6月期末余额', $source);
|
||||
$this->assertStringContainsString('上一账期期末', $source);
|
||||
$this->assertStringContainsString("note:'期初余额 + 收入合计 - 支出合计'", $source);
|
||||
$this->assertLessThan(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user