fix(payment): 调整货到付款支付方式及状态逻辑
- 将支付方式默认值修改为8表示货到付款 - 删除前端创建订单时对payStatus和payTime的传递,改为后端自动处理 - 更新订单详情页支付方式映射,新增多种支付方式及货到付款标识 - 修改订单状态展示逻辑,针对货到付款订单调整状态标签和流程判断 - 优化订单列表卡片状态显示,支持货到付款的特殊显示需求 - 更新订单模型注释,统一支付方式编码及对应说明
This commit is contained in:
@@ -97,9 +97,9 @@ export interface ShopOrder {
|
|||||||
formId?: number;
|
formId?: number;
|
||||||
// 支付的用户id
|
// 支付的用户id
|
||||||
payUserId?: number;
|
payUserId?: number;
|
||||||
// 0余额支付, 1微信支付,102微信Native,2会员卡支付,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;
|
payType?: number;
|
||||||
// 代付支付方式,0余额支付, 1微信支付,102微信Native,2会员卡支付,3支付宝,4现金,5POS机,6VIP月卡,7VIP年卡,8VIP次卡,9IC月卡,10IC年卡,11IC次卡,12免费,13VIP充值卡,14IC充值卡,15积分支付,16VIP季卡,17IC季卡,18代付
|
// 代付支付方式
|
||||||
friendPayType?: number;
|
friendPayType?: number;
|
||||||
// 0未付款,1已付款
|
// 0未付款,1已付款
|
||||||
payStatus?: boolean;
|
payStatus?: boolean;
|
||||||
@@ -187,11 +187,11 @@ export interface OrderCreateRequest {
|
|||||||
warehouseId?: number;
|
warehouseId?: number;
|
||||||
// 收货地址ID
|
// 收货地址ID
|
||||||
addressId?: number;
|
addressId?: number;
|
||||||
// 支付方式
|
// 支付方式:0余额支付, 1微信支付, 2支付宝, 3银联, 4现金, 5POS机, 6免费, 7积分支付, 8货到付款
|
||||||
payType: number;
|
payType: number;
|
||||||
// 支付状态(货到付款时传 true 防止定时任务删除)
|
// 支付状态(仅货到付款时前端传 true,其他支付方式由后端处理)
|
||||||
payStatus?: boolean;
|
payStatus?: boolean;
|
||||||
// 支付时间(货到付款时传当前时间)
|
// 支付时间(仅货到付款时前端传当前时间,其他支付方式由后端处理)
|
||||||
payTime?: string;
|
payTime?: string;
|
||||||
// 优惠券ID
|
// 优惠券ID
|
||||||
couponId?: number;
|
couponId?: number;
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ interface OrderCardProps {
|
|||||||
onClick?: () => void
|
onClick?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 综合 payStatus + deliveryStatus + orderStatus 计算列表卡片状态文案 */
|
/** 综合 payStatus + deliveryStatus + orderStatus + payType 计算列表卡片状态文案 */
|
||||||
const getCardStatus = (order: ShopOrder): { text: string; color: string } => {
|
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 === 2) return { text: '已取消', color: '#999' }
|
||||||
if (orderStatus === 3) return { text: '取消中', color: '#ff7d00' }
|
if (orderStatus === 3) return { text: '取消中', color: '#ff7d00' }
|
||||||
@@ -23,7 +24,9 @@ const getCardStatus = (order: ShopOrder): { text: string; color: string } => {
|
|||||||
// 终态:orderStatus=1 必须最先判断,盖过 deliveryStatus/payStatus
|
// 终态:orderStatus=1 必须最先判断,盖过 deliveryStatus/payStatus
|
||||||
if (orderStatus === 1) return { text: '已完成', color: '#0e932e' }
|
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 === 10) return { text: '待发货', color: '#4b9cf5' }
|
||||||
if (deliveryStatus === 20) return { text: '待收货', color: '#4b9cf5' }
|
if (deliveryStatus === 20) return { text: '待收货', color: '#4b9cf5' }
|
||||||
if (deliveryStatus === 30) return { text: '已收货', color: '#0e932e' }
|
if (deliveryStatus === 30) return { text: '已收货', color: '#0e932e' }
|
||||||
|
|||||||
@@ -15,11 +15,15 @@ definePageConfig({
|
|||||||
|
|
||||||
// 支付方式映射
|
// 支付方式映射
|
||||||
const PAY_TYPE_MAP: Record<number, string> = {
|
const PAY_TYPE_MAP: Record<number, string> = {
|
||||||
0: '货到付款',
|
0: '余额支付',
|
||||||
1: '微信支付',
|
1: '微信支付',
|
||||||
2: '会员卡支付',
|
2: '支付宝',
|
||||||
3: '支付宝',
|
3: '银联支付',
|
||||||
15: '积分支付',
|
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 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) {
|
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: '请尽快完成支付' }
|
return { bgColor: '#ff7d00', title: '待付款', subtitle: '请尽快完成支付' }
|
||||||
}
|
}
|
||||||
|
if (isCod && !payStatus) {
|
||||||
|
return { bgColor: '#4b9cf5', title: '货到付款·待发货', subtitle: '送达时支付' }
|
||||||
|
}
|
||||||
if (deliveryStatus === 10) {
|
if (deliveryStatus === 10) {
|
||||||
return { bgColor: '#4b9cf5', title: '待发货', subtitle: '商家正在准备商品' }
|
return { bgColor: '#4b9cf5', title: isCod ? '货到付款·待发货' : '待发货', subtitle: isCod ? '送达时支付' : '商家正在准备商品' }
|
||||||
}
|
}
|
||||||
if (deliveryStatus === 20 || deliveryStatus === 30) {
|
if (deliveryStatus === 20 || deliveryStatus === 30) {
|
||||||
return { bgColor: '#4b9cf5', title: '待收货', subtitle: '商品运输中,请注意查收' }
|
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'
|
type OrderPhase = 'unpaid' | 'unshipped' | 'shipped' | 'completed' | 'cancelled' | 'refund'
|
||||||
|
|
||||||
const getOrderPhase = (order: ShopOrder): OrderPhase => {
|
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)) {
|
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'
|
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 === 10) return 'unshipped'
|
||||||
if (deliveryStatus === 20 || deliveryStatus === 30) return 'shipped'
|
if (deliveryStatus === 20 || deliveryStatus === 30) return 'shipped'
|
||||||
if (orderStatus === OrderStatus.Completed) return 'completed'
|
if (orderStatus === OrderStatus.Completed) return 'completed'
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ const CheckoutPage: React.FC = () => {
|
|||||||
const [rushBuyProducts, setRushBuyProducts] = useState<ShopGoods[]>([])
|
const [rushBuyProducts, setRushBuyProducts] = useState<ShopGoods[]>([])
|
||||||
|
|
||||||
// 支付方式相关状态
|
// 支付方式相关状态
|
||||||
const [payType, setPayType] = useState<number>(0) // 0: 货到付款
|
const [payType, setPayType] = useState<number>(8) // 8: 货到付款
|
||||||
|
|
||||||
// 从本地存储获取立即购买的数据
|
// 从本地存储获取立即购买的数据
|
||||||
const buyNowItems = useMemo(() => {
|
const buyNowItems = useMemo(() => {
|
||||||
@@ -263,19 +263,11 @@ const CheckoutPage: React.FC = () => {
|
|||||||
specInfo: item.skuSpec || item.sku?.sku || item.product?.specName,
|
specInfo: item.skuSpec || item.sku?.sku || item.product?.specName,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// 格式化当前时间:yyyy-MM-dd HH:mm:ss(与后端 LocalDateTime 兼容)
|
// 货到付款:后端会自动设置 payStatus=true,无需前端传递 payStatus/payTime
|
||||||
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,防止后端定时任务自动删除未付款订单
|
|
||||||
const orderParams: OrderCreateRequest = {
|
const orderParams: OrderCreateRequest = {
|
||||||
goodsItems,
|
goodsItems,
|
||||||
addressId: defaultAddress.id,
|
addressId: defaultAddress.id,
|
||||||
payType,
|
payType,
|
||||||
payStatus: true,
|
|
||||||
payTime,
|
|
||||||
couponId: selectedCoupon?.id ? Number(selectedCoupon.id) : undefined,
|
couponId: selectedCoupon?.id ? Number(selectedCoupon.id) : undefined,
|
||||||
comments: remarks,
|
comments: remarks,
|
||||||
deliveryType: 0, // 快递配送
|
deliveryType: 0, // 快递配送
|
||||||
|
|||||||
Reference in New Issue
Block a user