1. 迁移交易订单的查询接口
2. 支付服务,重新初始化结构
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package cn.iocoder.mall.order.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.OrderBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单 convert
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-17 10:14
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderConvert {
|
||||
|
||||
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
List<OrderBO> convertPageBO(List<OrderDO> orderDOList);
|
||||
|
||||
@Mappings({})
|
||||
OrderInfoBO convert(OrderDO orderDO);
|
||||
}
|
||||
@@ -48,117 +48,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
*/
|
||||
public static final int PAY_EXPIRE_TIME = 120;
|
||||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
@Autowired
|
||||
private OrderItemMapper orderItemMapper;
|
||||
@Autowired
|
||||
private OrderLogisticsMapper orderLogisticsMapper;
|
||||
@Autowired
|
||||
private OrderLogisticsDetailMapper orderLogisticsDetailMapper;
|
||||
@Autowired
|
||||
private OrderRecipientMapper orderRecipientMapper;
|
||||
@Autowired
|
||||
private OrderCancelMapper orderCancelMapper;
|
||||
@Autowired
|
||||
private OrderReturnMapper orderReturnMapper;
|
||||
|
||||
@Autowired
|
||||
private CartServiceImpl cartService;
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.PromotionActivityService.version}")
|
||||
private ProductSpuService productSpuService;
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.UserAddressService.version}")
|
||||
private UserAddressService userAddressService;
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.PayTransactionService.version}")
|
||||
private PayTransactionService payTransactionService;
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
|
||||
private CouponService couponService;
|
||||
|
||||
@Override
|
||||
public CommonResult<OrderPageBO> getOrderPage(OrderQueryDTO orderQueryDTO) {
|
||||
|
||||
int totalCount = orderMapper.selectPageCount(orderQueryDTO);
|
||||
if (totalCount == 0) { // TODO FROM 芋艿 TO 小范 Collections.EMPTY_LIST 改成 Collections.emptyList()
|
||||
return CommonResult.success(new OrderPageBO().setOrders(Collections.EMPTY_LIST).setTotal(0));
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
List<OrderDO> orderDOList = orderMapper.selectPage(orderQueryDTO);
|
||||
|
||||
if (CollectionUtils.isEmpty(orderDOList)) {
|
||||
return CommonResult.success(new OrderPageBO().setOrders(Collections.EMPTY_LIST).setTotal(totalCount));
|
||||
}
|
||||
|
||||
// 获取订单 id
|
||||
Set<Integer> orderIds = orderDOList.stream()
|
||||
.map(orderDO -> orderDO.getId()) // TODO FROM 芋艿 to 小范,记得用 Lambda
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 获取配送信息
|
||||
List<OrderRecipientDO> orderRecipientDOList = orderRecipientMapper.selectByOrderIds(orderIds);
|
||||
List<OrderRecipientBO> orderRecipientBOList = OrderRecipientConvert.INSTANCE.convert(orderRecipientDOList);
|
||||
Map<Integer, OrderRecipientBO> orderRecipientBOMap
|
||||
= orderRecipientBOList.stream().collect(Collectors.toMap(OrderRecipientBO::getOrderId, obj -> obj));
|
||||
|
||||
// 获取 订单的 items
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderIds(orderIds, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
|
||||
List<OrderItemBO> orderItemBOList = OrderItemConvert.INSTANCE.convertOrderItemDO(orderItemDOList);
|
||||
Map<Integer, List<OrderItemBO>> orderItemBOMultimap = orderItemBOList.stream().collect(
|
||||
Collectors.toMap(
|
||||
OrderItemBO::getOrderId,
|
||||
item -> Lists.newArrayList(item),
|
||||
(oldVal, newVal) -> {
|
||||
oldVal.addAll(newVal);
|
||||
return oldVal;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// 转换 orderDO 为 OrderBO,并设置 item
|
||||
List<OrderBO> orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList);
|
||||
List<OrderBO> result = orderPageBOList.stream().map(orderBO -> {
|
||||
if (orderItemBOMultimap.containsKey(orderBO.getId())) {
|
||||
orderBO.setOrderItems(orderItemBOMultimap.get(orderBO.getId()));
|
||||
}
|
||||
if (orderRecipientBOMap.containsKey(orderBO.getId())) {
|
||||
orderBO.setOrderRecipient(orderRecipientBOMap.get(orderBO.getId()));
|
||||
}
|
||||
return orderBO;
|
||||
}).collect(Collectors.toList());
|
||||
return CommonResult.success(
|
||||
new OrderPageBO()
|
||||
.setTotal(totalCount)
|
||||
.setOrders(result)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<OrderItemBO>> getOrderItems(Integer orderId) {
|
||||
if (orderMapper.selectById(orderId) == null) {
|
||||
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
|
||||
}
|
||||
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
|
||||
List<OrderItemBO> orderItemBOList = OrderItemConvert.INSTANCE.convertOrderItemBO(orderItemDOList);
|
||||
return CommonResult.success(orderItemBOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<OrderRecipientBO> getOrderRecipientBO(Integer orderId) {
|
||||
if (orderMapper.selectById(orderId) == null) {
|
||||
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
|
||||
}
|
||||
|
||||
OrderRecipientDO orderRecipientDO = orderRecipientMapper.selectByOrderId(orderId);
|
||||
OrderRecipientBO orderRecipientBO = OrderRecipientConvert.INSTANCE.convert(orderRecipientDO);
|
||||
return CommonResult.success(orderRecipientBO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<OrderInfoBO> info(Integer userId, Integer orderId) {
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
spring:
|
||||
# datasource
|
||||
datasource:
|
||||
url: jdbc:mysql://s1.iocoder.cn:3306/mall_order?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 3WLiVUBEwTbvAfsh
|
||||
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
|
||||
# mybatis-plus
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
type-aliases-package: cn.iocoder.mall.order.biz.dataobject
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
||||
# Spring Cloud Alibaba Dubbo 专属配置
|
||||
cloud:
|
||||
subscribed-services: admin-application, user-application, product-application, promotion-application, pay-application # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||
# Dubbo 提供者的协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
# Dubbo 提供服务的扫描基础包
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.order.biz.service
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
filter: -exception
|
||||
CartService:
|
||||
version: 1.0.0
|
||||
OrderService:
|
||||
version: 1.0.0
|
||||
OrderReturnService:
|
||||
version: 1.0.0
|
||||
OrderLogisticsService:
|
||||
version: 1.0.0
|
||||
OrderCommentService:
|
||||
version: 1.0.0
|
||||
OrderCommentReplyService:
|
||||
version: 1.0.0
|
||||
consumer:
|
||||
timeout: 120000 # 设置长一点,方便调试代码
|
||||
ProductSpuService:
|
||||
version: 1.0.0
|
||||
PromotionActivityService:
|
||||
version: 1.0.0
|
||||
CouponService:
|
||||
version: 1.0.0
|
||||
PayRefundService:
|
||||
version: 1.0.0
|
||||
UserAddressService:
|
||||
version: 1.0.0
|
||||
PayTransactionService:
|
||||
version: 1.0.0
|
||||
DataDictService:
|
||||
version: 1.0.0
|
||||
|
||||
# logging
|
||||
logging:
|
||||
level:
|
||||
# dao 开启 debug 模式 mybatis 输入 sql
|
||||
cn.iocoder.mall.order.biz.dao: debug
|
||||
|
||||
# Seata 配置项
|
||||
seata:
|
||||
tx-service-group: default # Seata 事务组编号,用于 TC 集群名
|
||||
# 服务配置项,对应 ServiceProperties 类
|
||||
service:
|
||||
# 虚拟组和分组的映射
|
||||
vgroup-mapping:
|
||||
default: default
|
||||
# Seata 注册中心配置项
|
||||
registry:
|
||||
type: nacos # 注册中心类型
|
||||
nacos:
|
||||
serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址
|
||||
namespace: # Nacos 命名空间
|
||||
cluster: default # 使用的 Seata 分组
|
||||
Reference in New Issue
Block a user