小程序用户改用门店登录
This commit is contained in:
@@ -8,27 +8,21 @@ use App\Models\PurchaseOrderModel;
|
||||
use App\Models\StoreModel;
|
||||
use App\Models\StoreOrderItemModel;
|
||||
use App\Models\StoreOrderModel;
|
||||
use App\Models\UserModel;
|
||||
use Modules\SystemTool\Models\SysFileModel;
|
||||
|
||||
/**
|
||||
* 小程序账单:支付进度推导(待支付/审核中/已支付)、应结算日期(回款周期)、
|
||||
* 待支付汇总、可付款筛选、门店数据隔离、详情归属校验
|
||||
* (门店即用户:账单按 store_id 归属)
|
||||
*/
|
||||
class MiniBillTest extends ProcurementTestCase
|
||||
{
|
||||
private static int $billSeq = 0;
|
||||
|
||||
/**
|
||||
* 造一个绑定正常门店的小程序用户
|
||||
*
|
||||
* @return array{0: StoreModel, 1: UserModel}
|
||||
*/
|
||||
private function makeStoreWithUser(int $cycleDays = 3): array
|
||||
/** 造一家门店(指定回款周期) */
|
||||
private function makeStore(int $cycleDays = 3): StoreModel
|
||||
{
|
||||
$store = StoreModel::factory()->paymentCycle($cycleDays)->create();
|
||||
|
||||
return [$store, UserModel::factory()->forStore($store->id)->create()];
|
||||
return StoreModel::factory()->paymentCycle($cycleDays)->create();
|
||||
}
|
||||
|
||||
/** 造一张账单(默认 2026-08-10 出账,总额 140.00,未支付) */
|
||||
@@ -56,8 +50,8 @@ class MiniBillTest extends ProcurementTestCase
|
||||
/** 支付进度推导与应结算日期(账单日期 + 门店回款周期) */
|
||||
public function test_bill_list_derives_pay_state_and_settlement_date(): void
|
||||
{
|
||||
[$store, $user] = $this->makeStoreWithUser(3);
|
||||
$this->actingAsMiniUser($user);
|
||||
$store = $this->makeStore(3);
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$unpaid = $this->makeBill($store);
|
||||
$reviewing = $this->makeBill($store, ['payment_id' => 99]);
|
||||
@@ -88,8 +82,8 @@ class MiniBillTest extends ProcurementTestCase
|
||||
/** 待支付汇总:未支付笔数/金额(含审核中),不受列表筛选影响 */
|
||||
public function test_bill_list_summary_aggregates_unpaid(): void
|
||||
{
|
||||
[$store, $user] = $this->makeStoreWithUser();
|
||||
$this->actingAsMiniUser($user);
|
||||
$store = $this->makeStore();
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$this->makeBill($store, ['total_amount' => '100.00']);
|
||||
$this->makeBill($store, ['total_amount' => '50.50', 'payment_id' => 99]);
|
||||
@@ -104,8 +98,8 @@ class MiniBillTest extends ProcurementTestCase
|
||||
/** 可付款筛选:仅未支付且未锁定到支付记录的账单(合并付款选择页) */
|
||||
public function test_bill_list_payable_filter(): void
|
||||
{
|
||||
[$store, $user] = $this->makeStoreWithUser();
|
||||
$this->actingAsMiniUser($user);
|
||||
$store = $this->makeStore();
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$payable = $this->makeBill($store);
|
||||
$this->makeBill($store, ['payment_id' => 99]);
|
||||
@@ -119,8 +113,8 @@ class MiniBillTest extends ProcurementTestCase
|
||||
/** 账单日期区间筛选 */
|
||||
public function test_bill_list_filters_by_bill_date_range(): void
|
||||
{
|
||||
[$store, $user] = $this->makeStoreWithUser();
|
||||
$this->actingAsMiniUser($user);
|
||||
$store = $this->makeStore();
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$this->makeBill($store, ['bill_date' => '2026-08-01']);
|
||||
$this->makeBill($store, ['bill_date' => '2026-08-05']);
|
||||
@@ -134,11 +128,11 @@ class MiniBillTest extends ProcurementTestCase
|
||||
/** 门店数据隔离:只能查看本店账单 */
|
||||
public function test_bill_data_isolated_between_stores(): void
|
||||
{
|
||||
[$storeA] = $this->makeStoreWithUser();
|
||||
$storeA = $this->makeStore();
|
||||
$billOfA = $this->makeBill($storeA);
|
||||
|
||||
[, $userB] = $this->makeStoreWithUser();
|
||||
$this->actingAsMiniUser($userB);
|
||||
$storeB = $this->makeStore();
|
||||
$this->actingAsMiniStore($storeB);
|
||||
|
||||
$this->getJson('/mini/bill')->assertJsonPath('data.total', 0);
|
||||
$this->getJson("/mini/bill/{$billOfA->id}")->assertJsonPath('success', false);
|
||||
@@ -147,8 +141,8 @@ class MiniBillTest extends ProcurementTestCase
|
||||
/** 详情:格式化账单 + 合并商品明细 + 关联订单 */
|
||||
public function test_bill_detail_outputs_bill_items_and_orders(): void
|
||||
{
|
||||
[$store, $user] = $this->makeStoreWithUser(0);
|
||||
$this->actingAsMiniUser($user);
|
||||
$store = $this->makeStore(0);
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$file = SysFileModel::create([
|
||||
'group_id' => 1,
|
||||
|
||||
Reference in New Issue
Block a user