- 按流程状态=已完成同步全部记录(去掉收款人过滤) - 明细表「收款费用明细」JSON 解码并按行展开为多行 - 新增「标签」列:收款人=宁波顾家望业家居有限公司→刘萧代发,其余→1688代发 - 「料号」列改为「商品编码」(值留空) - 仓库改为数据库层分页 + SQL 聚合,避免大数据量拖垮页面 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
132 lines
5.6 KiB
PHP
132 lines
5.6 KiB
PHP
<?php
|
||
|
||
namespace Tests\Feature\Business;
|
||
|
||
use App\Models\Auth\Permission;
|
||
use Mockery;
|
||
use Modules\EcommerceFinance\Repositories\DingOnlineDaifaPriceMirrorRepository;
|
||
use Tests\Feature\FeatureTestCase;
|
||
|
||
class OnlineDaifaPricePageTest extends FeatureTestCase
|
||
{
|
||
public function test_online_daifa_price_page_renders_matched_product_and_amounts(): void
|
||
{
|
||
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
|
||
$repository = Mockery::mock(DingOnlineDaifaPriceMirrorRepository::class);
|
||
$repository->shouldReceive('paginate')->once()->andReturn([
|
||
'data' => [[
|
||
'process_instance_id' => 'DEMO-6927049845766979458',
|
||
'detail_index' => 0,
|
||
'product_id' => '3821829253650055444',
|
||
'daifa_trade_no' => '6927049845766979458',
|
||
'shop_trade_no' => '6927049845766979458',
|
||
'shop_name' => '抖音-HX旗舰店101',
|
||
'payee_name' => '宁波顾家望业家居有限公司',
|
||
'supplier_name' => '',
|
||
'material_no' => '',
|
||
'ship_qty' => 1,
|
||
'paid_amount' => 616.61,
|
||
'daifa_amount' => 375.0,
|
||
'price_diff' => 241.61,
|
||
'workflow' => [
|
||
'businessId' => '20260901001',
|
||
'title' => '线上代发业务报销',
|
||
'status' => 'COMPLETED',
|
||
'result' => 'agree',
|
||
'originatorUserName' => '扬灵',
|
||
'createAt' => '2026-09-01 10:00:00',
|
||
],
|
||
'scheme' => [['name' => '商品ID', 'value' => '3821829253650055444']],
|
||
'tasks' => [],
|
||
'status_key' => 'COMPLETED',
|
||
'status_label' => '已完成',
|
||
'matched_product' => ['matched' => true, 'name' => '演示商品', 'sku_id' => null, 'i_id' => null],
|
||
'workflow_created_at' => '2026-09-01 10:00:00',
|
||
]],
|
||
'total' => 1,
|
||
'status' => 'succeeded',
|
||
'last_synced_at' => '2026-09-08 00:00:05',
|
||
'summary' => [
|
||
'count' => 1,
|
||
'matched_count' => 1,
|
||
'daifa_amount' => 375.0,
|
||
'paid_amount' => 616.61,
|
||
'price_diff' => 241.61,
|
||
],
|
||
]);
|
||
$this->app->instance(DingOnlineDaifaPriceMirrorRepository::class, $repository);
|
||
|
||
$this->loginAs()->get(route('business.pages.show', [
|
||
'section' => 'product-inventory',
|
||
'page' => 'online-daifa-price',
|
||
]))->assertOk()
|
||
->assertSee('线上代发价格')
|
||
->assertSee('固定流程:线上代发业务报销流程(钉钉 OA 审批)')
|
||
->assertSee('固定收款人:')
|
||
->assertSee('宁波顾家望业家居有限公司')
|
||
->assertSee('镜像状态:succeeded')
|
||
->assertSee('3821829253650055444')
|
||
->assertSee('演示商品')
|
||
->assertSee('抖音-HX旗舰店101')
|
||
->assertSee('6927049845766979458')
|
||
->assertSee('已完成')
|
||
->assertSee('扬灵')
|
||
->assertSee('已匹配商品目录')
|
||
->assertSee('展开表单(1 项)');
|
||
}
|
||
|
||
public function test_online_daifa_price_page_keeps_an_unavailable_mirror_readable(): void
|
||
{
|
||
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
|
||
$repository = Mockery::mock(DingOnlineDaifaPriceMirrorRepository::class);
|
||
$repository->shouldReceive('paginate')->andThrow(new \RuntimeException('not ready'));
|
||
$this->app->instance(DingOnlineDaifaPriceMirrorRepository::class, $repository);
|
||
|
||
$this->loginAs()->get(route('business.pages.show', [
|
||
'section' => 'product-inventory',
|
||
'page' => 'online-daifa-price',
|
||
]))->assertOk()
|
||
->assertSee('线上代发价格镜像尚未完成同步,请稍后重试。')
|
||
->assertSee('镜像读取失败,请稍后重试。');
|
||
}
|
||
|
||
public function test_online_daifa_price_page_passes_filters_to_repository(): void
|
||
{
|
||
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
|
||
$repository = Mockery::mock(DingOnlineDaifaPriceMirrorRepository::class);
|
||
$repository->shouldReceive('paginate')->once()->with(
|
||
[
|
||
'keyword' => '6927049845766979458',
|
||
'product_id' => '3821829253650055444',
|
||
'shop_name' => '抖音-HX旗舰店101',
|
||
'status' => '',
|
||
'created_from' => '2026-09-01',
|
||
'created_to' => '2026-09-07',
|
||
],
|
||
1,
|
||
Mockery::type('int'),
|
||
)->andReturn([
|
||
'data' => [],
|
||
'total' => 0,
|
||
'status' => 'succeeded',
|
||
'last_synced_at' => '2026-09-08 00:00:05',
|
||
'summary' => [],
|
||
]);
|
||
$this->app->instance(DingOnlineDaifaPriceMirrorRepository::class, $repository);
|
||
|
||
$this->loginAs()->get(route('business.pages.show', [
|
||
'section' => 'product-inventory',
|
||
'page' => 'online-daifa-price',
|
||
'keyword' => '6927049845766979458',
|
||
'product_id' => '3821829253650055444',
|
||
'shop_name' => '抖音-HX旗舰店101',
|
||
'created_from' => '2026-09-01',
|
||
'created_to' => '2026-09-07',
|
||
]))->assertOk()
|
||
->assertSee('商品ID')
|
||
->assertSee('店铺名称')
|
||
->assertSee('2026-09-01')
|
||
->assertSee('2026-09-07');
|
||
}
|
||
}
|