use of com.fp.mall.order.model.entity.OrderInfoEntity in project FCLProject by FlowingCloudL.
the class OrderServiceImpl method submitOrder.
@GlobalTransactional
@Override
public Long submitOrder(Long uid, OrderSubmitDTO orderSubmitDTO) {
// 扣减库存
List<StockModifyBO> bos = orderSubmitDTO.getSkus().stream().map(dto -> {
StockModifyBO bo = new StockModifyBO();
BeanUtils.copyProperties(dto, bo);
return bo;
}).collect(Collectors.toList());
remoteStockService.decrStock(bos);
// 创建订单基本信息
OrderInfoEntity orderInfoEntity = new OrderInfoEntity();
BeanUtils.copyProperties(orderSubmitDTO, orderInfoEntity);
orderInfoEntity.setUserId(uid);
orderInfoEntity.setCreateTime(LocalDateTime.now());
orderInfoEntity.setUpdateTime(LocalDateTime.now());
orderInfoMapper.insert(orderInfoEntity);
// 创建订单项
for (OrderSubmitSkuDTO submitSkuDTO : orderSubmitDTO.getSkus()) {
// 远程调用获得订单项所需的SKU和SPU信息
OrderSpuBO orderSpuBO = remoteSpuService.getSpuBySkuId(submitSkuDTO.getSkuId());
// 生成订单项Entity
OrderItemEntity orderItemEntity = new OrderItemEntity();
// 设置订单id
orderItemEntity.setOrderId(orderInfoEntity.getOrderId());
// 设置spu部分
BeanUtils.copyProperties(orderSpuBO, orderItemEntity);
// 设置sku部分
BeanUtils.copyProperties(orderSpuBO.getSkuBO(), orderItemEntity);
// 设置单价
orderItemEntity.setSkuPrice(orderSpuBO.getSkuBO().getPrice());
// 设置数量
orderItemEntity.setSkuQuantity(submitSkuDTO.getCount());
// 计算订单项价格
orderItemEntity.setRealAmount(orderItemEntity.getSkuPrice().multiply(new BigDecimal(orderItemEntity.getSkuQuantity())));
orderItemMapper.insert(orderItemEntity);
}
return null;
}
use of com.fp.mall.order.model.entity.OrderInfoEntity in project FCLProject by FlowingCloudL.
the class TestController method test1.
@GetMapping("/t1")
public ResponseVO<List<OrderInfoVO>> test1() {
List<OrderInfoEntity> entityList = orderInfoMapper.selectList(new QueryWrapper<>());
List<OrderInfoVO> voList = new ArrayList<>(entityList.size());
for (OrderInfoEntity entity : entityList) {
OrderInfoVO vo = new OrderInfoVO();
BeanUtils.copyProperties(entity, vo);
voList.add(vo);
}
return ResponseVO.success(voList);
}
Aggregations