小程序用户改用门店登录

This commit is contained in:
liu
2026-08-20 13:46:04 +08:00
parent 6d9f02d831
commit c1d490134e
251 changed files with 689 additions and 2727 deletions
+11 -11
View File
@@ -5,18 +5,18 @@ namespace Tests\Feature;
use App\Models\CustomerLevelModel;
use App\Models\ProductModel;
use App\Models\StoreModel;
use App\Models\UserModel;
/**
* 小程序商品:商品详情接口(免登录浏览,登录门店按等级上浮比例显示换算价);
* 商品列表回归:登录门店场景曾数组误用对象访问 + 价格缺失导致 500
* (门店即用户:登录主体为 StoreModel
*/
class MiniProductTest extends ProcurementTestCase
{
/**
* 造门店 + 上架商品(成本价即售价,等级上浮 0%)
*
* @return array{0: StoreModel, 1: ProductModel, 2: UserModel, 3: CustomerLevelModel}
* @return array{0: StoreModel, 1: ProductModel, 2: CustomerLevelModel}
*/
private function makeStoreWithProduct(string $price = '5.00'): array
{
@@ -27,7 +27,7 @@ class MiniProductTest extends ProcurementTestCase
'cost_price' => $price,
]);
return [$store, $product, UserModel::factory()->forStore($store->id)->create(), $level];
return [$store, $product, $level];
}
/** 商品详情:未登录浏览 price=null,基础字段完整 */
@@ -45,10 +45,10 @@ class MiniProductTest extends ProcurementTestCase
}
/** 商品详情:登录门店按等级显示固定价 */
public function test_product_detail_store_user_sees_level_price(): void
public function test_product_detail_store_sees_level_price(): void
{
[, $product, $user] = $this->makeStoreWithProduct('6.50');
$this->actingAsMiniUser($user);
[$store, $product] = $this->makeStoreWithProduct('6.50');
$this->actingAsMiniStore($store);
$data = $this->getJson("/mini/product/{$product->id}")->assertOk()->json('data');
@@ -58,10 +58,10 @@ class MiniProductTest extends ProcurementTestCase
/** 商品详情:按门店等级上浮比例换算(成本价上浮 30%) */
public function test_product_detail_percent_price_calculated_from_cost(): void
{
[, $product, $user, $level] = $this->makeStoreWithProduct();
[$store, $product, $level] = $this->makeStoreWithProduct();
$level->update(['percent' => 30]);
$product->update(['cost_price' => '20.00']);
$this->actingAsMiniUser($user);
$this->actingAsMiniStore($store);
$data = $this->getJson("/mini/product/{$product->id}")->assertOk()->json('data');
@@ -79,10 +79,10 @@ class MiniProductTest extends ProcurementTestCase
}
/** 商品列表:登录门店显示等级价(回归:曾数组误用对象访问导致 500) */
public function test_product_list_store_user_sees_level_price(): void
public function test_product_list_store_sees_level_price(): void
{
[, $product, $user] = $this->makeStoreWithProduct('7.00');
$this->actingAsMiniUser($user);
[$store, $product] = $this->makeStoreWithProduct('7.00');
$this->actingAsMiniStore($store);
$rows = $this->getJson('/mini/product/list')->assertOk()->json('data.data');
$row = collect($rows)->firstWhere('id', $product->id);