From 5a3995d6baa6b3956d62195aa1a63cc1121a3924 Mon Sep 17 00:00:00 2001 From: liu <2302563948@qq.com> Date: Tue, 11 Aug 2026 18:35:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/StoreOrderController.php | 30 +++- app/Models/StoreOrderItemModel.php | 2 +- app/Models/StoreOrderModel.php | 29 ++-- ..._07_23_030610_create_store_order_table.php | 12 +- web/domain/iStoreOrder.ts | 30 ++-- web/pages/order/store.tsx | 136 +++++++++++++++--- 6 files changed, 194 insertions(+), 45 deletions(-) diff --git a/app/Http/Controllers/Order/StoreOrderController.php b/app/Http/Controllers/Order/StoreOrderController.php index af98c41..626f7fb 100644 --- a/app/Http/Controllers/Order/StoreOrderController.php +++ b/app/Http/Controllers/Order/StoreOrderController.php @@ -22,10 +22,11 @@ use Modules\Common\Http\Controllers\BaseController; class StoreOrderController extends BaseController { /** 状态中文名(通知文案用) */ - private const STATUS_NAMES = [ - StoreOrderModel::STATUS_PENDING => '待汇总', - StoreOrderModel::STATUS_SUMMARIZED => '已汇总', - StoreOrderModel::STATUS_DELIVERING => '配送中', + private const array STATUS_NAMES = [ + StoreOrderModel::STATUS_PENDING => '待接单', + StoreOrderModel::STATUS_SUMMARIZED => '已接单', + StoreOrderModel::STATUS_DELIVERING => '采购中', + StoreOrderModel::STATUS_DISTRIBUTION => '配送中', StoreOrderModel::STATUS_COMPLETED => '已完成', StoreOrderModel::STATUS_CANCELLED => '已取消', ]; @@ -43,11 +44,30 @@ class StoreOrderController extends BaseController { $params = $request->all(); $pageSize = $params['pageSize'] ?? 10; - $data = $this->buildSearch($params, StoreOrderModel::query()->with('store:id,name')) + $query = StoreOrderModel::query()->with([ + 'store:id,name,address,contact,phone', + 'items:id,order_id,product_id,product_name,product_spec,price,quantity,amount', + 'items.product' + ]); + $data = $this->buildSearch($params, $query) ->orderBy('order_date', 'desc') ->orderBy('id', 'desc') ->paginate($pageSize) ->toArray(); + $box_amount = site_config('services.box_amount'); + $tray_amount = site_config('services.tray_amount'); + foreach ($data['data'] as &$item) { + $item['box_amount'] = number_format($box_amount * $item['box_num'], 2); + $item['tray_amount'] = number_format($tray_amount * $item['tray_num'], 2); + if(count($item['items']) > 0) { + foreach ($item['items'] as &$product) { + if($product['product'] && $product['product']['images_arr'] > 0) { + $product['image'] = $product['product']['images_arr'][0]['preview_url'] ?? ''; + unset($product['product']); + } + } + } + } return $this->success($data); } diff --git a/app/Models/StoreOrderItemModel.php b/app/Models/StoreOrderItemModel.php index 9ff24fb..569b6b4 100644 --- a/app/Models/StoreOrderItemModel.php +++ b/app/Models/StoreOrderItemModel.php @@ -34,7 +34,7 @@ class StoreOrderItemModel extends Model 'store_id' => 'integer', 'product_id' => 'integer', 'price' => 'decimal:2', - 'quantity' => 'decimal:2', + 'quantity' => 'integer', 'weight' => 'decimal:3', 'amount' => 'decimal:2', ]; diff --git a/app/Models/StoreOrderModel.php b/app/Models/StoreOrderModel.php index d742960..7e246da 100644 --- a/app/Models/StoreOrderModel.php +++ b/app/Models/StoreOrderModel.php @@ -14,16 +14,18 @@ class StoreOrderModel extends Model { use HasFactory; - /** 状态:待汇总(可被采购单生成归集、可取消) */ - public const STATUS_PENDING = 0; - /** 状态:已汇总(已生成采购单) */ - public const STATUS_SUMMARIZED = 1; + /** 状态:待接单(可被采购单生成归集、可取消) */ + public const int STATUS_PENDING = 0; + /** 状态:已接单(已生成采购单) */ + public const int STATUS_SUMMARIZED = 1; + /** 状态:采购中 */ + public const int STATUS_DELIVERING = 2; /** 状态:配送中 */ - public const STATUS_DELIVERING = 2; + public const int STATUS_DISTRIBUTION = 3; /** 状态:已完成 */ - public const STATUS_COMPLETED = 3; + public const int STATUS_COMPLETED = 4; /** 状态:已取消 */ - public const STATUS_CANCELLED = 9; + public const int STATUS_CANCELLED = 9; protected $table = 'store_order'; protected $primaryKey = 'id'; @@ -35,17 +37,28 @@ class StoreOrderModel extends Model 'total_quantity', 'total_weight', 'total_amount', + 'product_amount', + 'added_amount', + 'box_num', + 'tray_num', 'status', 'remark', ]; protected $casts = [ 'store_id' => 'integer', + 'purchase_id' => 'integer', + 'statement_id' => 'integer', 'order_date' => 'date:Y-m-d', - 'total_quantity' => 'decimal:2', + 'total_quantity' => 'integer', 'total_weight' => 'decimal:3', 'total_amount' => 'decimal:2', + 'product_amount' => 'decimal:2', + 'added_amount' => 'decimal:2', + 'box_num' => 'integer', + 'tray_num' => 'integer', 'status' => 'integer', + 'created_at' => 'datetime:Y-m-d H:i:s', ]; /** diff --git a/database/migrations/2026_07_23_030610_create_store_order_table.php b/database/migrations/2026_07_23_030610_create_store_order_table.php index f26182f..abac1fe 100644 --- a/database/migrations/2026_07_23_030610_create_store_order_table.php +++ b/database/migrations/2026_07_23_030610_create_store_order_table.php @@ -18,11 +18,17 @@ return new class extends Migration $table->increments('id')->comment('订单ID'); $table->string('order_no', 32)->unique()->comment('订单编号'); $table->integer('store_id')->comment('门店ID'); + $table->integer('purchase_id')->nullable()->comment('关联采购单ID'); + $table->integer('statement_id')->nullable()->comment('关联账单ID'); $table->date('order_date')->comment('订货日期'); - $table->decimal('total_quantity', 10, 2)->default(0)->comment('订货总量'); + $table->integer('total_quantity', 10)->default(0)->comment('订货总量'); $table->decimal('total_weight', 10, 3)->default(0)->comment('总重量'); $table->decimal('total_amount', 10, 2)->default(0)->comment('订单总金额'); - $table->integer('status')->default(0)->comment('订单状态(0待汇总 1已汇总 2配送中 3已完成 9已取消)'); + $table->decimal('product_amount', 10, 2)->default(0)->comment('商品总金额'); + $table->decimal('added_amount', 10, 2)->default(0)->comment('附加金额'); + $table->decimal('box_num', 10, 2)->default(0)->comment('周转框数量'); + $table->decimal('tray_num', 10, 2)->default(0)->comment('周转托盘数量'); + $table->integer('status')->default(0)->comment('订单状态(0待接单 1已接单 2采购中 3配送中 4已完成 9已取消)'); $table->string('remark', 255)->default('')->comment('订单备注'); $table->timestamps(); $table->index(['store_id', 'order_date'], 'store_order_store_date_index'); @@ -41,7 +47,7 @@ return new class extends Migration $table->string('product_name', 100)->comment('品名(快照)'); $table->string('product_spec', 100)->default('')->comment('规格/包规(快照)'); $table->decimal('price', 10, 2)->default(0)->comment('单价(下单时客户等级价快照)'); - $table->decimal('quantity', 10, 2)->default(0)->comment('订货量'); + $table->integer('quantity', 10)->default(0)->comment('订货量'); $table->decimal('weight', 10, 3)->default(0)->comment('重量'); $table->decimal('amount', 10, 2)->default(0)->comment('单品金额'); $table->string('remark', 255)->default('')->comment('门店下单备注'); diff --git a/web/domain/iStoreOrder.ts b/web/domain/iStoreOrder.ts index eba9e17..385c612 100644 --- a/web/domain/iStoreOrder.ts +++ b/web/domain/iStoreOrder.ts @@ -7,7 +7,8 @@ export interface IStoreOrderItem { product_name?: string; product_spec?: string; price?: string; - quantity?: string; + image?: string; + quantity?: number; weight?: string; amount?: string; remark?: string; @@ -18,12 +19,24 @@ export default interface IStoreOrder { id?: number; order_no?: string; store_id?: number; - store?: { id: number; name: string }; + purchase_id?: number; + statement_id?: number; + store?: { + id: number; + name: string; + address: string; + contact: string; + phone: string; + }; order_date?: string; - total_quantity?: string; + total_quantity?: number; total_weight?: string; total_amount?: string; - /** 0待汇总 1已汇总 2配送中 3已完成 9已取消 */ + product_amount: string; + added_amount: string; + box_num: number; + tray_num: number; + /** 0待接单 1已接单 2采购中 3配送中 4已完成 9已取消 */ status?: number; remark?: string; items?: IStoreOrderItem[]; @@ -31,10 +44,11 @@ export default interface IStoreOrder { } export const STORE_ORDER_STATUS_MAP: Record = { - 0: { text: '待汇总', color: 'default' }, - 1: { text: '已汇总', color: 'processing' }, - 2: { text: '配送中', color: 'warning' }, - 3: { text: '已完成', color: 'success' }, + 0: { text: '待接单', color: 'default' }, + 1: { text: '已接单', color: 'processing' }, + 2: { text: '采购中', color: 'warning' }, + 3: { text: '配送中', color: 'success' }, + 4: { text: '已完成', color: 'success' }, 9: { text: '已取消', color: 'error' }, }; diff --git a/web/pages/order/store.tsx b/web/pages/order/store.tsx index 940d380..707a534 100644 --- a/web/pages/order/store.tsx +++ b/web/pages/order/store.tsx @@ -9,6 +9,7 @@ import { Table, Tag, Typography, + Image, } from 'antd'; import type { TableProps } from 'antd'; import XinTable from '@/components/XinTable'; @@ -84,16 +85,61 @@ const StoreOrderPage: React.FC = () => { const columns: XinTableColumn[] = [ { title: '订单号', + hideInTable: true, dataIndex: 'order_no', valueType: 'text', + hideInForm: true + }, + { + title: '商品信息', + dataIndex: 'items', hideInForm: true, - render: (_, record) => {record.order_no}, + hideInSearch: true, + width: 300, + render: (_, record) => { + return ( + + { record.items && record.items.length > 0 && record.items.map(item => ( +
+ +
+
{item.product_name}
+
{ item.price } ¥ × { item.quantity }
+
+
+ ))} +
+ ) + } + }, + { + title: '基本信息', + dataIndex: 'order_no', + hideInForm: true, + hideInSearch: true, + width: 300, + render: (_, record) => { + return ( + +
+ 订货门店: + {record.store?.name ?? `门店#${record.store_id}`} +
+
+ 订单号: + {record.order_no} +
+
订货时间:{record.created_at}
+
+ ) + } }, { title: '门店', dataIndex: 'store_id', valueType: 'select', hideInForm: true, + hideInTable: true, fieldProps: { options: stores.map((s) => ({ label: s.name, value: s.id })), showSearch: true, @@ -101,53 +147,103 @@ const StoreOrderPage: React.FC = () => { }, render: (_, record) => record.store?.name ?? '-', }, + { + title: '门店信息', + dataIndex: 'store_id', + hideInForm: true, + hideInSearch: true, + width: 300, + render: (_, record) => ( + +
联系人:{ record.store?.contact ?? '-' }
+
联系电话:{ record.store?.phone ?? '-' }
+
门店地址:{ record.store?.address ?? '-' }
+
+ ), + }, { title: '订货日期', dataIndex: 'order_date', valueType: 'dateRange', hideInForm: true, + hideInTable: true, align: 'center', - render: (_, record) => record.order_date, }, { - title: '订货总量', - dataIndex: 'total_quantity', + title: '订单信息', hideInForm: true, + dataIndex: 'status', hideInSearch: true, - align: 'right', + width: 200, + render: (_, record) => ( + +
+ 订货数量: + {record.total_quantity} +
+
+ 周转框数量: + {record.box_num} +
+
+ 周转托盘数量: + {record.tray_num} +
+
+ ) }, { - title: '订单金额', - dataIndex: 'total_amount', + title: '附加信息', hideInForm: true, + dataIndex: 'box_num', hideInSearch: true, - align: 'right', - render: (_, record) => ¥{record.total_amount}, + width: 200, + render: (_, record) => ( + +
+ 附加总金额: + {record.added_amount} ¥ +
+
+ 商品总金额: + {record.product_amount} ¥ +
+
+ 订单总金额: + {record.total_amount} ¥ +
+
+ ) }, { - title: '状态', + title: '订单状态', dataIndex: 'status', valueType: 'select', hideInForm: true, + align: 'center', fieldProps: { options: Object.entries(STORE_ORDER_STATUS_MAP).map(([value, item]) => ({ value: Number(value), label: item.text, })), }, - render: (_, record) => { - const item = STORE_ORDER_STATUS_MAP[record.status ?? 0]; - return {item?.text}; - }, - align: 'center', + render: (_, record) => ( + + {STORE_ORDER_STATUS_MAP[record.status ?? 0]?.text} + + ) }, { - title: '备注', - dataIndex: 'remark', + title: '采购单ID', + dataIndex: 'purchase_id', + valueType: 'digit', + hideInForm: true, + }, + { + title: '账单ID', + dataIndex: 'statement_id', + valueType: 'digit', hideInForm: true, - hideInSearch: true, - ellipsis: true, - render: (_, record) => record.remark || '-', }, ];