6
0
Fork 0
release
李静 2021-12-09 11:43:06 +08:00
parent d6819dfe09
commit eaddca989d
4 changed files with 23 additions and 5 deletions

View File

@ -11,6 +11,7 @@ class ShoppingCartItem extends Model
*/ */
protected $casts = [ protected $casts = [
'quantity' => 'int', 'quantity' => 'int',
'specs' => 'json',
]; ];
/** /**
@ -19,6 +20,11 @@ class ShoppingCartItem extends Model
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'sku_id', 'sku_id',
'name',
'cover',
'sell_price',
'vip_price',
'specs',
'quantity', 'quantity',
]; ];
@ -27,6 +33,13 @@ class ShoppingCartItem extends Model
*/ */
public function sku() public function sku()
{ {
return $this->belongsTo(ProductSku::class); return $this->belongsTo(ProductSku::class)->withDefault(function ($sku, $item) {
$sku->id = $item->sku_id;
$sku->name = $item->name;
$sku->cover = $item->cover;
$sku->sell_price = $item->sell_price;
$sku->vip_price = $item->vip_price;
$sku->specs = $item->specs;
});
} }
} }

View File

@ -17,6 +17,11 @@ class CreateShoppingCartItemsTable extends Migration
$table->id(); $table->id();
$table->unsignedBigInteger('user_id')->comment('用户ID'); $table->unsignedBigInteger('user_id')->comment('用户ID');
$table->unsignedBigInteger('sku_id')->comment('商品ID'); $table->unsignedBigInteger('sku_id')->comment('商品ID');
$table->string('name')->comment('商品名称');
$table->string('cover')->nullable()->comment('封面图');
$table->unsignedBigInteger('sell_price')->default(0)->comment('销售价格:分');
$table->unsignedBigInteger('vip_price')->nullable()->comment('会员价格:分');
$table->json('specs')->nullable()->comment('规格属性');
$table->unsignedInteger('quantity')->default(0)->comment('购买数量'); $table->unsignedInteger('quantity')->default(0)->comment('购买数量');
$table->timestamps(); $table->timestamps();

View File

@ -18,12 +18,12 @@ class CreateOrdersTable extends Migration
$table->unsignedBigInteger('user_id')->comment('用户ID'); $table->unsignedBigInteger('user_id')->comment('用户ID');
$table->string('sn')->comment('订单编号'); $table->string('sn')->comment('订单编号');
$table->unsignedBigInteger('user_coupon_id')->nullable()->comment('用户优惠券 ID'); $table->unsignedBigInteger('user_coupon_id')->nullable()->comment('用户优惠券 ID');
$table->unsignedBigInteger('discount_amount')->default(0)->comment('商品优惠'); $table->unsignedBigInteger('coupon_amount')->default(0)->comment('优惠券金额');
$table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠'); $table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠');
$table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额'); $table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额');
$table->unsignedBigInteger('shipping_fee')->default(0)->comment('运费'); $table->unsignedBigInteger('shipping_fee')->default(0)->comment('运费');
$table->unsignedBigInteger('products_total_amount')->comment('商品总额'); $table->unsignedBigInteger('products_total_amount')->comment('商品总额');
$table->unsignedBigInteger('total_amount')->comment('订单总额(支付金额)=商品总额+运费-会员优惠-商品优惠-减免金额'); $table->unsignedBigInteger('total_amount')->comment('订单总额(支付金额)=商品总额+运费-优惠券金额-会员优惠-减免金额');
$table->unsignedInteger('weight')->nullable()->comment('订单重量'); $table->unsignedInteger('weight')->nullable()->comment('订单重量');
$table->string('note')->nullable()->comment('客户备注'); $table->string('note')->nullable()->comment('客户备注');
$table->string('remark')->nullable()->comment('订单备注'); $table->string('remark')->nullable()->comment('订单备注');

View File

@ -28,10 +28,10 @@ class CreateOrderProductsTable extends Migration
$table->unsignedInteger('weight')->nullable()->comment('重量:g'); $table->unsignedInteger('weight')->nullable()->comment('重量:g');
$table->unsignedBigInteger('sell_price')->comment('商品价格'); $table->unsignedBigInteger('sell_price')->comment('商品价格');
$table->unsignedBigInteger('vip_price')->comment('会员价格'); $table->unsignedBigInteger('vip_price')->comment('会员价格');
$table->unsignedBigInteger('discount_amount')->default(0)->comment('商品优惠'); $table->unsignedBigInteger('coupon_amount')->default(0)->comment('优惠券金额');
$table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠'); $table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠');
$table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额'); $table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额');
$table->unsignedBigInteger('total_amount')->comment('商品总额(支付金额)=商品价格*数量-商品优惠-会员优惠-减免金额'); $table->unsignedBigInteger('total_amount')->comment('商品总额(支付金额)=商品价格*数量-优惠券金额-会员优惠-减免金额');
$table->boolean('is_comment')->default(false)->comment('是否评论'); $table->boolean('is_comment')->default(false)->comment('是否评论');
$table->timestamp('after_sale_deadline')->nullable()->comment('售后截止时间'); $table->timestamp('after_sale_deadline')->nullable()->comment('售后截止时间');
$table->timestamps(); $table->timestamps();