0, 'points_deduction_amount' => 0, ]; protected $fillable = [ 'order_id', 'product_category_id', 'products_total_amount', 'discount_reduction_amount', 'points_deduction_amount', 'payment_amount', ]; public function order() { return $this->belongsTo(OfflineOrder::class, 'order_id'); } public function productCategory() { return $this->belongsTo(OfflineProductCategory::class, 'product_category_id'); } public function getDiscount() { $discount = ''; if ($this->discount_reduction_amount > 0 && $this->products_total_amount > 0) { // 应付金额 $total = $this->products_total_amount - $this->discount_reduction_amount; $discount = round(bcdiv($total * 10, $this->products_total_amount, 3), 2); } return $discount; } }