Commit 6dc0d7c7 authored by 刘小敏's avatar 刘小敏

feat(order): 导出及详情增加商品规格编号和ID

parent af50af65
......@@ -151,7 +151,9 @@ class Order extends Common
// 更新包裹信息(5分钟缓存)
(new ExpressLib)->updateOrderExpress($id);
$order = $this->model->withTrashed()->with(['user', 'items', 'address', 'activity_orders', 'pays', 'invoice'])->where('id', $id)->find();
$order = $this->model->withTrashed()->with(['user', 'items' => function ($query) {
$query->with(['skuPrice']);
}, 'address', 'activity_orders', 'pays', 'invoice'])->where('id', $id)->find();
if (!$order) {
$this->error(__('No Results were found'));
}
......@@ -726,8 +728,11 @@ class Order extends Common
// 订单商品表字段
'activity_type_text' => '活动',
'promo_types' => '促销',
'promo_types' => '促销',
'goods_id' => '商品ID',
'goods_title' => '商品名称',
'goods_sn' => '商品规格编号',
'goods_sku_price_id' => '商品规格ID',
'goods_sku_text' => '商品规格',
'goods_num' => '购买数量',
'goods_original_price' => '商品原价',
......@@ -768,7 +773,7 @@ class Order extends Common
$total_score_amount = 0;
$result = $export->export($params, function ($pages) use (&$total_order_amount, &$total_pay_fee, &$total_real_pay_fee, &$total_discount_fee, &$total_score_amount, $total) {
$datas = $this->model->withTrashed()->sheepFilter()->with(['user', 'items' => function ($query) {
$query->with(['express']);
$query->with(['express', 'skuPrice']);
}, 'address'])
->limit((($pages['page'] - 1) * $pages['list_rows']), $pages['list_rows'])
->select();
......@@ -820,7 +825,10 @@ class Order extends Common
$items[] = [
'activity_type_text' => $item['activity_type_text'],
'promo_types_text' => is_array($item['promo_types_text']) ? join(',', $item['promo_types_text']) : ($item['promo_types_text'] ?: '-'),
'goods_id' => $item['sku_price'] ? $item['sku_price']['goods_id'] : '-',
'goods_title' => $item['goods_title'],
'goods_sn' => $item['sku_price'] ? $item['sku_price']['sn'] : '-',
'goods_sku_price_id' => $item['goods_sku_price_id'] ?: '-',
'goods_sku_text' => $item['goods_sku_text'],
'goods_num' => $item['goods_num'],
'goods_original_price' => $item['goods_original_price'],
......
......@@ -6,6 +6,7 @@ use app\admin\model\shopro\Common;
use app\admin\model\shopro\order\traits\OrderItemStatus;
use app\admin\model\shopro\activity\Activity;
use app\admin\model\shopro\user\User;
use app\admin\model\shopro\goods\SkuPrice;
class OrderItem extends Common
{
......@@ -224,4 +225,9 @@ class OrderItem extends Common
{
return $this->belongsTo(User::class, 'user_id');
}
public function skuPrice()
{
return $this->belongsTo(SkuPrice::class, 'goods_sku_price_id');
}
}
......@@ -480,6 +480,7 @@
<table class="sku-table" rules="all">
<thead>
<tr>
<th>商品规格ID</th>
<template v-for="(sku, skuIndex) in form.model.skus" :key="skuIndex">
<th v-if="sku.children.length">{{ sku.name }}</th>
</template>
......@@ -634,11 +635,14 @@
</el-popover>
</div>
</th>
<th>状态</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<tr v-for="(skuPrice,i) in form.model.sku_prices" :key="skuPrice.sku_key">
<td class="sku-id">
<span>{{ skuPrice.id ? skuPrice.id : '-' }}</span>
</td>
<template v-for="skuName in skuPrice.goods_sku_text" :key="skuName">
<td>
<span class="th-center">{{ skuName }}</span>
......
......@@ -839,6 +839,16 @@
</div>
</template>
</el-table-column>
<el-table-column label="商品规格编号" min-width="120">
<template #default="scope">
{{ scope.row.sku_price ? scope.row.sku_price.sn : '-' }}
</template>
</el-table-column>
<el-table-column label="商品规格ID" min-width="100">
<template #default="scope">
{{ scope.row.sku_price ? scope.row.sku_price.id : '-' }}
</template>
</el-table-column>
<el-table-column prop="goods_price" label="单价(元)" min-width="100">
</el-table-column>
<el-table-column prop="goods_num" label="数量(件)" min-width="80"></el-table-column>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment