feat(order): 优化订单备注结构及线下付款状态显示
- 门店订单修改金额时,修改原因从追加 comments 改为保存 merchantRemarks 字段 - ShopOrder 和 OrderCreateRequest 接口新增 buyerRemarks 和 merchantRemarks 字段,实现订单备注字段分离 - 结算页由 comments 注入变更为 buyerRemarks,门店订单列表新增买家备注展示块 - 修复线下付款订单状态显示:统一线下付款(payType=9)与货到付款(payType=8)的待发货状态显示 - 取消按钮逻辑优化,已付款订单不显示取消按钮,文案由"关闭订单"改为"取消订单" - 订单列表和详情页弹窗标题及提示文案更新,确保状态描述准确,提升用户体验
This commit is contained in:
@@ -143,6 +143,10 @@ export interface ShopOrder {
|
||||
userId?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 买家备注(下单时用户填写的订单备注)
|
||||
buyerRemarks?: string;
|
||||
// 商户备注(门店修改金额原因等)
|
||||
merchantRemarks?: string;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 是否删除, 0否, 1是
|
||||
@@ -199,6 +203,8 @@ export interface OrderCreateRequest {
|
||||
couponId?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 买家备注(下单时用户填写的订单备注)
|
||||
buyerRemarks?: string;
|
||||
// 配送开始时间(用于预约/配送时间)
|
||||
sendStartTime?: string;
|
||||
// 配送方式 0快递 1自提
|
||||
|
||||
@@ -26,11 +26,8 @@ const getCardStatus = (order: ShopOrder): { text: string; color: string } => {
|
||||
// 终态:orderStatus=1 必须最先判断,盖过 deliveryStatus/payStatus
|
||||
if (orderStatus === 1) return { text: '已完成', color: '#0e932e' }
|
||||
|
||||
// 线下付款·待确认:下单后等待商家确认收款
|
||||
if (isOffline && !payStatus) return { text: '线下付款·待确认', color: '#ff7d00' }
|
||||
// 货到付款:payStatus=true 直接进入待发货
|
||||
if (!payStatus && !isCod) return { text: '待付款', color: '#ee0a24' }
|
||||
if (isCod && deliveryStatus === 10) return { text: '货到付款·待发货', color: '#4b9cf5' }
|
||||
// 货到付款(8)/线下付款(9):无需在线支付,下单即进入发货流程
|
||||
if (!payStatus && !isCod && !isOffline) return { text: '待付款', color: '#ee0a24' }
|
||||
if (deliveryStatus === 10) return { text: '待发货', color: '#4b9cf5' }
|
||||
if (deliveryStatus === 20) return { text: '待收货', color: '#4b9cf5' }
|
||||
if (deliveryStatus === 30) return { text: '已收货', color: '#0e932e' }
|
||||
@@ -54,8 +51,9 @@ const OrderCard: React.FC<OrderCardProps> = ({ order, onClick, onCloseOrder }) =
|
||||
|
||||
const { text: statusText, color: statusColor } = getCardStatus(order)
|
||||
|
||||
// 待发货状态(deliveryStatus=10 未发货)才显示关闭订单按钮
|
||||
const showCloseButton = order.deliveryStatus === 10 && order.orderStatus !== 2 && order.orderStatus !== 3
|
||||
// 仅未付款/待确认收款的订单(payStatus=false)才显示取消按钮
|
||||
// 已付款的待发货订单需到详情页申请退款
|
||||
const showCloseButton = order.deliveryStatus === 10 && !order.payStatus && order.orderStatus !== 2 && order.orderStatus !== 3
|
||||
|
||||
// 获取首个商品图片作为封面,或显示默认占位
|
||||
const coverImage = order.orderGoods?.[0]?.image || ''
|
||||
@@ -157,7 +155,7 @@ const OrderCard: React.FC<OrderCardProps> = ({ order, onClick, onCloseOrder }) =
|
||||
className='px-3 py-1 rounded-full border border-gray-300'
|
||||
onClick={handleClose}
|
||||
>
|
||||
<Text className='text-xs text-gray-600'>关闭订单</Text>
|
||||
<Text className='text-xs text-gray-600'>取消订单</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -69,13 +69,13 @@ const getOrderDisplayStatus = (order: ShopOrder): { title: string; bgColor: stri
|
||||
return { bgColor: '#ff7d00', title: '待付款', subtitle: '请尽快完成支付' }
|
||||
}
|
||||
if (isOffline && !payStatus) {
|
||||
return { bgColor: '#ff7d00', title: '线下付款·待确认', subtitle: '请通过微信转账完成付款,商家确认后发货' }
|
||||
return { bgColor: '#4b9cf5', title: '待发货', subtitle: '请通过微信转账完成付款,商家确认后发货' }
|
||||
}
|
||||
if (isCod && !payStatus) {
|
||||
return { bgColor: '#4b9cf5', title: '货到付款·待发货', subtitle: '送达时支付' }
|
||||
return { bgColor: '#4b9cf5', title: '待发货', subtitle: '送达时支付' }
|
||||
}
|
||||
if (deliveryStatus === 10) {
|
||||
return { bgColor: '#4b9cf5', title: isCod ? '货到付款·待发货' : '待发货', subtitle: isCod ? '送达时支付' : '商家正在准备商品' }
|
||||
return { bgColor: '#4b9cf5', title: '待发货', subtitle: '商家正在准备商品' }
|
||||
}
|
||||
if (deliveryStatus === 20 || deliveryStatus === 30) {
|
||||
return { bgColor: '#4b9cf5', title: '待收货', subtitle: '商品运输中,请注意查收' }
|
||||
|
||||
@@ -147,23 +147,23 @@ const OrderListPage: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 关闭订单(待发货状态下允许客户取消) */
|
||||
/** 取消订单(未付款/待确认收款状态下允许客户取消) */
|
||||
const handleCloseOrder = (order: ShopOrder) => {
|
||||
Taro.showModal({
|
||||
title: '确认关闭订单',
|
||||
content: '关闭后订单将取消,是否确认?',
|
||||
title: '确认取消订单',
|
||||
content: '取消后订单将关闭,是否确认?',
|
||||
confirmColor: '#ee0a24',
|
||||
success: async (res) => {
|
||||
if (res.confirm && order?.orderId) {
|
||||
try {
|
||||
await updateShopOrder({ ...order, orderStatus: OrderStatus.Cancelled })
|
||||
Taro.showToast({ title: '订单已关闭', icon: 'success' })
|
||||
Taro.showToast({ title: '订单已取消', icon: 'success' })
|
||||
// 标记所有 tab 为未初始化,切换时会重新加载(确保「全部」等 tab 能看到最新状态)
|
||||
setTabStates(prev => prev.map(s => ({ ...s, initialized: false })))
|
||||
// 立即刷新当前 tab
|
||||
loadOrders(tabIndex, 1)
|
||||
} catch (err: any) {
|
||||
Taro.showToast({ title: err?.message || '关闭失败', icon: 'none' })
|
||||
Taro.showToast({ title: err?.message || '取消失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ const CheckoutPage: React.FC = () => {
|
||||
addressId: defaultAddress.id,
|
||||
payType,
|
||||
couponId: selectedCoupon?.id ? Number(selectedCoupon.id) : undefined,
|
||||
comments: remarks,
|
||||
buyerRemarks: remarks,
|
||||
deliveryType: 0, // 快递配送
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ export default function StoreOrdersPage() {
|
||||
await updateShopOrder({
|
||||
orderId: currentOrder.orderId,
|
||||
payPrice: newPrice.toFixed(2),
|
||||
comments: (currentOrder.comments || '') + `\n${changeRecord}`,
|
||||
merchantRemarks: (currentOrder.merchantRemarks || '') + `\n${changeRecord}`,
|
||||
} as ShopOrder)
|
||||
|
||||
Taro.showToast({title: '修改成功', icon: 'success'})
|
||||
@@ -450,6 +450,14 @@ export default function StoreOrdersPage() {
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 买家备注 */}
|
||||
{order.buyerRemarks && (
|
||||
<View className='bg-orange-50 rounded-lg p-3 mb-3'>
|
||||
<Text className='text-xs text-orange-500 mb-1 block'>买家备注</Text>
|
||||
<Text className='text-sm text-gray-600 block'>{order.buyerRemarks}</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 送达凭证(已完成订单) */}
|
||||
{order.sendEndImg && (() => {
|
||||
const imgs = parseSendEndImg(order.sendEndImg)
|
||||
|
||||
Reference in New Issue
Block a user