客户等级设置
This commit is contained in:
@@ -4,14 +4,13 @@ namespace Tests\Feature;
|
||||
|
||||
use App\Models\CustomerLevelModel;
|
||||
use App\Models\ProductModel;
|
||||
use App\Models\ProductPriceModel;
|
||||
use App\Models\StoreModel;
|
||||
use App\Models\StoreOrderModel;
|
||||
use App\Models\UserModel;
|
||||
use Modules\SystemTool\Models\SysFileModel;
|
||||
|
||||
/**
|
||||
* 小程序下单:等级价快照、服务端重算总价、取消限制、门店数据隔离
|
||||
* 小程序下单:等级上浮价快照、服务端重算总价、取消限制、门店数据隔离
|
||||
*/
|
||||
class StoreOrderTest extends ProcurementTestCase
|
||||
{
|
||||
@@ -22,11 +21,9 @@ class StoreOrderTest extends ProcurementTestCase
|
||||
{
|
||||
$level = CustomerLevelModel::factory()->create();
|
||||
$store = StoreModel::factory()->create(['level_id' => $level->id]);
|
||||
$product = ProductModel::factory()->create(['status' => ProductModel::STATUS_ON]);
|
||||
ProductPriceModel::factory()->create([
|
||||
'product_id' => $product->id,
|
||||
'level_id' => $level->id,
|
||||
'price' => $price,
|
||||
$product = ProductModel::factory()->create([
|
||||
'status' => ProductModel::STATUS_ON,
|
||||
'cost_price' => $price,
|
||||
]);
|
||||
|
||||
return [$store, $product, UserModel::factory()->forStore($store->id)->create()];
|
||||
@@ -73,11 +70,11 @@ class StoreOrderTest extends ProcurementTestCase
|
||||
$this->assertSame('10.00', (string) $order->total_amount, '应按等级价 5.00×2 计算,忽略前端金额');
|
||||
}
|
||||
|
||||
/** 商品未设置门店等级价格时拒绝下单 */
|
||||
public function test_product_without_level_price_rejected(): void
|
||||
/** 门店绑定的客户等级被删除时拒绝下单 */
|
||||
public function test_store_level_missing_rejected(): void
|
||||
{
|
||||
[, $product, $user] = $this->makeStoreWithProduct('5.00');
|
||||
ProductPriceModel::where('product_id', $product->id)->delete();
|
||||
[$store, $product, $user] = $this->makeStoreWithProduct('5.00');
|
||||
CustomerLevelModel::whereKey($store->level_id)->delete();
|
||||
$this->actingAsMiniUser($user);
|
||||
|
||||
$this->postJson('/mini/order', [
|
||||
@@ -140,8 +137,7 @@ class StoreOrderTest extends ProcurementTestCase
|
||||
|
||||
$items = [];
|
||||
foreach (['白菜', '土豆', '番茄', '黄瓜'] as $name) {
|
||||
$product = ProductModel::factory()->create(['name' => $name, 'status' => ProductModel::STATUS_ON]);
|
||||
ProductPriceModel::factory()->create(['product_id' => $product->id, 'level_id' => $level->id, 'price' => 5.00]);
|
||||
$product = ProductModel::factory()->create(['name' => $name, 'status' => ProductModel::STATUS_ON, 'cost_price' => '5.00']);
|
||||
$items[] = ['product_id' => $product->id, 'quantity' => 2];
|
||||
}
|
||||
$this->postJson('/mini/order', ['items' => $items])->assertJsonPath('success', true);
|
||||
@@ -345,11 +341,7 @@ class StoreOrderTest extends ProcurementTestCase
|
||||
'spec' => '30斤/筐',
|
||||
'unit' => '筐',
|
||||
'image_ids' => (string) $file->id,
|
||||
]);
|
||||
ProductPriceModel::factory()->create([
|
||||
'product_id' => $product->id,
|
||||
'level_id' => $level->id,
|
||||
'price' => '5.00',
|
||||
'cost_price' => '5.00',
|
||||
]);
|
||||
$user = UserModel::factory()->forStore($store->id)->create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user