小程序用户改用门店登录
This commit is contained in:
@@ -7,7 +7,6 @@ use App\Models\NoticeModel;
|
||||
use App\Models\ProductCategoryModel;
|
||||
use App\Models\ProductModel;
|
||||
use App\Models\StoreModel;
|
||||
use App\Models\UserModel;
|
||||
|
||||
/**
|
||||
* 商品成本价 + 等级上浮计价:
|
||||
@@ -26,7 +25,7 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/** 造门店(等级上浮 percent)+ 上架商品(成本价 cost) + 该店用户 */
|
||||
/** 造门店(等级上浮 percent)+ 上架商品(成本价 cost) */
|
||||
private function makeStoreWithPercentProduct(float $cost = 10, float $percent = 30): array
|
||||
{
|
||||
$level = CustomerLevelModel::factory()->create(['percent' => $percent]);
|
||||
@@ -36,7 +35,7 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
'cost_price' => $cost,
|
||||
]);
|
||||
|
||||
return [$store, $product, UserModel::factory()->forStore($store->id)->create()];
|
||||
return [$store, $product];
|
||||
}
|
||||
|
||||
/** 售价换算:成本价 × (100 + percent) / 100 */
|
||||
@@ -78,8 +77,8 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
/** 小程序列表:返回换算后实际价,且成本价不泄漏 */
|
||||
public function test_mini_list_returns_actual_price_without_cost_price(): void
|
||||
{
|
||||
[$store, $product, $user] = $this->makeStoreWithPercentProduct();
|
||||
$this->actingAsMiniUser($user);
|
||||
[$store, $product] = $this->makeStoreWithPercentProduct();
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$response = $this->getJson('/mini/product/list');
|
||||
$response->assertOk()->assertJsonPath('success', true);
|
||||
@@ -116,7 +115,6 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
|
||||
$level = CustomerLevelModel::factory()->create(['percent' => 30]);
|
||||
$store = StoreModel::factory()->create(['level_id' => $level->id]);
|
||||
$user = UserModel::factory()->forStore($store->id)->create();
|
||||
$product = ProductModel::factory()->create(['cost_price' => 10]);
|
||||
|
||||
$this->putJson('/product/goods/batchPrice', [
|
||||
@@ -125,15 +123,15 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
],
|
||||
])->assertOk()->assertJsonPath('success', true);
|
||||
|
||||
$this->assertSame('20.00', (string) $product->fresh()->cost_price, '成本价应已更新');
|
||||
$this->assertSame('20.00', (string) $product->refresh()->cost_price, '成本价应已更新');
|
||||
$this->assertSame(
|
||||
1,
|
||||
NoticeModel::where('user_id', $user->id)->where('type', NoticeModel::TYPE_PRICE)->count(),
|
||||
'门店用户应收到价格变更通知'
|
||||
NoticeModel::where('store_id', $store->id)->where('type', NoticeModel::TYPE_PRICE)->count(),
|
||||
'门店应收到价格变更通知'
|
||||
);
|
||||
|
||||
// 等级售价联动:20 元上浮 30% = 26.00
|
||||
$this->actingAsMiniUser($user);
|
||||
$this->actingAsMiniStore($store);
|
||||
$row = collect($this->getJson('/mini/product/list')->json('data.data'))->firstWhere('id', $product->id);
|
||||
$this->assertSame('26.00', (string) $row['price'], '成本变更后小程序端售价应按上浮比例联动');
|
||||
}
|
||||
@@ -178,8 +176,8 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
/** 小程序下单:按等级上浮换算价重算金额并快照 */
|
||||
public function test_mini_order_uses_level_price(): void
|
||||
{
|
||||
[$store, $product, $user] = $this->makeStoreWithPercentProduct(10, 30);
|
||||
$this->actingAsMiniUser($user);
|
||||
[$store, $product] = $this->makeStoreWithPercentProduct(10, 30);
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$this->postJson('/mini/order', [
|
||||
'items' => [['product_id' => $product->id, 'quantity' => 3]],
|
||||
@@ -195,8 +193,8 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
/** 小程序购物车:列表金额按等级上浮换算价计算 */
|
||||
public function test_mini_cart_uses_level_price(): void
|
||||
{
|
||||
[$store, $product, $user] = $this->makeStoreWithPercentProduct(10, 30);
|
||||
$this->actingAsMiniUser($user);
|
||||
[$store, $product] = $this->makeStoreWithPercentProduct(10, 30);
|
||||
$this->actingAsMiniStore($store);
|
||||
|
||||
$this->postJson('/mini/cart', ['product_id' => $product->id, 'quantity' => 2.5])
|
||||
->assertOk()->assertJsonPath('success', true);
|
||||
|
||||
Reference in New Issue
Block a user