diff --git a/.workbuddy/memory/2026-07-17.md b/.workbuddy/memory/2026-07-17.md index 4636bdf..c5f0cd4 100644 --- a/.workbuddy/memory/2026-07-17.md +++ b/.workbuddy/memory/2026-07-17.md @@ -138,7 +138,14 @@ - **deliveryStatus 含义**:10=待发货, 20=已发货, 30=部分发货(未使用) - **状态文案**:deliveryStatus=20+未付款+线下付款 → "已发货待收款"(红),deliveryStatus=20+已付款 → "待收货"(蓝) -### 门店端:改价功能合并到确认收款弹窗 -- 去掉独立的"改价"按钮和修改金额弹窗(`editPrice` OpType、`showEditPriceModal`、`editReason` 等) -- 在确认收款弹窗中增加"实付金额"输入框(预填当前值,可修改),改价不再需要单独输入原因(收款备注即可说明) -- 提交时:如果金额有变化,先调 `updateShopOrder` 更新 `payPrice`+`merchantRemarks`,再调 `confirmOfflinePayment` 确认收款 +### 门店端:改价功能合并到确认收款弹窗 → 又改回来了 +- 先去掉了独立的"改价"按钮和修改金额弹窗(`editPrice` OpType、`showEditPriceModal`、`editReason` 等) +- 在确认收款弹窗中增加了"实付金额"输入框 +- **2026-07-17 下午**:用户要求改回来,恢复独立的改价按钮和弹窗 + - OpType 加回 `editPrice` + - `getOrderActions` 中线下付款未付款时显示「改价」+「确认收款」两个按钮 + - 恢复 `showEditPriceModal`/`editPriceOrder`/`editPriceValue`/`editPriceRemarks`/`editingPrice` 状态 + - 恢复 `openEditPriceModal`/`closeEditPriceModal`/`submitEditPrice` 函数 + - 恢复独立改价弹窗(订单信息 + 新金额输入 + 改价原因备注) + - 确认收款弹窗去掉「实付金额」输入框,`submitOperation` 中 confirmPay 分支去掉改价逻辑 + - 改价按钮样式:橙色背景白字 `bg-orange-500` diff --git a/src/pages/store/orders/index.tsx b/src/pages/store/orders/index.tsx index 8b24b60..c398ed9 100644 --- a/src/pages/store/orders/index.tsx +++ b/src/pages/store/orders/index.tsx @@ -28,13 +28,14 @@ const TABS: { key: TabKey; label: string; params: Partial[] }[] ] // ─── 操作类型 ───────────────────────────────────────────────────── -type OpType = 'confirmPay' | 'deliver' | 'complete' | 'ship' +type OpType = 'confirmPay' | 'deliver' | 'complete' | 'ship' | 'editPrice' const OP_LABEL: Record = { confirmPay: '收款', deliver: '送达', complete: '已完成', ship: '发货', + editPrice: '改价', } const OP_DESC: Record = { @@ -42,6 +43,7 @@ const OP_DESC: Record = { deliver: '上传送达凭证照片,标记为已收货(不改变付款和订单完成状态)', complete: '确认订单已完成,收款后点击此按钮标记订单完成', ship: '选择发货人员并生成发货单,订单将进入已发货状态', + editPrice: '修改订单实付金额', } // ─── 图片上传 ───────────────────────────────────────────────────── @@ -132,8 +134,9 @@ function isOrderActionable(order: ShopOrder): boolean { function getOrderActions(order: ShopOrder): { label: string; type: OpType }[] { if (!isOrderActionable(order)) return [] const actions: { label: string; type: OpType }[] = [] - // 线下付款·待确认收款:显示"确认收款"按钮 + // 线下付款·待确认收款:显示"确认收款"和"改价"按钮 if (!order.payStatus && order.payType === 9 && order.orderStatus === 0) { + actions.push({label: '改价', type: 'editPrice'}) actions.push({label: '确认收款', type: 'confirmPay'}) } // 发货: @@ -176,8 +179,12 @@ export default function StoreOrdersPage() { const [payRemarks, setPayRemarks] = useState('') const [submitting, setSubmitting] = useState(false) - // 确认收款弹窗:修改金额(选填) - const [editPayPrice, setEditPayPrice] = useState('') + // 改价弹窗状态 + const [showEditPriceModal, setShowEditPriceModal] = useState(false) + const [editPriceOrder, setEditPriceOrder] = useState(null) + const [editPriceValue, setEditPriceValue] = useState('') + const [editPriceRemarks, setEditPriceRemarks] = useState('') + const [editingPrice, setEditingPrice] = useState(false) // 发货弹窗状态 const [showShipModal, setShowShipModal] = useState(false) @@ -309,11 +316,15 @@ export default function StoreOrdersPage() { /** 打开操作弹窗 */ const openModal = (order: ShopOrder, type: OpType) => { + // 改价走独立弹窗 + if (type === 'editPrice') { + openEditPriceModal(order) + return + } setCurrentOrder(order) setOpType(type) setProofImages([]) setPayRemarks('') - setEditPayPrice(String(order.payPrice || order.totalPrice || '')) setShowModal(true) } @@ -323,7 +334,6 @@ export default function StoreOrdersPage() { setCurrentOrder(null) setProofImages([]) setPayRemarks('') - setEditPayPrice('') } /** 选择并上传凭证图片 */ @@ -383,23 +393,7 @@ export default function StoreOrdersPage() { setSubmitting(true) try { if (opType === 'confirmPay') { - // 确认线下收款:检查是否需要改价,合并改价+确认收款 - const newPrice = parseFloat(editPayPrice) - const oldPriceStr = String(currentOrder.payPrice || currentOrder.totalPrice || '') - const oldPrice = parseFloat(oldPriceStr) - const priceChanged = !isNaN(newPrice) && newPrice >= 0 && Math.abs(newPrice - oldPrice) > 0.01 - - if (priceChanged) { - // 先更新金额 - const changeRecord = `【门店修改金额】原实付¥${oldPriceStr} → 新实付¥${newPrice.toFixed(2)}` - await updateShopOrder({ - orderId: currentOrder.orderId, - payPrice: newPrice.toFixed(2), - merchantRemarks: (currentOrder.merchantRemarks || '') + `\n${changeRecord}`, - } as ShopOrder) - } - - // 确认收款 + // 确认线下收款 await confirmOfflinePayment( currentOrder.orderId!, payRemarks.trim() || undefined, @@ -430,6 +424,54 @@ export default function StoreOrdersPage() { } } + /** 打开改价弹窗 */ + const openEditPriceModal = (order: ShopOrder) => { + setEditPriceOrder(order) + setEditPriceValue(String(order.payPrice || order.totalPrice || '')) + setEditPriceRemarks('') + setShowEditPriceModal(true) + } + + /** 关闭改价弹窗 */ + const closeEditPriceModal = () => { + setShowEditPriceModal(false) + setEditPriceOrder(null) + setEditPriceValue('') + setEditPriceRemarks('') + } + + /** 提交改价 */ + const submitEditPrice = async () => { + if (!editPriceOrder) return + const newPrice = parseFloat(editPriceValue) + if (isNaN(newPrice) || newPrice < 0) { + Taro.showToast({title: '请输入有效金额', icon: 'none'}) + return + } + const oldPriceStr = String(editPriceOrder.payPrice || editPriceOrder.totalPrice || '0') + const oldPrice = parseFloat(oldPriceStr) + if (!isNaN(oldPrice) && Math.abs(newPrice - oldPrice) < 0.01) { + Taro.showToast({title: '金额未变化', icon: 'none'}) + return + } + setEditingPrice(true) + try { + const changeRecord = `【门店修改金额】原实付¥${oldPriceStr} → 新实付¥${newPrice.toFixed(2)}` + await updateShopOrder({ + orderId: editPriceOrder.orderId, + payPrice: newPrice.toFixed(2), + merchantRemarks: (editPriceOrder.merchantRemarks || '') + `\n${changeRecord}`, + } as ShopOrder) + Taro.showToast({title: '改价成功', icon: 'success'}) + closeEditPriceModal() + loadOrders(activeTab, 1) + } catch (e: any) { + Taro.showToast({title: e.message || '改价失败', icon: 'none'}) + } finally { + setEditingPrice(false) + } + } + /** 打开发货弹窗:拉取门店店员列表供选择发货人员 */ const openShipModal = async (order: ShopOrder) => { setCurrentOrder(order) @@ -656,6 +698,8 @@ export default function StoreOrdersPage() { ? 'bg-blue-500' : act.type === 'ship' ? 'bg-purple-500' + : act.type === 'editPrice' + ? 'bg-orange-500' : 'border border-blue-500' }`} onClick={() => act.type === 'ship' @@ -663,7 +707,7 @@ export default function StoreOrdersPage() { : openModal(order, act.type)} > {act.label} ))} @@ -828,31 +872,17 @@ export default function StoreOrdersPage() { {/* 备注(仅确认收款时显示) */} {opType === 'confirmPay' && ( - <> - - 备注(选填) -