feat(得物支付宝账户): 新增聚水潭支付宝账单页签 (#1369)
新增得物支付宝账户页签,限定 8 个主体并默认展示聚水潭 2026 年 10 月淘系支付宝账单。
This commit is contained in:
parent
d2d58276fb
commit
cfde5d06c7
@ -10,6 +10,7 @@ use Modules\EcommerceFinance\Repositories\JdDailyBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\PinduoduoSettlementBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingAlipayBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDouyinBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDewuAlipayBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingJdWalletBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingPinduoduoBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\TaobaoWechatSettlementBillRepository;
|
||||
@ -149,6 +150,7 @@ class RunAccountBillsExportTask extends Command
|
||||
'taobao-wechat' => app(TaobaoWechatSettlementBillRepository::class)->exportAccountBills($filters, $sort, $dir),
|
||||
'pinduoduo' => app(PinduoduoSettlementBillRepository::class)->exportAccountBills($filters, $sort, $dir),
|
||||
'dewu' => app(DewuSettlementBillRepository::class)->exportAccountBills($filters, $sort, $dir),
|
||||
'dewu-alipay' => app(StoreReceivingDewuAlipayBillMirrorRepository::class)->exportRows($filters, $sort, $dir),
|
||||
'jd-transactions', 'jingxi' => JdBillPlatform::isJdBillTab($tab)
|
||||
? app(JdDailyBillRepository::class)->forPlatform(JdBillPlatform::platformForBillType($tab))->exportRows($filters, $sort, $dir)
|
||||
: [],
|
||||
|
||||
@ -584,6 +584,7 @@ $navigation = [
|
||||
['slug' => 'jingxi', 'title' => '京喜账单'],
|
||||
['slug' => 'douyin', 'title' => '抖音账户'],
|
||||
['slug' => 'dewu', 'title' => '得物账户'],
|
||||
['slug' => 'dewu-alipay', 'title' => '得物支付宝账户'],
|
||||
['slug' => 'vipshop', 'title' => '唯品会MP账户'],
|
||||
['slug' => 'vipshop-jx', 'title' => '唯品会JX账户'],
|
||||
['slug' => 'xiaohongshu', 'title' => '小红书账户'],
|
||||
|
||||
@ -53,6 +53,45 @@ class AccountBillColumns
|
||||
['修改人', 'modifier', 'text'],
|
||||
];
|
||||
|
||||
/** @var array<int,array{0:string,1:int}> */
|
||||
private const DEWU_ALIPAY_GROUPS = [
|
||||
['基础信息', 5],
|
||||
['账户与交易', 8],
|
||||
['金额', 3],
|
||||
['业务关联', 6],
|
||||
['维护信息', 4],
|
||||
];
|
||||
|
||||
/** @var array<int,array{0:string,1:string,2:string}> */
|
||||
private const DEWU_ALIPAY_COLUMNS = [
|
||||
['记录编码', 'record_code', 'num'],
|
||||
['原始店铺', 'store_name', 'text'],
|
||||
['总账备注', 'ledger_remark', 'text'],
|
||||
['自定义备注', 'custom_remark', 'text'],
|
||||
['账单项目', 'bill_item', 'tag'],
|
||||
['支付宝账号', 'alipay_account', 'num'],
|
||||
['账务订单号', 'account_order_no', 'num'],
|
||||
['业务流水号', 'business_serial_no', 'num'],
|
||||
['商户订单号', 'merchant_order_no', 'num'],
|
||||
['业务基础订单号', 'business_base_order_no', 'num'],
|
||||
['商品名称', 'goods_name', 'text'],
|
||||
['对方账号', 'counterparty_account', 'text'],
|
||||
['发生时间', 'occurred_at', 'date'],
|
||||
['收入', 'income', 'money_in'],
|
||||
['支出', 'expense', 'money_out'],
|
||||
['余额', 'balance', 'money'],
|
||||
['业务类型', 'business_type', 'tag'],
|
||||
['备注', 'remark', 'text'],
|
||||
['线上单号', 'online_order_no', 'num'],
|
||||
['线上单号对应实际店铺', 'online_real_store', 'text'],
|
||||
['业务描述', 'business_description', 'text'],
|
||||
['业务账单来源', 'business_bill_source', 'text'],
|
||||
['业务订单号', 'business_order_no', 'num'],
|
||||
['创建时间', 'created_at', 'date'],
|
||||
['修改时间', 'updated_at', 'date'],
|
||||
['修改人', 'modifier', 'text'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string,array{title:string,groups?:array<int,array{0:string,1:int}>,columns:array<int,array{0:string,1:string,2:string}>}>
|
||||
*/
|
||||
@ -298,6 +337,11 @@ class AccountBillColumns
|
||||
['修改人', 'modifier', 'text'],
|
||||
],
|
||||
],
|
||||
'dewu-alipay' => [
|
||||
'title' => '得物支付宝账户',
|
||||
'groups' => self::DEWU_ALIPAY_GROUPS,
|
||||
'columns' => self::DEWU_ALIPAY_COLUMNS,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ use Modules\EcommerceFinance\Repositories\JdDailyBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingJdWalletBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDouyinBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDewuBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDewuAlipayBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingPinduoduoBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\PromotionMarketingExpenseRepository;
|
||||
use Modules\EcommerceFinance\Repositories\VipshopJxOpeningBalanceRepository;
|
||||
@ -25,7 +26,7 @@ class AccountBills extends Controller
|
||||
{
|
||||
use DecoratesLedgerRemarks;
|
||||
/** 走共享业务镜像的账户类型(其余类型读本系统账单表 ec_account_bills)。 */
|
||||
private const MIRROR_TABS = ['douyin', 'pinduoduo', 'dewu', 'jd-transactions', 'jingxi', 'jd-wallet'];
|
||||
private const MIRROR_TABS = ['douyin', 'pinduoduo', 'dewu', 'dewu-alipay', 'jd-transactions', 'jingxi', 'jd-wallet'];
|
||||
|
||||
/**
|
||||
* 时间筛选按「账单期间」(payload.settle_period,形如 2026-07)而不是按发生时间过滤的页签。
|
||||
@ -355,6 +356,7 @@ class AccountBills extends Controller
|
||||
'jd_daily_bill_mirror_not_ready',
|
||||
'jd_wallet_bill_mirror_not_ready',
|
||||
'dewu_authoritative_bills_not_ready',
|
||||
'taobao_alipay_authoritative_bills_not_ready',
|
||||
], true)) {
|
||||
throw $exception;
|
||||
}
|
||||
@ -595,6 +597,7 @@ class AccountBills extends Controller
|
||||
'jd_daily_bill_mirror_not_ready',
|
||||
'jd_wallet_bill_mirror_not_ready',
|
||||
'dewu_authoritative_bills_not_ready',
|
||||
'taobao_alipay_authoritative_bills_not_ready',
|
||||
], true)) {
|
||||
throw $exception;
|
||||
}
|
||||
@ -796,6 +799,7 @@ class AccountBills extends Controller
|
||||
'jd_daily_bill_mirror_not_ready',
|
||||
'jd_wallet_bill_mirror_not_ready',
|
||||
'dewu_authoritative_bills_not_ready',
|
||||
'taobao_alipay_authoritative_bills_not_ready',
|
||||
], true)) {
|
||||
throw $exception;
|
||||
}
|
||||
@ -864,6 +868,7 @@ class AccountBills extends Controller
|
||||
'jd-wallet' => app(StoreReceivingJdWalletBillRepository::class),
|
||||
'pinduoduo' => app(StoreReceivingPinduoduoBillMirrorRepository::class),
|
||||
'dewu' => app(StoreReceivingDewuBillMirrorRepository::class),
|
||||
'dewu-alipay' => app(StoreReceivingDewuAlipayBillMirrorRepository::class),
|
||||
default => app(StoreReceivingDouyinBillMirrorRepository::class),
|
||||
};
|
||||
}
|
||||
@ -876,6 +881,7 @@ class AccountBills extends Controller
|
||||
'jd-wallet' => '京东钱包',
|
||||
'pinduoduo' => '拼多多',
|
||||
'dewu' => '得物',
|
||||
'dewu-alipay' => '得物支付宝',
|
||||
'taobao-alipay' => '淘系支付宝账户',
|
||||
'taobao-wechat' => '淘系微信账户',
|
||||
'vipshop' => '唯品会MP账户',
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\EcommerceFinance\Repositories;
|
||||
|
||||
/**
|
||||
* 得物支付宝账户:从聚水潭淘系支付宝完整账单中读取指定主体的账户流水。
|
||||
*
|
||||
* 聚水潭导出的展示名可能在末尾追加 8 位日期后缀;本页按八家主体的标准名称锁定范围,
|
||||
* 表格继续展示源账单中的原始账户名。
|
||||
*/
|
||||
class StoreReceivingDewuAlipayBillMirrorRepository
|
||||
{
|
||||
/** @var list<string> */
|
||||
public const STORE_NAMES = [
|
||||
'支付宝-常州春之华家居有限公司',
|
||||
'支付宝-常州诗科家电子商务有限公司',
|
||||
'支付宝-常州玖阔家居有限公司',
|
||||
'支付宝-常州阔之煜家居有限公司',
|
||||
'支付宝-常州熊泽家居有限公司',
|
||||
'支付宝-常州雄川家居有限公司',
|
||||
'支付宝-常州泽之云家居有限公司',
|
||||
'支付宝-常州君佰家居有限公司',
|
||||
];
|
||||
|
||||
private readonly TaobaoAlipaySettlementBillRepository $source;
|
||||
|
||||
public function __construct(TaobaoAlipaySettlementBillRepository $source)
|
||||
{
|
||||
$this->source = $source->scopedToStores(self::STORE_NAMES);
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function paginate(array $filters, string $sort, string $direction, int $page, int $perPage): array
|
||||
{
|
||||
return $this->source->paginate($filters, $sort, $direction, $page, $perPage);
|
||||
}
|
||||
|
||||
/** @return iterable<int,array<string,mixed>> */
|
||||
public function exportRows(array $filters, string $sort = 'occurred_at', string $direction = 'asc'): iterable
|
||||
{
|
||||
return $this->source->exportRows($filters, $sort, $direction);
|
||||
}
|
||||
|
||||
/** @return array{shops:list<string>,bill_items:list<string>} */
|
||||
public function filterOptions(): array
|
||||
{
|
||||
$options = $this->source->accountBillFilterOptions();
|
||||
$shops = array_values(array_unique(array_merge(self::STORE_NAMES, $options['shops'])));
|
||||
sort($shops, SORT_NATURAL);
|
||||
|
||||
return [
|
||||
'shops' => $shops,
|
||||
'bill_items' => $options['bill_items'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,9 @@ class TaobaoAlipaySettlementBillRepository
|
||||
|
||||
private readonly ConnectionInterface $connection;
|
||||
|
||||
/** @var list<string> */
|
||||
private array $storeNames = [];
|
||||
|
||||
public function __construct(DatabaseManager $databases)
|
||||
{
|
||||
$this->connection = $databases->connection(
|
||||
@ -37,10 +40,28 @@ class TaobaoAlipaySettlementBillRepository
|
||||
return $this->connection->table(self::IMPORT_TABLE)->where('status', 'succeeded')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建限定到固定店铺集合的只读查询副本。用于同一镜像上的专题页签,
|
||||
* 不改变财务系统“淘系支付宝账户”本身的查询范围。
|
||||
*
|
||||
* @param list<string> $storeNames
|
||||
*/
|
||||
public function scopedToStores(array $storeNames): self
|
||||
{
|
||||
$copy = clone $this;
|
||||
$copy->storeNames = array_values(array_unique(array_filter(array_map(
|
||||
static fn (mixed $value): string => trim((string) $value),
|
||||
$storeNames,
|
||||
))));
|
||||
|
||||
return $copy;
|
||||
}
|
||||
|
||||
/** @return array{shops:list<string>,bill_items:list<string>} */
|
||||
public function accountBillFilterOptions(): array
|
||||
{
|
||||
$query = $this->query();
|
||||
$this->applyStoreScope($query);
|
||||
|
||||
return [
|
||||
'shops' => (clone $query)->whereNotNull('store_name')->where('store_name', '<>', '')
|
||||
@ -174,6 +195,7 @@ class TaobaoAlipaySettlementBillRepository
|
||||
/** @param array<string,mixed> $filters */
|
||||
private function applyFilters(Builder $query, array $filters): void
|
||||
{
|
||||
$this->applyStoreScope($query);
|
||||
$store = trim((string) ($filters['store_name'] ?? ''));
|
||||
if ($store !== '') $query->where('store_name', $store);
|
||||
$excludedStoreNamePrefix = trim((string) ($filters['exclude_store_name_prefix'] ?? ''));
|
||||
@ -344,14 +366,20 @@ class TaobaoAlipaySettlementBillRepository
|
||||
->when($excludedStoreNamePrefix !== '', function (Builder $query) use ($excludedStoreNamePrefix): void {
|
||||
$this->applyExcludedStoreNamePrefix($query, $excludedStoreNamePrefix);
|
||||
});
|
||||
$scopedQuery = function () use ($query): Builder {
|
||||
$builder = $query();
|
||||
$this->applyStoreScope($builder);
|
||||
|
||||
$accounts = $query()
|
||||
return $builder;
|
||||
};
|
||||
|
||||
$accounts = $scopedQuery()
|
||||
->select('alipay_account')
|
||||
->groupBy('alipay_account')
|
||||
->pluck('alipay_account');
|
||||
$rows = [];
|
||||
foreach ($accounts as $account) {
|
||||
$row = $query()
|
||||
$row = $scopedQuery()
|
||||
->where('alipay_account', $account)
|
||||
->orderByDesc('occurred_at')
|
||||
->orderByDesc('source_row_number')
|
||||
@ -388,14 +416,20 @@ class TaobaoAlipaySettlementBillRepository
|
||||
->when($excludedStoreNamePrefix !== '', function (Builder $query) use ($excludedStoreNamePrefix): void {
|
||||
$this->applyExcludedStoreNamePrefix($query, $excludedStoreNamePrefix);
|
||||
});
|
||||
$scopedQuery = function () use ($query): Builder {
|
||||
$builder = $query();
|
||||
$this->applyStoreScope($builder);
|
||||
|
||||
$accounts = $query()
|
||||
return $builder;
|
||||
};
|
||||
|
||||
$accounts = $scopedQuery()
|
||||
->select('alipay_account')
|
||||
->groupBy('alipay_account')
|
||||
->pluck('alipay_account');
|
||||
$rows = [];
|
||||
foreach ($accounts as $account) {
|
||||
$row = $query()
|
||||
$row = $scopedQuery()
|
||||
->where('alipay_account', $account)
|
||||
->orderBy('occurred_at')
|
||||
->orderBy('source_row_number')
|
||||
@ -484,6 +518,13 @@ class TaobaoAlipaySettlementBillRepository
|
||||
});
|
||||
}
|
||||
|
||||
private function applyStoreScope(Builder $query): void
|
||||
{
|
||||
if ($this->storeNames !== []) {
|
||||
$query->whereIn('store_name', $this->storeNames);
|
||||
}
|
||||
}
|
||||
|
||||
private function openingBalanceCacheKey(
|
||||
string $cutoff,
|
||||
string $store,
|
||||
@ -496,6 +537,7 @@ class TaobaoAlipaySettlementBillRepository
|
||||
$store,
|
||||
$importVersion,
|
||||
$excludedStoreNamePrefix,
|
||||
implode("\0", $this->storeNames),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
'tw-stats--jd-wallet': billType === 'jd-wallet',
|
||||
'tw-stats--pinduoduo': billType === 'pinduoduo',
|
||||
'tw-stats--douyin': billType === 'douyin',
|
||||
'tw-stats--dewu-alipay': billType === 'dewu-alipay',
|
||||
'tw-stats--vipshop': billType === 'vipshop',
|
||||
'tw-stats--vipshop-jx': billType === 'vipshop-jx',
|
||||
'tw-stats--xiaohongshu': billType === 'xiaohongshu',
|
||||
@ -295,7 +296,7 @@ export default {
|
||||
// Every account-bill tab uses the same explicit picker path. Keeping one
|
||||
// control avoids browser-native date inputs appearing on older tabs.
|
||||
usesStableDateControl(){return true;},
|
||||
usesMirrorOptions(){return ['douyin','pinduoduo','dewu','taobao-wechat','jd-transactions','jingxi','jd-wallet','vipshop','vipshop-jx','xiaohongshu','promotion-marketing'].indexOf(this.billType)!==-1;},
|
||||
usesMirrorOptions(){return ['douyin','pinduoduo','dewu','dewu-alipay','taobao-wechat','jd-transactions','jingxi','jd-wallet','vipshop','vipshop-jx','xiaohongshu','promotion-marketing'].indexOf(this.billType)!==-1;},
|
||||
canUseStoreSelect(){return !this.filterOptionsError&&(this.filterOptionsLoading||this.filterOptions.shops.length>0);},
|
||||
invalidDateRange(){return Boolean(this.filters.start&&this.filters.end&&this.filters.start>this.filters.end);},
|
||||
startDateConfig(){return {...dateConfig,maxDate:this.filters.end||null};},
|
||||
@ -336,6 +337,20 @@ export default {
|
||||
{label:'交易笔数',value:this.summary.count,note:'当前筛选结果',className:''},
|
||||
];
|
||||
}
|
||||
if(this.billType==='dewu-alipay'){
|
||||
const openingSource=this.summary.opening_balance_source;
|
||||
const openingDate=this.summary.opening_balance_date;
|
||||
const openingNote=openingSource==='first_row_estimate'
|
||||
?'首月按首笔余额倒推'
|
||||
:(openingDate?`截至 ${openingDate} 账户最后一笔`:'上月最后一笔');
|
||||
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'},
|
||||
{label:'支出合计',value:this.moneyWan(this.summary.expense),note:'按当前筛选',className:'is-expense'},
|
||||
{label:'期末余额',value:this.moneyWan(this.summary.balance),note:'期初余额 + 收入合计 - 支出合计',className:''},
|
||||
{label:'交易笔数',value:this.summary.count,note:'当前筛选结果',className:''},
|
||||
];
|
||||
}
|
||||
if(this.billType==='jd-wallet'){
|
||||
const openingSource=this.summary.opening_balance_source;
|
||||
const openingDate=this.summary.opening_balance_date;
|
||||
@ -456,7 +471,7 @@ export default {
|
||||
async fetchFilterOptions(){const requestId=++this.filterOptionsRequestSerial;this.filterOptionsLoading=true;this.filterOptionsError=false;try{const response=await window.axios.get(`${this.apiBase}/filter-options`,{params:{start:this.filters.start,end:this.filters.end}});if(requestId!==this.filterOptionsRequestSerial)return;const body=response.data||{};const shops=Array.isArray(body.shops)?body.shops.slice():[];const selected=String(this.filters.store_name||'').trim();if(selected&&shops.indexOf(selected)===-1)shops.unshift(selected);this.filterOptions={shops,bill_items:Array.isArray(body.bill_items)?body.bill_items:[],ledger_remarks:Array.isArray(body.ledger_remarks)?body.ledger_remarks:[]};}catch(error){if(requestId===this.filterOptionsRequestSerial)this.filterOptionsError=true;}finally{if(requestId===this.filterOptionsRequestSerial)this.filterOptionsLoading=false;}},
|
||||
async fetch(){const requestId=++this.requestSerial;const requestedFilters={...this.queryFilters};this.loading=true;this.loadError=false;try{const response=await window.axios.get(this.apiBase,{params:{...requestedFilters,sort:this.sort.key,dir:this.sort.dir,limit:this.perPage,page:this.currentPage}});if(requestId!==this.requestSerial)return;const body=response.data||{};this.resultFilters=requestedFilters;this.sync=body.sync||null;this.rows=body.data||[];this.total=body.total||0;this.currentPage=body.current_page||1;this.lastPage=body.last_page||1;this.perPage=body.per_page||this.perPage;this.summary=body.summary||{income:0,expense:0,opening_balance:null,opening_balance_date:null,opening_balance_source:null,withdrawal_amount:0,withdrawal_count:0,withdrawal_latest_date:null,balance:null,balance_source:null,count:0};if(this.isPromotionMarketing){this.promotionExpenseSummary={income:Number(this.summary.income||0),expense:Number(this.summary.expense||0),balance:Number(this.summary.balance||0),count:Number(this.summary.count||0)};}if(body.columns){this.columnsTitle=body.columns.title||'';this.sourceGroups=body.columns.groups||[];this.sourceColumns=this.attachGroups(body.columns.columns||body.columns||[],this.sourceGroups);}}catch(error){if(requestId!==this.requestSerial)return;this.rows=[];this.total=0;this.sync=null;this.summary={income:0,expense:0,opening_balance:null,opening_balance_date:null,opening_balance_source:null,withdrawal_amount:0,withdrawal_count:0,withdrawal_latest_date:null,balance:null,balance_source:null,count:0};this.promotionExpenseSummary={income:0,expense:0,balance:0,count:0};this.loadError=true;}finally{if(requestId===this.requestSerial)this.loading=false;}},
|
||||
attachGroups(columns,groups){let index=0;return columns.map((column,columnIndex)=>{while(groups[index]&&columnIndex>=groups.slice(0,index+1).reduce((sum,group)=>sum+Number(group.span||0),0))index+=1;return{...column,key:column.field||`column-${columnIndex}`,group:groups[index]?groups[index].label:''};});},
|
||||
applyFilters(){if(this.invalidDateRange)return;const dateRangeChanged=this.queryFilters.start!==this.filters.start||this.queryFilters.end!==this.filters.end;this.queryFilters={...this.filters};this.currentPage=1;const requests=[this.fetch()];if(this.usesMirrorOptions&&!this.compact&&dateRangeChanged)requests.push(this.fetchFilterOptions());return Promise.all(requests);},resetFilters(){this.filters=filtersForRange();return this.applyFilters();},changePage(page){this.currentPage=page;this.fetch();this.$nextTick(()=>{if(this.$refs.scroll)this.$refs.scroll.scrollTop=0;});},
|
||||
applyFilters(){if(this.invalidDateRange)return;const dateRangeChanged=this.queryFilters.start!==this.filters.start||this.queryFilters.end!==this.filters.end;this.queryFilters={...this.filters};this.currentPage=1;const requests=[this.fetch()];if(this.usesMirrorOptions&&!this.compact&&dateRangeChanged)requests.push(this.fetchFilterOptions());return Promise.all(requests);},resetFilters(){this.filters=filtersForRange(this.initialStart,this.initialEnd);return this.applyFilters();},changePage(page){this.currentPage=page;this.fetch();this.$nextTick(()=>{if(this.$refs.scroll)this.$refs.scroll.scrollTop=0;});},
|
||||
openDatePicker(refName){const picker=this.$refs[refName];if(picker&&picker.fp)picker.fp.open();},
|
||||
async fetchPromotionExpenseDetails(filters=null){
|
||||
const requestId=++this.promotionRequestSerial;
|
||||
@ -580,17 +595,20 @@ export default {
|
||||
.tw-toolbar { flex-wrap: wrap; }
|
||||
.tw-tools { flex: 1 1 24rem; min-width: 0; }
|
||||
.tw-stats--douyin { grid-template-columns: repeat(5, minmax(0, 1fr)); }
|
||||
.tw-stats--dewu-alipay { grid-template-columns: repeat(5, minmax(0, 1fr)); }
|
||||
.tw-stats--vipshop { grid-template-columns: repeat(5, minmax(0, 1fr)); }
|
||||
.tw-stats--vipshop-jx { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
||||
.tw-stats--xiaohongshu { grid-template-columns: repeat(5, minmax(0, 1fr)); }
|
||||
@media (max-width: 900px) {
|
||||
.tw-stats--douyin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.tw-stats--dewu-alipay { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.tw-stats--vipshop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.tw-stats--vipshop-jx { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.tw-stats--xiaohongshu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
}
|
||||
@media (max-width: 520px) {
|
||||
.tw-stats--douyin { grid-template-columns: 1fr; }
|
||||
.tw-stats--dewu-alipay { grid-template-columns: 1fr; }
|
||||
.tw-stats--vipshop { grid-template-columns: 1fr; }
|
||||
.tw-stats--vipshop-jx { grid-template-columns: 1fr; }
|
||||
.tw-stats--xiaohongshu { grid-template-columns: 1fr; }
|
||||
|
||||
19
resources/assets/js/views/business/pages.js
vendored
19
resources/assets/js/views/business/pages.js
vendored
@ -6,7 +6,7 @@
|
||||
* 店铺收款账户账单(store-receiving-bills)下各 tab:
|
||||
* - balance-overview → 店铺余额趋势看板(聚合 8 个收款平台的期初、收入与支出)
|
||||
* - taobao-alipay → 独立实现 TaobaoAlipayBills(经营分析副本共享镜像)
|
||||
* - taobao-wechat / pinduoduo / jd-wallet / jd-transactions / jingxi / dewu / vipshop / vipshop-jx / xiaohongshu / promotion-marketing
|
||||
* - taobao-wechat / pinduoduo / jd-wallet / jd-transactions / jingxi / dewu / dewu-alipay / vipshop / vipshop-jx / xiaohongshu / promotion-marketing
|
||||
* → 通用实现 AccountBills(表 ec_account_bills,按 bill_type 区分)
|
||||
* - douyin → AccountBills 展示共享原始账单镜像中的头条放心购渠道
|
||||
* 期末余额双源核对(period-balance-reconciliation) → 财务期末余额与聚水潭余额核对
|
||||
@ -22,8 +22,8 @@ import AccountBills from './../../components/business/AccountBills.vue';
|
||||
import StoreReceivingBalanceOverview from './../../components/business/StoreReceivingBalanceOverview.vue';
|
||||
import PeriodBalanceReconciliation from './../../components/business/PeriodBalanceReconciliation.vue';
|
||||
|
||||
const GENERIC_TABS = ['taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'vipshop', 'vipshop-jx', 'xiaohongshu', 'promotion-marketing'];
|
||||
const STORE_RECEIVING_TABS = ['balance-overview', 'taobao-alipay', 'taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'vipshop', 'vipshop-jx', 'xiaohongshu'];
|
||||
const GENERIC_TABS = ['taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'dewu-alipay', 'vipshop', 'vipshop-jx', 'xiaohongshu', 'promotion-marketing'];
|
||||
const STORE_RECEIVING_TABS = ['balance-overview', 'taobao-alipay', 'taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'dewu-alipay', 'vipshop', 'vipshop-jx', 'xiaohongshu'];
|
||||
|
||||
function pageContext(pathname = window.location.pathname) {
|
||||
const parts = (pathname || '').split('/').filter(Boolean);
|
||||
@ -81,7 +81,18 @@ function resolveComponent(context) {
|
||||
const progressBase = context.companyId
|
||||
? `/${context.companyId}/ecommerce-finance/account-bills/export-progress`
|
||||
: '/ecommerce-finance/account-bills/export-progress';
|
||||
return { Component: AccountBills, props: { apiBase: accountBase, billType: context.tab, progressBase, pageKey: context.page } };
|
||||
const isDewuAlipay = context.page === 'store-receiving-bills' && context.tab === 'dewu-alipay';
|
||||
return {
|
||||
Component: AccountBills,
|
||||
props: {
|
||||
apiBase: accountBase,
|
||||
billType: context.tab,
|
||||
progressBase,
|
||||
pageKey: context.page,
|
||||
initialStart: isDewuAlipay ? '2026-10-01' : '',
|
||||
initialEnd: isDewuAlipay ? '2026-10-31' : '',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
97
tests/Feature/Business/DewuAlipayReceivingBillsTest.php
Normal file
97
tests/Feature/Business/DewuAlipayReceivingBillsTest.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Business;
|
||||
|
||||
use App\Models\Auth\Permission;
|
||||
use Mockery;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDewuAlipayBillMirrorRepository;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class DewuAlipayReceivingBillsTest extends FeatureTestCase
|
||||
{
|
||||
public function test_endpoint_reads_only_the_scoped_dewu_alipay_mirror(): void
|
||||
{
|
||||
$this->allowPage();
|
||||
$repository = Mockery::mock(StoreReceivingDewuAlipayBillMirrorRepository::class);
|
||||
$repository->shouldReceive('paginate')
|
||||
->once()
|
||||
->with(
|
||||
Mockery::on(static fn (array $filters): bool => ($filters['start'] ?? null) === '2026-10-01'
|
||||
&& ($filters['end'] ?? null) === '2026-10-31'),
|
||||
'occurred_at',
|
||||
'desc',
|
||||
1,
|
||||
20,
|
||||
)
|
||||
->andReturn([
|
||||
'data' => [[
|
||||
'record_code' => '2000000001360000001',
|
||||
'store_name' => '支付宝-常州阔之煜家居有限公司',
|
||||
'bill_item' => '商家代付货款',
|
||||
'alipay_account' => '2088841085257651',
|
||||
'occurred_at' => '2026-10-27 18:52:15',
|
||||
'income' => 21815.89,
|
||||
'expense' => 0,
|
||||
'balance' => 92957.40,
|
||||
]],
|
||||
'total' => 1,
|
||||
'current_page' => 1,
|
||||
'last_page' => 1,
|
||||
'per_page' => 20,
|
||||
'summary' => [
|
||||
'income' => 21815.89,
|
||||
'expense' => 0,
|
||||
'opening_balance' => 71141.51,
|
||||
'opening_balance_date' => '2026-09-30',
|
||||
'opening_balance_source' => 'previous_period',
|
||||
'balance' => 92957.40,
|
||||
'count' => 1,
|
||||
],
|
||||
'sync' => ['status' => 'succeeded', 'last_succeeded_at' => '2026-11-01 09:00:00'],
|
||||
]);
|
||||
$this->app->instance(StoreReceivingDewuAlipayBillMirrorRepository::class, $repository);
|
||||
|
||||
$this->loginAs()
|
||||
->getJson(route('ecommerce-finance.account-bills.index', [
|
||||
'bill_type' => 'dewu-alipay',
|
||||
'start' => '2026-10-01',
|
||||
'end' => '2026-10-31',
|
||||
'limit' => 20,
|
||||
]))
|
||||
->assertOk()
|
||||
->assertJsonPath('columns.title', '得物支付宝账户')
|
||||
->assertJsonPath('total', 1)
|
||||
->assertJsonPath('data.0.alipay_account', '2088841085257651')
|
||||
->assertJsonPath('summary.balance', 92957.4);
|
||||
}
|
||||
|
||||
public function test_filter_options_expose_the_eight_scoped_accounts(): void
|
||||
{
|
||||
$this->allowPage();
|
||||
$repository = Mockery::mock(StoreReceivingDewuAlipayBillMirrorRepository::class);
|
||||
$repository->shouldReceive('filterOptions')->once()->andReturn([
|
||||
'shops' => StoreReceivingDewuAlipayBillMirrorRepository::STORE_NAMES,
|
||||
'bill_items' => ['商家代付货款', '技术服务费'],
|
||||
]);
|
||||
$this->app->instance(StoreReceivingDewuAlipayBillMirrorRepository::class, $repository);
|
||||
|
||||
$response = $this->loginAs()
|
||||
->getJson(route('ecommerce-finance.account-bills.filter-options', [
|
||||
'bill_type' => 'dewu-alipay',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertJsonPath('bill_items.1', '技术服务费')
|
||||
->assertJsonCount(8, 'shops');
|
||||
$this->assertContains(
|
||||
'支付宝-常州春之华家居有限公司',
|
||||
$response->json('shops'),
|
||||
);
|
||||
}
|
||||
|
||||
private function allowPage(): void
|
||||
{
|
||||
$this->user->attachPermission(
|
||||
Permission::where('name', 'read-admin-panel')->firstOrFail(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\EcommerceFinance\Repositories\StoreReceivingDewuAlipayBillMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\TaobaoAlipaySettlementBillRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -126,6 +127,72 @@ class TaobaoAlipaySettlementBillRepositoryTest extends TestCase
|
||||
$this->assertSame(180.0, $result['summary']['balance']);
|
||||
}
|
||||
|
||||
public function test_scoped_repository_limits_rows_and_opening_balance_to_fixed_stores(): void
|
||||
{
|
||||
$rows = DB::connection('business_mirror')->table('taobao_alipay_bill_rows');
|
||||
$rows->insert([
|
||||
$this->row('A-SEP', '支付宝-目标店', 'account-a', '2026-09-30 23:59:59', '0', '0', '150', 10),
|
||||
$this->row('B-SEP', '支付宝-其他店', 'account-b', '2026-09-30 23:59:59', '0', '0', '500', 20),
|
||||
$this->row('A-OCT', '支付宝-目标店', 'account-a', '2026-10-15 10:00:00', '40', '10', '180', 30),
|
||||
$this->row('B-OCT', '支付宝-其他店', 'account-b', '2026-10-20 10:00:00', '100', '0', '600', 40),
|
||||
]);
|
||||
|
||||
$result = app(TaobaoAlipaySettlementBillRepository::class)
|
||||
->scopedToStores(['支付宝-目标店'])
|
||||
->paginate(
|
||||
['start' => '2026-10-01', 'end' => '2026-10-31'],
|
||||
'occurred_at',
|
||||
'desc',
|
||||
1,
|
||||
20,
|
||||
);
|
||||
|
||||
$this->assertSame(1, $result['summary']['count']);
|
||||
$this->assertSame(40.0, $result['summary']['income']);
|
||||
$this->assertSame(10.0, $result['summary']['expense']);
|
||||
$this->assertSame(150.0, $result['summary']['opening_balance']);
|
||||
$this->assertSame(180.0, $result['summary']['balance']);
|
||||
$this->assertSame(['支付宝-目标店'], array_column($result['data'], 'store_name'));
|
||||
}
|
||||
|
||||
public function test_dewu_alipay_wrapper_keeps_only_the_eight_configured_accounts(): void
|
||||
{
|
||||
$rows = DB::connection('business_mirror')->table('taobao_alipay_bill_rows');
|
||||
$rows->insert([
|
||||
$this->row('TARGET-SEP', '支付宝-常州熊泽家居有限公司', 'account-target', '2026-09-30 23:59:59', '0', '0', '100', 10),
|
||||
$this->row('OTHER-SEP', '支付宝-常州其他主体有限公司', 'account-other', '2026-09-30 23:59:59', '0', '0', '500', 20),
|
||||
$this->row('TARGET-OCT', '支付宝-常州熊泽家居有限公司', 'account-target', '2026-10-12 10:05:34', '30', '0', '130', 30),
|
||||
$this->row('OTHER-OCT', '支付宝-常州其他主体有限公司', 'account-other', '2026-10-12 10:05:34', '90', '0', '590', 40),
|
||||
]);
|
||||
$repository = new StoreReceivingDewuAlipayBillMirrorRepository(
|
||||
app(TaobaoAlipaySettlementBillRepository::class),
|
||||
);
|
||||
|
||||
$result = $repository->paginate(
|
||||
['start' => '2026-10-01', 'end' => '2026-10-31'],
|
||||
'occurred_at',
|
||||
'desc',
|
||||
1,
|
||||
20,
|
||||
);
|
||||
$options = $repository->filterOptions();
|
||||
$export = iterator_to_array($repository->exportRows(
|
||||
['start' => '2026-10-01', 'end' => '2026-10-31'],
|
||||
'occurred_at',
|
||||
'desc',
|
||||
));
|
||||
|
||||
$this->assertSame(1, $result['summary']['count']);
|
||||
$this->assertSame(30.0, $result['summary']['income']);
|
||||
$this->assertSame(130.0, $result['summary']['balance']);
|
||||
$this->assertSame(['支付宝-常州熊泽家居有限公司'], array_column($result['data'], 'store_name'));
|
||||
$this->assertCount(8, $options['shops']);
|
||||
$this->assertContains('支付宝-常州熊泽家居有限公司', $options['shops']);
|
||||
$this->assertNotContains('支付宝-常州其他主体有限公司', $options['shops']);
|
||||
$this->assertCount(1, $export);
|
||||
$this->assertSame('支付宝-常州熊泽家居有限公司', $export[0]['store_name']);
|
||||
}
|
||||
|
||||
public function test_first_imported_month_infers_opening_balance_from_first_account_rows(): void
|
||||
{
|
||||
$rows = DB::connection('business_mirror')->table('taobao_alipay_bill_rows');
|
||||
|
||||
@ -14,7 +14,7 @@ class AccountBillsTableTest extends TestCase
|
||||
$this->assertStringContainsString("usesStableDateControl(){return true;}", $source);
|
||||
$this->assertStringContainsString("{ 'is-stable-date': usesStableDateControl }", $source);
|
||||
$this->assertStringContainsString('.tw-date.is-stable-date .tw-date-control', $source);
|
||||
$this->assertStringContainsString("['douyin','pinduoduo','dewu','taobao-wechat','jd-transactions','jingxi','jd-wallet','vipshop','vipshop-jx','xiaohongshu','promotion-marketing'].indexOf(this.billType)!==-1", $source);
|
||||
$this->assertStringContainsString("['douyin','pinduoduo','dewu','dewu-alipay','taobao-wechat','jd-transactions','jingxi','jd-wallet','vipshop','vipshop-jx','xiaohongshu','promotion-marketing'].indexOf(this.billType)!==-1", $source);
|
||||
$this->assertStringContainsString('v-if="usesMirrorOptions && !filterOptionsError"', $source);
|
||||
$this->assertStringContainsString(':page-key="pageKey"', $source);
|
||||
$this->assertStringContainsString(':tab-key="billType"', $source);
|
||||
@ -30,11 +30,11 @@ class AccountBillsTableTest extends TestCase
|
||||
$source = file_get_contents(__DIR__ . '/../../../resources/assets/js/views/business/pages.js');
|
||||
|
||||
$this->assertStringContainsString(
|
||||
"const GENERIC_TABS = ['taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'vipshop', 'vipshop-jx', 'xiaohongshu', 'promotion-marketing'];",
|
||||
"const GENERIC_TABS = ['taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'dewu-alipay', 'vipshop', 'vipshop-jx', 'xiaohongshu', 'promotion-marketing'];",
|
||||
$source,
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
"const STORE_RECEIVING_TABS = ['balance-overview', 'taobao-alipay', 'taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'vipshop', 'vipshop-jx', 'xiaohongshu'];",
|
||||
"const STORE_RECEIVING_TABS = ['balance-overview', 'taobao-alipay', 'taobao-wechat', 'pinduoduo', 'jd-wallet', 'jd-transactions', 'jingxi', 'douyin', 'dewu', 'dewu-alipay', 'vipshop', 'vipshop-jx', 'xiaohongshu'];",
|
||||
$source,
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
@ -89,7 +89,7 @@ class AccountBillsTableTest extends TestCase
|
||||
$this->assertStringContainsString("'tw-stats--taobao-wechat': billType === 'taobao-wechat'", $source);
|
||||
$this->assertStringContainsString("if(this.billType==='taobao-wechat')", $source);
|
||||
$this->assertStringContainsString("label:'期初余额'", $source);
|
||||
$this->assertStringContainsString("label:'期末余额(最新)'", $source);
|
||||
$this->assertStringContainsString("label:netLabel?'收支净额':'期末余额(最新)'", $source);
|
||||
$this->assertStringContainsString('待录入各店铺6月期末余额', $source);
|
||||
$this->assertStringContainsString("'店铺后台'", $source);
|
||||
$this->assertStringContainsString('6月末余额结转至', $source);
|
||||
@ -101,6 +101,26 @@ class AccountBillsTableTest extends TestCase
|
||||
$this->assertStringContainsString('.tw-stats--taobao-wechat{grid-template-columns:repeat(5,minmax(0,1fr))}', $source);
|
||||
}
|
||||
|
||||
public function test_dewu_alipay_sits_next_to_dewu_and_defaults_to_october(): void
|
||||
{
|
||||
$navigation = file_get_contents(__DIR__ . '/../../../config/business_navigation.php');
|
||||
$pages = file_get_contents(__DIR__ . '/../../../resources/assets/js/views/business/pages.js');
|
||||
$component = file_get_contents(__DIR__ . '/../../../resources/assets/js/components/business/AccountBills.vue');
|
||||
|
||||
$this->assertStringContainsString(
|
||||
"['slug' => 'dewu', 'title' => '得物账户'],\n ['slug' => 'dewu-alipay', 'title' => '得物支付宝账户'],",
|
||||
$navigation,
|
||||
);
|
||||
$this->assertStringContainsString("context.tab === 'dewu-alipay'", $pages);
|
||||
$this->assertStringContainsString("initialStart: isDewuAlipay ? '2026-10-01' : ''", $pages);
|
||||
$this->assertStringContainsString("initialEnd: isDewuAlipay ? '2026-10-31' : ''", $pages);
|
||||
$this->assertStringContainsString("'tw-stats--dewu-alipay': billType === 'dewu-alipay'", $component);
|
||||
$this->assertStringContainsString("if(this.billType==='dewu-alipay')", $component);
|
||||
$this->assertStringContainsString("label:'期初余额'", $component);
|
||||
$this->assertStringContainsString("label:'期末余额'", $component);
|
||||
$this->assertStringContainsString('.tw-stats--dewu-alipay { grid-template-columns: repeat(5, minmax(0, 1fr)); }', $component);
|
||||
}
|
||||
|
||||
public function test_jd_wallet_places_opening_balance_before_income_and_uses_period_formula(): void
|
||||
{
|
||||
$source = file_get_contents(__DIR__ . '/../../../resources/assets/js/components/business/AccountBills.vue');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user