|
|
@@ -38,8 +38,14 @@ class ExpressOrderResource extends JsonResource
|
|
|
$baseDiscount = (float) ($this->base_discount_amount ?? $discount);
|
|
|
$giftcard = (float) ($this->giftcard_amount ?? 0);
|
|
|
$baseGiftcard = (float) ($this->base_giftcard_amount ?? $giftcard);
|
|
|
- $grandTotal = max(0, $subTotal - $discount - $giftcard);
|
|
|
- $baseGrandTotal = max(0, $baseSubTotal - $baseDiscount - $baseGiftcard);
|
|
|
+ $vipPlus = (float) ($this->vip_plus_amount ?? 0);
|
|
|
+ $baseVipPlus = (float) ($this->base_vip_plus_amount ?? $vipPlus);
|
|
|
+ $vipDiscount = (float) ($this->vip_discount_amount ?? 0);
|
|
|
+ $baseVipDiscount = (float) ($this->base_vip_discount_amount ?? $vipDiscount);
|
|
|
+ $shippingInsurance = (float) ($this->shipping_insurance_amount ?? 0);
|
|
|
+ $baseShippingInsurance = (float) ($this->base_shipping_insurance_amount ?? $shippingInsurance);
|
|
|
+ $grandTotal = max(0, $subTotal - $discount - $giftcard + $vipPlus - $vipDiscount + $shippingInsurance);
|
|
|
+ $baseGrandTotal = max(0, $baseSubTotal - $baseDiscount - $baseGiftcard + $baseVipPlus - $baseVipDiscount + $baseShippingInsurance);
|
|
|
|
|
|
return [
|
|
|
'cart_id' => $this->id,
|
|
|
@@ -76,6 +82,14 @@ class ExpressOrderResource extends JsonResource
|
|
|
'giftcard_amount' => $giftcard,
|
|
|
'base_giftcard_amount' => $baseGiftcard,
|
|
|
]),
|
|
|
+ $this->mergeWhen($this->vip_plus_amount && $this->vip_plus_amount > 0, [
|
|
|
+ 'vip_plus_amount' => $this->vip_plus_amount,
|
|
|
+ 'base_vip_plus_amount' => $this->base_vip_plus_amount,
|
|
|
+ ]),
|
|
|
+ $this->mergeWhen($this->vip_discount_amount && $this->vip_discount_amount > 0, [
|
|
|
+ 'vip_discount_amount' => $this->vip_discount_amount,
|
|
|
+ 'base_vip_discount_amount' => $this->base_vip_discount_amount,
|
|
|
+ ]),
|
|
|
$this->mergeWhen($this->shipping_insurance_amount && $this->shipping_insurance_amount > 0, [
|
|
|
'shipping_insurance_amount' => $this->shipping_insurance_amount,
|
|
|
'base_shipping_insurance_amount' => $this->base_shipping_insurance_amount,
|