parent
4a9055ecd3
commit
a191aa60f2
|
@ -10,11 +10,9 @@ import java.util.List;
|
|||
@Data
|
||||
@Schema(description = "结算实体类")
|
||||
public class TradeVo {
|
||||
|
||||
@Schema(description = "结算总金额")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Schema(description = "结算商品列表")
|
||||
private List<OrderItem> orderItemList;
|
||||
|
||||
}
|
|
@ -38,4 +38,11 @@ public class OrderInfoController {
|
|||
OrderInfo orderInfo = orderInfoService.getOrderInfo(orderId);
|
||||
return Result.success(orderInfo);
|
||||
}
|
||||
|
||||
@Operation(summary = "立即购买")
|
||||
@GetMapping("auth/buy/{skuId}")
|
||||
public Result<TradeVo> buy(@Parameter(name = "skuId", description = "商品skuId", required = true) @PathVariable Long skuId) {
|
||||
TradeVo tradeVo = orderInfoService.buy(skuId);
|
||||
return Result.success(tradeVo);
|
||||
}
|
||||
}
|
|
@ -27,4 +27,12 @@ public interface OrderInfoService {
|
|||
* @return OrderInfo
|
||||
*/
|
||||
OrderInfo getOrderInfo(Long orderId);
|
||||
|
||||
/**
|
||||
* 立即购买
|
||||
*
|
||||
* @param skuId 商品Id
|
||||
* @return 结算实体类
|
||||
*/
|
||||
TradeVo buy(Long skuId);
|
||||
}
|
||||
|
|
|
@ -160,4 +160,33 @@ public class OrderInfoServiceImpl implements OrderInfoService {
|
|||
public OrderInfo getOrderInfo(Long orderId) {
|
||||
return orderInfoMapper.getById(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即购买
|
||||
*
|
||||
* @param skuId 商品Id
|
||||
* @return 结算实体类
|
||||
*/
|
||||
@Override
|
||||
public TradeVo buy(Long skuId) {
|
||||
// 查询商品
|
||||
ProductSku productSku = productFeignClient.getBySkuId(skuId).getData();
|
||||
List<OrderItem> orderItemList = new ArrayList<>();
|
||||
OrderItem orderItem = new OrderItem();
|
||||
orderItem.setSkuId(skuId);
|
||||
orderItem.setSkuName(productSku.getSkuName());
|
||||
orderItem.setSkuNum(1);
|
||||
orderItem.setSkuPrice(productSku.getSalePrice());
|
||||
orderItem.setThumbImg(productSku.getThumbImg());
|
||||
orderItemList.add(orderItem);
|
||||
|
||||
// 计算总金额
|
||||
BigDecimal totalAmount = productSku.getSalePrice();
|
||||
TradeVo tradeVo = new TradeVo();
|
||||
tradeVo.setTotalAmount(totalAmount);
|
||||
tradeVo.setOrderItemList(orderItemList);
|
||||
|
||||
// 返回
|
||||
return tradeVo;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue