fixed total format

This commit is contained in:
Edward Yang 2022-08-24 18:30:24 +08:00
parent c97c715bd8
commit b194c7670f
8 changed files with 29 additions and 9 deletions

View File

@ -25,6 +25,8 @@ class Order extends Base
'payment_address_1', 'payment_address_2',
];
protected $appends = ['total_format'];
public function orderProducts(): HasMany
{
return $this->hasMany(OrderProduct::class);
@ -39,4 +41,9 @@ class Order extends Base
{
return $this->hasMany(OrderHistory::class);
}
public function getTotalFormatAttribute()
{
return currency_format($this->total);
}
}

View File

@ -24,4 +24,11 @@ class OrderProduct extends Base
return $this->belongsTo(Order::class);
}
protected $appends = ['price_format'];
public function getPriceFormatAttribute()
{
return currency_format($this->price);
}
}

View File

@ -16,4 +16,11 @@ class OrderTotal extends Base
protected $fillable = [
'order_id', 'code', 'value', 'title', 'reference'
];
protected $appends = ['value_format'];
public function getValueFormatAttribute()
{
return currency_format($this->value);
}
}

View File

@ -13,7 +13,6 @@ namespace Beike\Repositories;
use Beike\Models\Order;
use Beike\Models\OrderProduct;
use Beike\Models\Rma;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

View File

@ -20,7 +20,7 @@
</tr>
<tr>
<td>总计:</td>
<td>{{ $order->total }}</td>
<td>{{ $order->total_format }}</td>
</tr>
</tbody>
</table>
@ -134,7 +134,7 @@
<div class="wh-60 me-2"><img src="{{ $product->image }}" class="img-fluid"></div>{{ $product->name }}
</div>
</td>
<td>{{ $product->price }}</td>
<td>{{ $product->price_format }}</td>
<td class="text-end">{{ $product->quantity }}</td>
<td class="text-end">{{ $product->product_sku }}</td>
</tr>
@ -144,7 +144,7 @@
@foreach ($order->orderTotals as $orderTotal)
<tr>
<td colspan="4" class="text-end">{{ $orderTotal->title }}</td>
<td class="text-end"><span class="fw-bold">{{ $orderTotal->value }}</span></td>
<td class="text-end"><span class="fw-bold">{{ $orderTotal->value_format }}</span></td>
</tr>
@endforeach
</tfoot>

View File

@ -62,7 +62,7 @@
<td>{{ $order->customer_name }}</td>
<td>{{ $order->payment_method_name }}</td>
<td>{{ $order->status }}</td>
<td>{{ $order->total }}</td>
<td>{{ $order->total_format }}</td>
<td>{{ $order->created_at }}</td>
<td>{{ $order->updated_at }}</td>
<td><a href="{{ admin_route('orders.show', [$order->id]) }}" class="btn btn-outline-secondary btn-sm">查看</a>

View File

@ -79,7 +79,7 @@
<span class="ms-4 d-inline-block">{{ __('shop/account.state') }}{{ $order->status }}</span>
</td>
<td>
<span class="ms-3 d-inline-block">{{ __('shop/account.amount') }}{{ $order->total }}</span>
<span class="ms-3 d-inline-block">{{ __('shop/account.amount') }}{{ $order->total_format }}</span>
</td>
<td>

View File

@ -42,7 +42,7 @@
<td>
{{ __("common.order.{$order->status}") }}
</td>
<td>{{ currency_format($order->total) }}</td>
<td>{{ $order->total_format }}</td>
</tr>
</tbody>
</table>
@ -61,7 +61,7 @@
<div class="left"><img src="{{ $product->image }}" class="img-fluid"></div>
<div class="right">
<div class="name">{{ $product->name }} x {{ $product->quantity }}</div>
<div class="price">{{ currency_format($product->price) }}</div>
<div class="price">{{ $product->price_format }}</div>
</div>
</div>
@if ($order->status == 'completed')
@ -84,7 +84,7 @@
<tr>
@foreach ($totals as $total)
<td class="bg-light wp-200">{{ $total->title }}</td>
<td><strong>{{ $total->value }}</strong></td>
<td><strong>{{ $total->value_format }}</strong></td>
@endforeach
</tr>
@endforeach