修复一些错误
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Models\PurchaseOrderModel;
|
||||
use App\Models\StoreModel;
|
||||
use App\Models\StoreOrderModel;
|
||||
use App\Models\UserModel;
|
||||
use Modules\SystemTool\Models\SysFileModel;
|
||||
|
||||
/**
|
||||
* 账单链路与支付:订单状态随业务链自动推进(采购单完成→配送中、生成账单→已完成);
|
||||
@@ -206,4 +207,73 @@ class BillPaymentTest extends ProcurementTestCase
|
||||
$this->assertSame(0, $bill->payment_id, '账单释放可重新付款');
|
||||
$this->assertSame('0.00', (string) $store->fresh()->total_purchase_amount);
|
||||
}
|
||||
|
||||
/** 后台门店订单:列表显示关联账单与支付进度,详情附带完整账单 */
|
||||
public function test_admin_order_list_and_detail_show_bill_info(): void
|
||||
{
|
||||
[$store, $order, $bill] = $this->makeBillViaChain();
|
||||
$this->actingAsSysUser();
|
||||
|
||||
// 列表:账单摘要 + 支付进度(待支付)
|
||||
$rows = $this->getJson('/order/store')->assertOk()->json('data.data');
|
||||
$row = collect($rows)->firstWhere('id', $order->id);
|
||||
$this->assertNotNull($row['bill'], '已出账订单列表应附账单');
|
||||
$this->assertSame($bill->bill_no, $row['bill']['bill_no']);
|
||||
$this->assertSame('20.00', $row['bill']['total_amount']);
|
||||
$this->assertSame(BillModel::PAY_STATE_UNPAID, $row['bill']['pay_state']);
|
||||
$this->assertSame('待支付', $row['bill']['pay_state_name']);
|
||||
|
||||
// 详情:完整账单字段 + 支付进度
|
||||
$detail = $this->getJson("/order/store/{$order->id}")->assertOk()->json('data');
|
||||
$this->assertSame($bill->bill_no, $detail['bill']['bill_no']);
|
||||
$this->assertSame('20.00', $detail['bill']['product_amount']);
|
||||
$this->assertSame(BillModel::PAY_STATE_UNPAID, $detail['bill']['pay_state']);
|
||||
|
||||
// 收款后列表支付进度变为已支付
|
||||
$this->putJson("/recon/bill/{$bill->id}/pay")->assertJsonPath('success', true);
|
||||
$rows = $this->getJson('/order/store')->assertOk()->json('data.data');
|
||||
$row = collect($rows)->firstWhere('id', $order->id);
|
||||
$this->assertSame(BillModel::PAY_STATE_PAID, $row['bill']['pay_state']);
|
||||
$this->assertSame('已支付', $row['bill']['pay_state_name']);
|
||||
}
|
||||
|
||||
/** 支付记录详情:凭证图片解析 preview_url(回归:preview_url 为访问器不能 pluck) */
|
||||
public function test_payment_detail_returns_voucher_urls(): void
|
||||
{
|
||||
$store = StoreModel::factory()->create();
|
||||
$user = UserModel::factory()->forStore($store->id)->create();
|
||||
|
||||
$makeFile = static function (string $path): int {
|
||||
return (int) SysFileModel::create([
|
||||
'group_id' => 4,
|
||||
'disk' => 'local',
|
||||
'channel' => 20,
|
||||
'file_type' => 10,
|
||||
'file_name' => basename($path),
|
||||
'file_path' => $path,
|
||||
'file_size' => 1024,
|
||||
'file_ext' => 'jpg',
|
||||
'uploader_id' => 1,
|
||||
])->id;
|
||||
};
|
||||
$fileA = $makeFile('voucher/a.jpg');
|
||||
$fileB = $makeFile('voucher/b.jpg');
|
||||
|
||||
$payment = PaymentModel::create([
|
||||
'payment_no' => 'ZF202608140003',
|
||||
'store_id' => $store->id,
|
||||
'user_id' => $user->id,
|
||||
'amount' => '100.00',
|
||||
'pay_method' => PaymentModel::METHOD_BANK,
|
||||
'voucher_ids' => [$fileA, $fileB],
|
||||
'status' => PaymentModel::STATUS_PENDING,
|
||||
]);
|
||||
|
||||
$this->actingAsSysUser();
|
||||
$data = $this->getJson("/recon/payment/{$payment->id}")->assertOk()->json('data');
|
||||
|
||||
$this->assertCount(2, $data['payment']['voucher_urls']);
|
||||
$this->assertStringContainsString('voucher/a.jpg', $data['payment']['voucher_urls'][0]);
|
||||
$this->assertStringContainsString('voucher/b.jpg', $data['payment']['voucher_urls'][1], '凭证顺序保持提交顺序');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user