fix(payment): 调整货到付款支付方式及状态逻辑

- 将支付方式默认值修改为8表示货到付款
- 删除前端创建订单时对payStatus和payTime的传递,改为后端自动处理
- 更新订单详情页支付方式映射,新增多种支付方式及货到付款标识
- 修改订单状态展示逻辑,针对货到付款订单调整状态标签和流程判断
- 优化订单列表卡片状态显示,支持货到付款的特殊显示需求
- 更新订单模型注释,统一支付方式编码及对应说明
This commit is contained in:
2026-07-14 19:26:43 +08:00
parent b60e5c976a
commit a6a34da3cb
4 changed files with 32 additions and 27 deletions

View File

@@ -97,9 +97,9 @@ export interface ShopOrder {
formId?: number;
// 支付的用户id
payUserId?: number;
// 0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡18代付
// 支付方式:0余额支付, 1微信支付, 2支付宝, 3银联, 4现金, 5POS机, 6免费, 7积分支付, 8货到付款
payType?: number;
// 代付支付方式,0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡18代付
// 代付支付方式
friendPayType?: number;
// 0未付款1已付款
payStatus?: boolean;
@@ -187,11 +187,11 @@ export interface OrderCreateRequest {
warehouseId?: number;
// 收货地址ID
addressId?: number;
// 支付方式
// 支付方式0余额支付, 1微信支付, 2支付宝, 3银联, 4现金, 5POS机, 6免费, 7积分支付, 8货到付款
payType: number;
// 支付状态(货到付款时传 true 防止定时任务删除
// 支付状态(货到付款时前端传 true,其他支付方式由后端处理
payStatus?: boolean;
// 支付时间(货到付款时传当前时间)
// 支付时间(货到付款时前端传当前时间,其他支付方式由后端处理
payTime?: string;
// 优惠券ID
couponId?: number;

View File

@@ -10,9 +10,10 @@ interface OrderCardProps {
onClick?: () => void
}
/** 综合 payStatus + deliveryStatus + orderStatus 计算列表卡片状态文案 */
/** 综合 payStatus + deliveryStatus + orderStatus + payType 计算列表卡片状态文案 */
const getCardStatus = (order: ShopOrder): { text: string; color: string } => {
const { payStatus, deliveryStatus, orderStatus } = order
const { payStatus, deliveryStatus, orderStatus, payType } = order
const isCod = payType === 8 // 货到付款
if (orderStatus === 2) return { text: '已取消', color: '#999' }
if (orderStatus === 3) return { text: '取消中', color: '#ff7d00' }
@@ -23,7 +24,9 @@ const getCardStatus = (order: ShopOrder): { text: string; color: string } => {
// 终态orderStatus=1 必须最先判断,盖过 deliveryStatus/payStatus
if (orderStatus === 1) return { text: '已完成', color: '#0e932e' }
if (!payStatus) return { text: '待付款', color: '#ee0a24' }
// 货到付款payStatus=true 直接进入待发货
if (!payStatus && !isCod) return { text: '待付款', color: '#ee0a24' }
if (isCod && deliveryStatus === 10) return { text: '货到付款·待发货', color: '#4b9cf5' }
if (deliveryStatus === 10) return { text: '待发货', color: '#4b9cf5' }
if (deliveryStatus === 20) return { text: '待收货', color: '#4b9cf5' }
if (deliveryStatus === 30) return { text: '已收货', color: '#0e932e' }

View File

@@ -15,11 +15,15 @@ definePageConfig({
// 支付方式映射
const PAY_TYPE_MAP: Record<number, string> = {
0: '货到付款',
0: '余额支付',
1: '微信支付',
2: '会员卡支付',
3: '支付',
15: '积分支付',
2: '支付',
3: '银联支付',
4: '现金支付',
5: 'POS机',
6: '免费',
7: '积分支付',
8: '货到付款',
}
// 发票状态映射
@@ -38,7 +42,8 @@ const DELIVERY_STATUS_MAP: Record<number, string> = {
/** 根据订单状态计算展示用的状态标签 */
const getOrderDisplayStatus = (order: ShopOrder): { title: string; bgColor: string; subtitle: string } => {
const { payStatus, deliveryStatus, orderStatus } = order
const { payStatus, deliveryStatus, orderStatus, payType } = order
const isCod = payType === 8 // 货到付款
// 退款/取消相关状态
if (orderStatus === OrderStatus.Cancelled) {
@@ -58,11 +63,14 @@ const getOrderDisplayStatus = (order: ShopOrder): { title: string; bgColor: stri
}
// 正常订单流程
if (!payStatus) {
if (!payStatus && !isCod) {
return { bgColor: '#ff7d00', title: '待付款', subtitle: '请尽快完成支付' }
}
if (isCod && !payStatus) {
return { bgColor: '#4b9cf5', title: '货到付款·待发货', subtitle: '送达时支付' }
}
if (deliveryStatus === 10) {
return { bgColor: '#4b9cf5', title: '待发货', subtitle: '商家正在准备商品' }
return { bgColor: '#4b9cf5', title: isCod ? '货到付款·待发货' : '待发货', subtitle: isCod ? '送达时支付' : '商家正在准备商品' }
}
if (deliveryStatus === 20 || deliveryStatus === 30) {
return { bgColor: '#4b9cf5', title: '待收货', subtitle: '商品运输中,请注意查收' }
@@ -82,14 +90,16 @@ const getOrderDisplayStatus = (order: ShopOrder): { title: string; bgColor: stri
type OrderPhase = 'unpaid' | 'unshipped' | 'shipped' | 'completed' | 'cancelled' | 'refund'
const getOrderPhase = (order: ShopOrder): OrderPhase => {
const { payStatus, deliveryStatus, orderStatus } = order
const { payStatus, deliveryStatus, orderStatus, payType } = order
const isCod = payType === 8 // 货到付款
// 退款/取消
if ([OrderStatus.Cancelled, OrderStatus.Cancelling, OrderStatus.RefundSuccess, OrderStatus.RefundApply, OrderStatus.ClientRefundApply, OrderStatus.RefundRejected].includes(orderStatus as OrderStatus)) {
return orderStatus === OrderStatus.Cancelled || orderStatus === OrderStatus.RefundSuccess ? 'cancelled' : 'refund'
}
if (!payStatus) return 'unpaid'
// 货到付款订单payStatus=true 但还未实际付款,直接进入 unshipped 阶段(不需要"立即支付"按钮)
if (!payStatus && !isCod) return 'unpaid'
if (deliveryStatus === 10) return 'unshipped'
if (deliveryStatus === 20 || deliveryStatus === 30) return 'shipped'
if (orderStatus === OrderStatus.Completed) return 'completed'

View File

@@ -125,7 +125,7 @@ const CheckoutPage: React.FC = () => {
const [rushBuyProducts, setRushBuyProducts] = useState<ShopGoods[]>([])
// 支付方式相关状态
const [payType, setPayType] = useState<number>(0) // 0: 货到付款
const [payType, setPayType] = useState<number>(8) // 8: 货到付款
// 从本地存储获取立即购买的数据
const buyNowItems = useMemo(() => {
@@ -263,19 +263,11 @@ const CheckoutPage: React.FC = () => {
specInfo: item.skuSpec || item.sku?.sku || item.product?.specName,
}))
// 格式化当前时间yyyy-MM-dd HH:mm:ss与后端 LocalDateTime 兼容)
const now = new Date()
const pad = (n: number) => n.toString().padStart(2, '0')
const payTime = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
// 创建订单
// 货到付款:直接设置 payStatus=true + payTime防止后端定时任务自动删除未付款订单
// 货到付款:后端会自动设置 payStatus=true无需前端传递 payStatus/payTime
const orderParams: OrderCreateRequest = {
goodsItems,
addressId: defaultAddress.id,
payType,
payStatus: true,
payTime,
couponId: selectedCoupon?.id ? Number(selectedCoupon.id) : undefined,
comments: remarks,
deliveryType: 0, // 快递配送