前端:订单确认页,接入优惠劵列表(不包括计算)
后端:增加优惠劵的计算逻辑
This commit is contained in:
@@ -96,7 +96,7 @@ public class UsersCartController {
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
// 计算商品价格
|
||||
CommonResult<CalcOrderPriceBO> calcOrderPriceResult = list0(cartItems);
|
||||
CommonResult<CalcOrderPriceBO> calcOrderPriceResult = list0(cartItems, null);
|
||||
if (calcOrderPriceResult.isError()) {
|
||||
return CommonResult.error(calcOrderPriceResult);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class UsersCartController {
|
||||
}
|
||||
|
||||
@GetMapping("/confirm_create_order")
|
||||
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder() {
|
||||
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("couponCardId") Integer couponCardId) {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
// 获得购物车中选中的
|
||||
List<CartItemBO> cartItems = cartService.list(userId, true).getData();
|
||||
@@ -117,7 +117,7 @@ public class UsersCartController {
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
// 计算商品价格
|
||||
CommonResult<CalcOrderPriceBO> calcOrderPriceResult = list0(cartItems);
|
||||
CommonResult<CalcOrderPriceBO> calcOrderPriceResult = list0(cartItems, couponCardId);
|
||||
if (calcOrderPriceResult.isError()) {
|
||||
return CommonResult.error(calcOrderPriceResult);
|
||||
}
|
||||
@@ -130,10 +130,12 @@ public class UsersCartController {
|
||||
.setCouponCards(couponCards));
|
||||
}
|
||||
|
||||
private CommonResult<CalcOrderPriceBO> list0(List<CartItemBO> cartItems) {
|
||||
private CommonResult<CalcOrderPriceBO> list0(List<CartItemBO> cartItems, Integer couponCardId) {
|
||||
// 创建计算的 DTO
|
||||
CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
|
||||
.setItems(new ArrayList<>(cartItems.size()));
|
||||
.setUserId(UserSecurityContextHolder.getContext().getUserId())
|
||||
.setItems(new ArrayList<>(cartItems.size()))
|
||||
.setCouponCardId(couponCardId);
|
||||
for (CartItemBO item : cartItems) {
|
||||
calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), item.getSelected()));
|
||||
}
|
||||
|
||||
@@ -93,10 +93,13 @@ public class UsersOrderController {
|
||||
@GetMapping("confirm_create_order")
|
||||
@ApiOperation("确认创建订单")
|
||||
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
|
||||
@RequestParam("quantity") Integer quantity) {
|
||||
@RequestParam("quantity") Integer quantity,
|
||||
@RequestParam("couponCardId") Integer couponCardId) {
|
||||
// 创建 CalcOrderPriceDTO 对象,并执行价格计算
|
||||
CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
|
||||
.setItems(Collections.singletonList(new CalcOrderPriceDTO.Item(skuId, quantity, true)));
|
||||
.setUserId(UserSecurityContextHolder.getContext().getUserId())
|
||||
.setItems(Collections.singletonList(new CalcOrderPriceDTO.Item(skuId, quantity, true)))
|
||||
.setCouponCardId(couponCardId);
|
||||
CommonResult<CalcOrderPriceBO> calcOrderPriceResult = cartService.calcOrderPrice(calcOrderPriceDTO);
|
||||
if (calcOrderPriceResult.isError()) {
|
||||
return CommonResult.error(calcOrderPriceResult);
|
||||
|
||||
@@ -24,7 +24,6 @@ public class UsersOrderConfirmCreateVO {
|
||||
* 优惠劵列表 TODO 芋艿,后续改改
|
||||
*/
|
||||
private List<CouponCardAvailableBO> couponCards;
|
||||
|
||||
/**
|
||||
* 商品分组
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user