优化订单状态

This commit is contained in:
Edward Yang 2022-08-26 10:11:28 +08:00
parent 4cb0078572
commit d0fea5ec2d
9 changed files with 21 additions and 37 deletions

View File

@ -25,7 +25,8 @@ class OrderSimple extends JsonResource
'telephone' => $this->telephone,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'status' => trans("admin/order.{$this->status}"),
'status' => $this->status,
'status_format' => $this->status_format,
];
return $data;

View File

@ -25,7 +25,7 @@ class Order extends Base
'payment_address_1', 'payment_address_2',
];
protected $appends = ['total_format'];
protected $appends = ['status_format', 'total_format'];
public function orderProducts(): HasMany
{
@ -42,6 +42,11 @@ class Order extends Base
return $this->hasMany(OrderHistory::class);
}
public function getStatusFormatAttribute()
{
return trans('order.' . $this->status);
}
public function getTotalFormatAttribute()
{
return currency_format($this->total);

View File

@ -85,7 +85,7 @@
<div class="card-body" id="app">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="当前状态">
{{ __('admin/order.' . $order->status) }}
{{ $order->status_format }}
</el-form-item>
<el-form-item label="修改状态" prop="status">
<el-select size="small" v-model="form.status" placeholder="请选择">

View File

@ -61,7 +61,7 @@
<td>{{ $order->number }}</td>
<td>{{ $order->customer_name }}</td>
<td>{{ $order->payment_method_name }}</td>
<td>{{ $order->status }}</td>
<td>{{ $order->status_format }}</td>
<td>{{ $order->total_format }}</td>
<td>{{ $order->created_at }}</td>
<td>{{ $order->updated_at }}</td>

View File

@ -19,9 +19,4 @@ return [
'orders_update' => 'Update',
'orders_delete' => 'Delete',
'orders_update_status' => 'Update Status',
'unpaid' => 'Unpaid',
'paid' => 'Paid',
'shipped' => 'Shipped',
'completed' => 'Completed',
];

View File

@ -20,4 +20,9 @@ return [
'updated_at' => 'Updated',
'status' => 'Status',
'total' => 'Total',
'unpaid' => 'Unpaid',
'paid' => 'Paid',
'shipped' => 'Shipped',
'completed' => 'Completed',
];

View File

@ -19,9 +19,4 @@ return [
'orders_update' => '更新订单',
'orders_delete' => '删除订单',
'orders_update_status' => '更新状态',
'unpaid' => '待支付',
'paid' => '已支付',
'shipped' => '已发货',
'completed' => '已完成',
];

View File

@ -20,4 +20,9 @@ return [
'updated_at' => '更新时间',
'status' => '状态',
'total' => '订单总额',
'unpaid' => '待支付',
'paid' => '已支付',
'shipped' => '已发货',
'completed' => '已完成',
];

View File

@ -76,7 +76,7 @@
<div class="text-muted">{{ __('shop/account.order_time') }}{{ $order->created_at }}</div>
</td>
<td>
<span class="ms-4 d-inline-block">{{ __('shop/account.state') }}{{ $order->status }}</span>
<span class="ms-4 d-inline-block">{{ __('shop/account.state') }}{{ $order->status_format }}</span>
</td>
<td>
<span class="ms-3 d-inline-block">{{ __('shop/account.amount') }}{{ $order->total_format }}</span>
@ -90,28 +90,6 @@
@endforeach
</tbody>
</table>
{{-- @foreach ($latest_orders as $order)
<div class="d-flex justify-content-between align-items-center mb-3">
<div class="d-flex align-items-center">
<div class="img me-3 border wh-70">
@foreach ($order->orderProducts as $product)
<img src="{{ $product->image }}" class="img-fluid">
@endforeach
</div>
<div>
<div class="order-number mb-2">
<span class="wp-200 d-inline-block">订单号:{{ $order->number }}</span>
<span class="wp-200 ms-4 d-inline-block">状态:{{ $order->status }}</span>
<span class=" ms-3 d-inline-block">金额:{{ $order->total }}</span>
</div>
<div class="order-created text-muted">下单时间:{{ $order->created_at }}</div>
</div>
</div>
<a href="{{ shop_route('account.order.show', ['number' => $order->number]) }}"
class="btn btn-outline-secondary btn-sm">查看详情</a>
</div>
@endforeach --}}
</ul>
@endif
</div>