54 lines
996 B
PHP
54 lines
996 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Helpers\Numeric;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class OrderProduct extends Model
|
|
{
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'specs' => 'json',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'user_id',
|
|
'order_id',
|
|
'spu_id',
|
|
'sku_id',
|
|
'category_id',
|
|
'name',
|
|
'specs',
|
|
'cover',
|
|
'weight',
|
|
'sell_price',
|
|
'vip_price',
|
|
'quantity',
|
|
'coupon_discount_amount',
|
|
'vip_discount_amount',
|
|
'reduced_amount',
|
|
'total_amount',
|
|
];
|
|
|
|
/**
|
|
* 获取订单支付金额
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getTotalAmountFormatAttribute()
|
|
{
|
|
return Numeric::trimZero(bcdiv($this->attributes['total_amount'], 100, 2));
|
|
}
|
|
|
|
public function packageProducts()
|
|
{
|
|
return $this->hasMany(OrderPackageProduct::class, 'order_product_id');
|
|
}
|
|
}
|