mall:订单详情:调整售后字段

This commit is contained in:
YunaiV 2023-05-21 12:18:52 +08:00
parent e745bb6675
commit e942b52a67
11 changed files with 67 additions and 67 deletions

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.enums.delivery;
package cn.iocoder.yudao.module.trade.enums.delivery;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
@ -15,9 +15,8 @@ import java.util.Arrays;
@AllArgsConstructor
public enum DeliveryTypeEnum implements IntArrayValuable {
// TODO 芋艿英文单词需要再想下
EXPRESS(1, "快递发货"),
USER(2, "用户自提"),;
PICK_UP(2, "用户自提"),;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getMode).toArray();

View File

@ -17,8 +17,8 @@ import java.util.Arrays;
public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable {
NONE(0, "未售后"),
APPLY(1, "售后中"),
SUCCESS(2, "已退款");
APPLY(10, "售后中"),
SUCCESS(20, "售后成功");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray();
@ -31,9 +31,6 @@ public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable {
*/
private final String name;
// TODO 芋艿EXPIRED 已失效不允许申请售后
// TODO 芋艿PART_AFTER_SALE 部分售后
@Override
public int[] array() {
return ARRAYS;

View File

@ -7,19 +7,19 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* 交易订单 - 售后状态
* 交易订单 - 退款状态
*
* @author Sin
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderAfterSaleStatusEnum implements IntArrayValuable {
public enum TradeOrderRefundStatusEnum implements IntArrayValuable {
NONE(0, "未退款"),
PART(1, "部分退款"),
ALL(2, "全部退款");
PART(10, "部分退款"),
ALL(20, "全部退款");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderAfterSaleStatusEnum::getStatus).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderRefundStatusEnum::getStatus).toArray();
/**
* 状态值

View File

@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -46,6 +47,9 @@ public class AppTradeOrderController {
@Resource
private ProductPropertyValueApi productPropertyValueApi;
@Resource
private TradeOrderProperties tradeOrderProperties;
@GetMapping("/settlement")
@Operation(summary = "获得订单结算信息")
@PreAuthenticated
@ -154,7 +158,8 @@ public class AppTradeOrderController {
List<ProductPropertyValueDetailRespDTO> propertyValueDetails = productPropertyValueApi
.getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems));
// 最终组合
return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, propertyValueDetails));
return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems,
propertyValueDetails, tradeOrderProperties));
}
@GetMapping("/page")

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -38,6 +38,9 @@ public class AppTradeOrderDetailRespVO {
@Schema(description = "订单取消时间")
private LocalDateTime cancelTime;
@Schema(description = "是否评价", required = true, example = "true")
private Boolean commentStatus;
// ========== 价格 + 支付基本信息 ==========
@Schema(description = "是否已支付", required = true, example = "true")
@ -49,6 +52,9 @@ public class AppTradeOrderDetailRespVO {
@Schema(description = "付款时间")
private LocalDateTime payTime;
@Schema(description = "付款超时时间", required = true)
private LocalDateTime payExpireTime;
@Schema(description = "支付渠道", required = true, example = "wx_lite_pay")
private String payChannelCode;
@ -72,6 +78,9 @@ public class AppTradeOrderDetailRespVO {
// ========== 收件 + 物流基本信息 ==========
@Schema(description = "配送方式", required = true, example = "1")
private Integer deliveryType;
@Schema(description = "发货物流单号", example = "1024")
private String logisticsNo;
@ -112,42 +121,6 @@ public class AppTradeOrderDetailRespVO {
/**
* 订单项数组
*/
private List<Item> items;
@Schema(description = "用户 App - 交易订单的分页项的订单项目")
@Data
public static class Item {
@Schema(description = "编号", required = true, example = "1")
private Long id;
@Schema(description = "商品 SPU 编号", required = true, example = "1")
private Long spuId;
@Schema(description = "商品 SPU 名称", required = true, example = "芋道源码")
private String spuName;
@Schema(description = "商品 SKU 编号", required = true, example = "1")
private Long skuId;
/**
* 属性数组
*/
private List<AppProductPropertyValueDetailRespVO> properties;
@Schema(description = "商品图片", required = true, example = "https://www.iocoder.cn/1.png")
private String picUrl;
@Schema(description = "购买数量", required = true, example = "1")
private Integer count;
@Schema(description = "是否评价", required = true, example = "true")
private Boolean commentStatus;
// ========== 价格 + 支付基本信息 ==========
@Schema(description = "商品原价(单)", required = true, example = "100")
private Integer price;
}
private List<AppTradeOrderItemRespVO> items;
}

View File

@ -37,6 +37,11 @@ public class AppTradeOrderPageItemRespVO {
@Schema(description = "应付金额,单位:分", required = true, example = "1000")
private Integer payPrice;
// ========== 收件 + 物流基本信息 ==========
@Schema(description = "配送方式", required = true, example = "1")
private Integer deliveryType;
/**
* 订单项数组
*/

View File

@ -15,25 +15,38 @@ public class AppTradeOrderItemRespVO {
@Schema(description = "商品 SPU 编号", required = true, example = "1")
private Long spuId;
@Schema(description = "商品 SPU 名称", required = true, example = "芋道源码")
private String spuName;
@Schema(description = "商品 SKU 编号", required = true, example = "1")
private Long skuId;
/**
* 属性数组
*/
private List<AppProductPropertyValueDetailRespVO> properties;
@Schema(description = "商品图片", required = true, example = "https://www.iocoder.cn/1.png")
private String picUrl;
@Schema(description = "购买数量", required = true, example = "1")
private Integer count;
@Schema(description = "是否评价", required = true, example = "true")
private Boolean commentStatus;
// ========== 价格 + 支付基本信息 ==========
@Schema(description = "商品原价(单)", required = true, example = "100")
private Integer price;
/**
* 属性数组
*/
private List<AppProductPropertyValueDetailRespVO> properties;
// ========== 营销基本信息 ==========
// TODO 芋艿在捉摸一下
// ========== 售后基本信息 ==========
@Schema(description = "售后状态", required = true, example = "1")
private Integer afterSaleStatus;
}

View File

@ -212,8 +212,9 @@ public interface TradeOrderConvert {
AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean);
default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List<TradeOrderItemDO> orderItems,
List<ProductPropertyValueDetailRespDTO> propertyValueDetails) {
List<ProductPropertyValueDetailRespDTO> propertyValueDetails, TradeOrderProperties tradeOrderProperties) {
AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems);
orderVO.setPayExpireTime(addTime(tradeOrderProperties.getExpireTime()));
// 处理商品属性
Map<Long, ProductPropertyValueDetailRespDTO> propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId);
for (int i = 0; i < orderItems.size(); i++) {
@ -221,7 +222,7 @@ public interface TradeOrderConvert {
if (CollUtil.isEmpty(properties)) {
continue;
}
AppTradeOrderDetailRespVO.Item item = orderVO.getItems().get(i);
AppTradeOrderItemRespVO item = orderVO.getItems().get(i);
item.setProperties(new ArrayList<>(properties.size()));
// 遍历每个 properties设置到 TradeOrderPageItemRespVO.Item
properties.forEach(property -> {

View File

@ -3,8 +3,9 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO.OrderItem;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderAfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderDeliveryStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
@ -179,6 +180,12 @@ public class TradeOrderDO extends BaseDO {
private Integer payPrice;
// ========== 收件 + 物流基本信息 ==========
/**
* 配送方式
*
* 枚举 {@link DeliveryTypeEnum}
*/
private Integer deliveryType;
/**
* 配置模板的编号
*
@ -229,9 +236,9 @@ public class TradeOrderDO extends BaseDO {
/**
* 售后状态
*
* 枚举 {@link TradeOrderAfterSaleStatusEnum}
* 枚举 {@link TradeOrderRefundStatusEnum}
*/
private Integer afterSaleStatus;
private Integer refundStatus;
/**
* 退款金额单位
*

View File

@ -178,12 +178,12 @@ public class TradeOrderServiceImpl implements TradeOrderService {
tradeOrderDO.setNo(IdUtil.getSnowflakeNextId() + ""); // TODO @LeeYan9: 思考下, 怎么生成好点哈; 这个是会展示给用户的;
tradeOrderDO.setStatus(TradeOrderStatusEnum.UNPAID.getStatus());
tradeOrderDO.setType(TradeOrderTypeEnum.NORMAL.getType());
tradeOrderDO.setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.NONE.getStatus());
tradeOrderDO.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());
tradeOrderDO.setProductCount(getSumValue(order.getItems(), PriceCalculateRespDTO.OrderItem::getCount, Integer::sum));
tradeOrderDO.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源?
tradeOrderDO.setAdjustPrice(0).setPayed(false); // 支付信息
tradeOrderDO.setDeliveryStatus(TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus()); // 物流信息
tradeOrderDO.setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.NONE.getStatus()).setRefundPrice(0); // 退款信息
tradeOrderDO.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); // 退款信息
tradeOrderMapper.insert(tradeOrderDO);
return tradeOrderDO;
}
@ -491,7 +491,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
Integer orderRefundPrice = order.getRefundPrice() + refundPrice;
if (isAllOrderItemAfterSaleSuccess(order.getId())) { // 如果都售后成功则需要取消订单
tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
.setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.ALL.getStatus()).setRefundPrice(orderRefundPrice)
.setRefundStatus(TradeOrderRefundStatusEnum.ALL.getStatus()).setRefundPrice(orderRefundPrice)
.setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now()));
// TODO 芋艿记录订单日志
@ -499,7 +499,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
// TODO 芋艿站内信
} else { // 如果部分售后则更新退款金额
tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
.setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.PART.getStatus()).setRefundPrice(orderRefundPrice));
.setRefundStatus(TradeOrderRefundStatusEnum.PART.getStatus()).setRefundPrice(orderRefundPrice));
}
// TODO 芋艿未来如果有分佣需要更新相关分佣订单为已失效

View File

@ -185,7 +185,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
assertEquals(tradeOrderDO.getReceiverMobile(), "15601691300");
assertEquals(tradeOrderDO.getReceiverAreaId(), 3306);
assertEquals(tradeOrderDO.getReceiverDetailAddress(), "土豆村");
assertEquals(tradeOrderDO.getAfterSaleStatus(), TradeOrderAfterSaleStatusEnum.NONE.getStatus());
assertEquals(tradeOrderDO.getRefundStatus(), TradeOrderRefundStatusEnum.NONE.getStatus());
assertEquals(tradeOrderDO.getRefundPrice(), 0);
assertEquals(tradeOrderDO.getCouponPrice(), 30);
assertEquals(tradeOrderDO.getPointPrice(), 10);