更新了优惠券模块

This commit is contained in:
chen-xin-zhi 2025-02-09 00:59:16 +08:00
parent 2ba3a71edd
commit 7bd07866ef
24 changed files with 1091 additions and 98 deletions

View File

@ -0,0 +1,285 @@
package com.cultural.heritage.controller.good;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cultural.heritage.common.BaseResponse;
import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonBatchRequest;
import com.cultural.heritage.model.dto.cartService.CartExperienceAddRequest;
import com.cultural.heritage.model.dto.cartService.CartExperienceUpdateRequest;
import com.cultural.heritage.model.dto.order.BuySingleGoodVerifyRequest;
import com.cultural.heritage.model.entity.CartExperience;
import com.cultural.heritage.model.entity.Good;
import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.model.vo.cartService.CartExperienceGoodVO;
import com.cultural.heritage.model.vo.cartService.CartExperienceOrderVO;
import com.cultural.heritage.model.vo.cartService.CartExperienceVO;
import com.cultural.heritage.service.good.CartExperienceService;
import com.cultural.heritage.service.good.GoodService;
import com.cultural.heritage.service.user.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.*;
@RestController
@RequestMapping("/cartExperience")
@Slf4j
@Tag(name = "服务类购物车模块")
public class CartExperienceController {
@Resource
private CartExperienceService cartExperienceService;
@Resource
private GoodService goodService;
@Resource
private UserService userService;
/**
* 小程序端用户添加服务类商品至购物车
* @param cartExperienceAddRequest 服务类购物车商品添加请求体
* @return 是否添加成功
*/
@PostMapping("/add")
@Operation(summary = "小程序端用户添加服务类商品至购物车", description = "参数服务类购物车商品添加请求体权限所有人方法名addCartRecord")
public BaseResponse<Boolean> addCartRecord(@RequestBody CartExperienceAddRequest cartExperienceAddRequest, HttpServletRequest request) {
if (cartExperienceAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// 更新购物车的商品属性
cartExperienceService.updateCartGoodAttribute(cartExperienceAddRequest, request);
return ResultUtils.success(true);
}
/**
* 小程序端用户更新服务类购物车中的商品数量
* @param cartExperienceUpdateRequestList 服务类购物车更新请求体
* @return 是否更新成功
*/
@PostMapping("/update")
@Operation(summary = "小程序端用户更新服务类购物车中的商品数量", description = "参数服务类购物车更新请求体权限所有人方法名updateCartRecord")
public BaseResponse<Boolean> updateCartRecord(@RequestBody List<CartExperienceUpdateRequest> cartExperienceUpdateRequestList, HttpServletRequest request) {
if (CollectionUtils.isEmpty(cartExperienceUpdateRequestList)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
userService.getLoginUser(request);
// 获取购物车id列表
List<Long> cartIds = cartExperienceUpdateRequestList.stream().map(CartExperienceUpdateRequest::getId).toList();
QueryWrapper<CartExperience> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", cartIds);
List<CartExperience> cartExperienceList = cartExperienceService.list(queryWrapper);
// 封装map集合购物车id, 商品数量
Map<Long, Integer> QuantityMap = new HashMap<>();
// 封装map集合购物车id, 预约时间
Map<Long, String> reservationDateMap = new HashMap<>();
// 封装map集合购物车id, 预约时间段
Map<Long, String> timeSlotMap = new HashMap<>();
for (CartExperienceUpdateRequest cartExperienceUpdateRequest : cartExperienceUpdateRequestList) {
Long id = cartExperienceUpdateRequest.getId();
Integer quantity = cartExperienceUpdateRequest.getQuantity();
String reservationDate = cartExperienceUpdateRequest.getReservationDate();
String timeSlot = cartExperienceUpdateRequest.getTimeSlot();
QuantityMap.put(id, quantity);
reservationDateMap.put(id, reservationDate);
timeSlotMap.put(id, timeSlot);
}
// 获取商品id列表
List<Long> goodIds = cartExperienceList.stream().map(CartExperience::getGoodId).toList();
QueryWrapper<Good> goodQueryWrapper = new QueryWrapper<>();
goodQueryWrapper.in("id", goodIds);
List<Good> goodList = goodService.list(goodQueryWrapper);
// 封装map集合商品id, 商品价格
Map<Long, BigDecimal> priceMap = new HashMap<>();
for (Good good : goodList) {
priceMap.put(good.getId(), good.getPrice());
}
// 批量更新购物车数量小计预约时间预约时间段
for (CartExperience cartExperience : cartExperienceList) {
Long cartRecordId = cartExperience.getId();
Integer quantity = QuantityMap.get(cartRecordId);
cartExperience.setQuantity(quantity);
Long goodId = cartExperience.getGoodId();
BigDecimal price = priceMap.get(goodId);
cartExperience.setSubtotal(price.multiply(BigDecimal.valueOf(quantity)));
String reservationDate = reservationDateMap.get(cartRecordId);
cartExperience.setReservationDate(reservationDate);
String timeSlot = timeSlotMap.get(cartRecordId);
cartExperience.setTimeSlot(timeSlot);
}
boolean result = cartExperienceService.updateBatchById(cartExperienceList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "购物车信息更新失败");
return ResultUtils.success(true);
}
/**
* 小程序端用户删除服务类购物车中的物品
* @param commonBatchRequest 删除的商品id列表
* @return 是否删除成功
*/
@PostMapping("/delete")
@Operation(summary = "小程序端用户删除服务类购物车中的物品", description = "参数:购物车记录删除请求体(商品id列表如[2,3,4])权限所有人方法名deleteCart")
public BaseResponse<Boolean> deleteCart(@RequestBody CommonBatchRequest commonBatchRequest, HttpServletRequest request) {
if (commonBatchRequest == null || commonBatchRequest.getIdList().isEmpty()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
userService.getLoginUser(request);
List<Long> idList = commonBatchRequest.getIdList();
boolean result = cartExperienceService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
}
/**
* 小程序端用户查询服务类购物车中的商品
* @return 商品列表信息
*/
@PostMapping("/list")
@Operation(summary = "小程序端用户查询服务类购物车中的商品", description = "参数权限所有人方法名listUserCartRecord")
public BaseResponse<List<CartExperienceVO>> listUserCartRecord(HttpServletRequest request) {
// 根据用户id查询购物车记录
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
QueryWrapper<CartExperience> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userId", userId);
queryWrapper.orderByDesc("id");
List<CartExperience> cartExperienceList = cartExperienceService.list(queryWrapper);
// 封装用户购物车中的商品信息
List<CartExperienceVO> cartExperienceVOList = cartExperienceService.transformToCartRecordVOList(cartExperienceList);
return ResultUtils.success(cartExperienceVOList);
}
/**
* 小程序端显示服务类购物车中不合理的商品项
* @return 存在问题的购物车id列表
*/
@PostMapping("/submit/error")
@Operation(summary = "小程序端显示服务类购物车中不合理的商品项", description = "参数:无权限所有人方法名listInvalidCartIds")
public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
QueryWrapper<CartExperience> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userId", userId);
List<CartExperience> cartExperienceList = cartExperienceService.list(queryWrapper);
// 找出存在问题的购物车id列表
List<Long> invalidCartIds = cartExperienceService.getInvalidCartIds(cartExperienceList);
return ResultUtils.success(invalidCartIds);
}
/**
* 小程序端显示服务类购物车提交订单页的商品信息
* @param commonBatchRequest 购物车id列表
* @return 订单商品信息列表
*/
@PostMapping("/submit/list")
@Operation(summary = "小程序端显示服务类购物车提交订单页的商品信息", description = "参数:商品id和购买数量信息权限所有人方法名listCartRecord")
public BaseResponse<List<CartExperienceOrderVO>> listCartRecord(@RequestBody CommonBatchRequest commonBatchRequest, HttpServletRequest request) {
if (commonBatchRequest == null || commonBatchRequest.getIdList().isEmpty()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
userService.getLoginUser(request);
List<Long> cartExperienceIds = commonBatchRequest.getIdList();
List<CartExperience> cartExperienceList = cartExperienceService.list();
// 获取购物车列表信息
List<CartExperience> cartExperiences = cartExperienceList.stream().filter(cartExperience -> {
Long id = cartExperience.getId();
return cartExperienceIds.contains(id);
}).toList();
// 提取出购物车中的商品id列表
List<Long> goodIds = cartExperiences.stream().map(CartExperience::getGoodId).toList();
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", goodIds);
List<Good> goodList = goodService.list(queryWrapper);
// 封装goodMap(根据商品id查询商品)
Map<Long, Good> goodMap = new HashMap<>();
for (Good good : goodList) {
goodMap.put(good.getId(), good);
}
// 封装提交订单页的商品信息列表
List<CartExperienceOrderVO> cartOrderVOList = new ArrayList<>();
for (CartExperience cartExperience : cartExperiences) {
Integer quantity = cartExperience.getQuantity();
Long goodId = cartExperience.getGoodId();
Good good = goodMap.get(goodId);
CartExperienceGoodVO cartExperienceGoodVO = new CartExperienceGoodVO();
BeanUtils.copyProperties(good, cartExperienceGoodVO);
CartExperienceOrderVO cartExperienceOrderVO = new CartExperienceOrderVO();
cartExperienceOrderVO.setCartExperienceGoodVO(cartExperienceGoodVO);
cartExperienceOrderVO.setQuantity(quantity);
cartExperienceOrderVO.setReservationDate(cartExperience.getReservationDate());
cartExperienceOrderVO.setTimeSlot(cartExperience.getTimeSlot());
cartOrderVOList.add(cartExperienceOrderVO);
}
Collections.reverse(cartOrderVOList);
return ResultUtils.success(cartOrderVOList);
}
/**
* 小程序端用户点击立即购买触发的校验
* @param buySingleGoodVerifyRequest 商品id和购买数量
* @return 是否通过校验
*/
@PostMapping("/verify/good")
@Operation(summary = "小程序端用户点击立即购买触发的校验", description = "参数:商品id和购买数量权限所有人方法名verifyPurchaseInfo")
public BaseResponse<Boolean> verifyPurchaseInfo(@RequestBody BuySingleGoodVerifyRequest buySingleGoodVerifyRequest, HttpServletRequest request) {
if (buySingleGoodVerifyRequest == null || buySingleGoodVerifyRequest.getGoodId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
userService.getLoginUser(request);
Long goodId = buySingleGoodVerifyRequest.getGoodId();
Integer quantity = buySingleGoodVerifyRequest.getQuantity();
Good good = goodService.getById(goodId);
ThrowUtils.throwIf(good == null || good.getIsShelves() == 0, ErrorCode.SYSTEM_ERROR, "商品已下架或不存在");
ThrowUtils.throwIf(quantity > good.getInventory(), ErrorCode.SYSTEM_ERROR, "商品库存不足");
return ResultUtils.success(true);
}
}

View File

@ -6,6 +6,7 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonBatchRequest;
import com.cultural.heritage.model.dto.cart.CartRecordAddRequest;
import com.cultural.heritage.model.dto.cart.CartRecordUpdateRequest;
import com.cultural.heritage.model.dto.order.BuySingleGoodVerifyRequest;
@ -36,7 +37,7 @@ import java.util.*;
@RestController
@RequestMapping("/cart")
@Slf4j
@Tag(name = "购物车信息模块")
@Tag(name = "常规类购物车模块")
public class CartRecordController {
@ -52,12 +53,12 @@ public class CartRecordController {
private UserService userService;
/**
* 用户添加商品至购物车
* @param cartRecordAddRequest 购物车记录添加请求体
* 小程序端用户添加常规类商品至购物车
* @param cartRecordAddRequest 常规类购物车商品添加请求体
* @return 是否添加成功
*/
@PostMapping("/add")
@Operation(summary = "小程序端用户添加商品至购物车", description = "参数:购物车记录添加请求体权限所有人方法名addCartRecord")
@Operation(summary = "小程序端用户添加常规类商品至购物车", description = "参数:常规类购物车商品添加请求体权限所有人方法名addCartRecord")
public BaseResponse<Boolean> addCartRecord(@RequestBody CartRecordAddRequest cartRecordAddRequest, HttpServletRequest request) {
if (cartRecordAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -69,34 +70,55 @@ public class CartRecordController {
/**
* 小程序端用户更新购物车中的商品数量
* @param cartRecordUpdateRequestList 购物车记录列表更新请求体
* 小程序端用户更新常规类购物车中的商品数量
* @param cartRecordUpdateRequestList 常规类购物车更新请求体
* @return 是否更新成功
*/
@PostMapping("/update")
@Operation(summary = "小程序端用户更新购物车中的商品数量", description = "参数:购物车记录更新请求体权限所有人方法名updateCartRecord")
@Operation(summary = "小程序端用户更新常规类购物车中的商品数量", description = "参数:常规类购物车更新请求体权限所有人方法名updateCartRecord")
public BaseResponse<Boolean> updateCartRecord(@RequestBody List<CartRecordUpdateRequest> cartRecordUpdateRequestList, HttpServletRequest request) {
if (CollectionUtils.isEmpty(cartRecordUpdateRequestList)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
List<CartRecord> cartRecordList = cartRecordUpdateRequestList.stream().map(cartRecordUpdateRequest -> {
userService.getLoginUser(request);
// 获取购物车id列表
List<Long> cartIds = cartRecordUpdateRequestList.stream().map(CartRecordUpdateRequest::getId).toList();
QueryWrapper<CartRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", cartIds);
List<CartRecord> cartRecordList = cartRecordService.list(queryWrapper);
// 封装map集合购物车id, 商品数量
Map<Long, Integer> QuantityMap = new HashMap<>();
for (CartRecordUpdateRequest cartRecordUpdateRequest : cartRecordUpdateRequestList) {
Long id = cartRecordUpdateRequest.getId();
CartRecord cart = cartRecordService.getById(id);
ThrowUtils.throwIf(cart == null, ErrorCode.OPERATION_ERROR, "该项商品已被移除");
CartRecord cartRecord = new CartRecord();
BeanUtils.copyProperties(cartRecordUpdateRequest, cartRecord);
Long goodId = cart.getGoodId();
Good good = goodService.getById(goodId);
ThrowUtils.throwIf(good == null || good.getIsShelves() == 0, ErrorCode.OPERATION_ERROR, "购物车商品更新失败");
cartRecord.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartRecord.getQuantity())));
cartRecord.setUserId(userId);
cartRecord.setGoodId(goodId);
// 校验
cartRecordService.validCart(cartRecord, true);
return cartRecord;
}).toList();
Integer quantity = cartRecordUpdateRequest.getQuantity();
QuantityMap.put(id, quantity);
}
// 获取商品id列表
List<Long> goodIds = cartRecordList.stream().map(CartRecord::getGoodId).toList();
QueryWrapper<Good> goodQueryWrapper = new QueryWrapper<>();
goodQueryWrapper.in("id", goodIds);
List<Good> goodList = goodService.list(goodQueryWrapper);
// 封装map集合商品id, 商品价格
Map<Long, BigDecimal> priceMap = new HashMap<>();
for (Good good : goodList) {
priceMap.put(good.getId(), good.getPrice());
}
// 批量更新购物车数量和小计
for (CartRecord cartRecord : cartRecordList) {
Long cartRecordId = cartRecord.getId();
Integer quantity = QuantityMap.get(cartRecordId);
cartRecord.setQuantity(quantity);
Long goodId = cartRecord.getGoodId();
BigDecimal price = priceMap.get(goodId);
cartRecord.setSubtotal(price.multiply(BigDecimal.valueOf(quantity)));
}
boolean result = cartRecordService.updateBatchById(cartRecordList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
@ -105,17 +127,18 @@ public class CartRecordController {
/**
* 用户删除购物车的物品
* @param idList 删除的商品id列表
* 小程序端用户删除常规类购物车的物品
* @param commonBatchRequest 删除的商品id列表
* @return 是否删除成功
*/
@PostMapping("/delete")
@Operation(summary = "小程序端用户删除购物车的物品", description = "参数:购物车记录删除请求体(商品id列表如[2,3,4])权限所有人方法名deleteCart")
public BaseResponse<Boolean> deleteCart(@RequestBody List<Integer> idList, HttpServletRequest request) {
if (CollectionUtils.isEmpty(idList)) {
@Operation(summary = "小程序端用户删除常规类购物车的物品", description = "参数:购物车记录删除请求体(商品id列表如[2,3,4])权限所有人方法名deleteCart")
public BaseResponse<Boolean> deleteCart(@RequestBody CommonBatchRequest commonBatchRequest, HttpServletRequest request) {
if (commonBatchRequest == null || commonBatchRequest.getIdList().isEmpty()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
userService.getLoginUser(request);
List<Long> idList = commonBatchRequest.getIdList();
boolean result = cartRecordService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
@ -124,11 +147,11 @@ public class CartRecordController {
/**
* 小程序端用户查询购物车中的商品
* 小程序端用户查询常规类购物车中的商品
* @return 商品列表信息
*/
@PostMapping("/list")
@Operation(summary = "小程序端用户查询购物车中的商品", description = "参数权限所有人方法名listUserCartRecord")
@Operation(summary = "小程序端用户查询常规类购物车中的商品", description = "参数权限所有人方法名listUserCartRecord")
public BaseResponse<List<CartRecordVO>> listUserCartRecord(HttpServletRequest request) {
// 根据用户id查询购物车记录
User loginUser = userService.getLoginUser(request);
@ -146,11 +169,11 @@ public class CartRecordController {
/**
* (小程序端)从购物车中找出不合理的商品项
* 小程序端显示常规类购物车中不合理的商品项
* @return 存在问题的购物车id列表
*/
@PostMapping("/submit/error")
@Operation(summary = "(小程序端)从购物车中找出不合理的商品项", description = "参数:无权限所有人方法名listInvalidCartIds")
@Operation(summary = "小程序端显示常规类购物车中不合理的商品项", description = "参数:无权限所有人方法名listInvalidCartIds")
public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
@ -167,17 +190,18 @@ public class CartRecordController {
/**
* (小程序端)展示购物车提交订单页的商品信息
* @param cartRecordIds 购物车id列表
* 小程序端显示常规类购物车提交订单页的商品信息
* @param commonBatchRequest 购物车id列表
* @return 订单商品信息列表
*/
@PostMapping("/submit/list")
@Operation(summary = "(小程序端)展示购物车提交订单页的商品信息", description = "参数:商品id和购买数量信息权限所有人方法名listCartRecord")
public BaseResponse<List<CartOrderVO>> listCartRecord(@RequestBody List<Long> cartRecordIds, HttpServletRequest request) {
if (CollectionUtils.isEmpty(cartRecordIds)) {
@Operation(summary = "小程序端显示常规类购物车提交订单页的商品信息", description = "参数:购物车id列表权限所有人方法名listCartRecord")
public BaseResponse<List<CartOrderVO>> listCartRecord(@RequestBody CommonBatchRequest commonBatchRequest, HttpServletRequest request) {
if (commonBatchRequest == null || commonBatchRequest.getIdList().isEmpty()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
userService.getLoginUser(request);
List<Long> cartRecordIds = commonBatchRequest.getIdList();
List<CartRecord> cartRecordList = cartRecordService.list();
// 获取购物车列表信息
List<CartRecord> cartRecords = cartRecordList.stream().filter(cartRecord -> {
@ -185,11 +209,6 @@ public class CartRecordController {
return cartRecordIds.contains(id);
}).toList();
// 判断是否存在无效的购物车id
if (cartRecords.size() < cartRecordIds.size()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "存在无效的购物车id");
}
// 提取出购物车中的商品id列表
List<Long> goodIds = cartRecords.stream().map(CartRecord::getGoodId).toList();
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
@ -208,8 +227,10 @@ public class CartRecordController {
Integer quantity = cartRecord.getQuantity();
Long goodId = cartRecord.getGoodId();
Good good = goodMap.get(goodId);
CartGoodVO cartGoodVO = new CartGoodVO();
BeanUtils.copyProperties(good, cartGoodVO);
CartOrderVO cartOrderVO = new CartOrderVO();
cartOrderVO.setCartGoodVO(cartGoodVO);
cartOrderVO.setQuantity(quantity);
@ -224,12 +245,12 @@ public class CartRecordController {
/**
* (小程序端)用户点击立即购买或者支付订单触发的校验
* 小程序端用户点击立即购买触发的校验
* @param buySingleGoodVerifyRequest 商品id和购买数量
* @return 是否通过校验
*/
@PostMapping("/verify/good")
@Operation(summary = "(小程序端)用户点击立即购买或者支付订单触发的校验", description = "参数:商品id和购买数量权限所有人方法名verifyPurchaseInfo")
@Operation(summary = "小程序端用户点击立即购买触发的校验", description = "参数:商品id和购买数量权限所有人方法名verifyPurchaseInfo")
public BaseResponse<Boolean> verifyPurchaseInfo(@RequestBody BuySingleGoodVerifyRequest buySingleGoodVerifyRequest, HttpServletRequest request) {
if (buySingleGoodVerifyRequest == null || buySingleGoodVerifyRequest.getGoodId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);

View File

@ -519,11 +519,11 @@ public class GoodController {
List<TimePeriodVO> timePeriodVOList = timeMap.get(dateId);
if (result == 0) {
timePeriodVOList = timePeriodVOList.stream().filter(timePeriodVO -> {
String startTime = timePeriodVO.getTimeSlot().split("-")[0];
String currentTime = DateUtil.format(DateUtil.date(), "HH:mm");
String startTime = timePeriodVO.getTimeSlot().split("-")[0] + ":00";
String currentTime = DateUtil.format(DateUtil.date(), "HH:mm:ss");
Date startDate = DateUtil.parse(startTime, "HH:mm");
Date currentDate = DateUtil.parse(currentTime, "HH:mm");
Date startDate = DateUtil.parse(startTime, "HH:mm:ss");
Date currentDate = DateUtil.parse(currentTime, "HH:mm:ss");
return startDate.after(currentDate);
}).toList();
if (timePeriodVOList.isEmpty()) continue;

View File

@ -81,41 +81,6 @@ public class OrderController {
/**
* 小程序端用户创建常规类商品购物车订单
*/
@PostMapping("/add/cart")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "小程序端用户创建常规类商品购物车订单", description = "参数购物车订单创建请求体权限所有人方法名addCartOrder")
public BaseResponse<Long> addCartOrder(@RequestBody CartOrderAddRequest cartOrderAddRequest, HttpServletRequest request) {
if (cartOrderAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// 校验用户当前是否处于登录态
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
// 校验购物车数据是否准确
List<CartOrderItemAddRequest> cartOrderItemAddRequestList = cartOrderAddRequest.getCartOrderItemAddRequestList();
boolean isAccurate = cartRecordService.validIsConsistent(cartOrderItemAddRequestList);
ThrowUtils.throwIf(!isAccurate, ErrorCode.OPERATION_ERROR, "当前购物车中的某些商品已下架或者库存不足,无法生成订单");
// 封装成订单主要信息请求体
OrderMainInfoAddRequest orderMainInfoAddRequest = orderService.packagedOrderMainInfoAddRequest(cartOrderAddRequest);
// 创建通用订单(常规类和服务类商品)
List<Long> cartIds = cartOrderItemAddRequestList.stream().map(CartOrderItemAddRequest::getCartRecordId).toList();
Long orderId = orderService.createCommonOrder(orderMainInfoAddRequest, userId, true, cartIds, false);
// 向消息队列中发送订单创建的消息
orderService.sendCreateOrderMessage(orderId);
return ResultUtils.success(orderId);
}
/**
* 小程序端用户创建常规类(服务类商品订单
* @param generalGoodSingleBuyAddRequest 常规类商品单独购买创建请求体
@ -156,6 +121,44 @@ public class OrderController {
/**
* 小程序端用户创建常规类商品购物车订单
*/
@PostMapping("/add/cart")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "小程序端用户创建常规类商品购物车订单", description = "参数购物车订单创建请求体权限所有人方法名addCartOrder")
public BaseResponse<Long> addCartOrder(@RequestBody CartOrderAddRequest cartOrderAddRequest, HttpServletRequest request) {
if (cartOrderAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// 校验用户当前是否处于登录态
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
// 校验购物车数据是否准确
List<CartOrderItemAddRequest> cartOrderItemAddRequestList = cartOrderAddRequest.getCartOrderItemAddRequestList();
boolean isAccurate = cartRecordService.validIsConsistent(cartOrderItemAddRequestList);
ThrowUtils.throwIf(!isAccurate, ErrorCode.OPERATION_ERROR, "当前购物车中的某些商品已下架或者库存不足,无法生成订单");
// 封装成订单主要信息请求体
OrderMainInfoAddRequest orderMainInfoAddRequest = orderService.packagedOrderMainInfoAddRequest(cartOrderAddRequest);
// 创建通用订单(常规类和服务类商品)
List<Long> cartIds = cartOrderItemAddRequestList.stream().map(CartOrderItemAddRequest::getCartRecordId).toList();
Long orderId = orderService.createCommonOrder(orderMainInfoAddRequest, userId, true, cartIds, false);
// 向消息队列中发送订单创建的消息
orderService.sendCreateOrderMessage(orderId);
return ResultUtils.success(orderId);
}
/**
* Web端管理员分页查询订单
* @param orderQueryRequest 订单查询请求体

View File

@ -0,0 +1,7 @@
package com.cultural.heritage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cultural.heritage.model.entity.CartExperience;
public interface CartExperienceMapper extends BaseMapper<CartExperience> {
}

View File

@ -4,4 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cultural.heritage.model.entity.RefundRecord;
public interface RefundRecordMapper extends BaseMapper<RefundRecord> {
}

View File

@ -0,0 +1,40 @@
package com.cultural.heritage.model.dto.cartService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "购物车记录添加请求体", requiredProperties = {"goodId", "quantity"})
public class CartExperienceAddRequest implements Serializable {
/**
* 商品id
*/
@Schema(description = "商品id(id > 0)", example = "20")
private Long goodId;
/**
* 数量
*/
@Schema(description = "商品数量(quantity > 0)", example = "3")
private Integer quantity;
/**
* 预约日期
*/
@Schema(description = "预约日期", example = "2025-02-08")
private String reservationDate;
/**
* 预约时间段
*/
@Schema(description = "预约时间段", example = "8:00-11:00")
private String timeSlot;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,62 @@
package com.cultural.heritage.model.dto.cartService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@Schema(description = "购物车订单创建请求体", requiredProperties = {"orderType", "userName", "addressId",
"couponId", "totalAmount", "note", "cartPayRequestList"})
public class CartExperienceOrderAddRequest implements Serializable {
/**
* 订单类别
*/
@Schema(description = "订单类别", example = "product")
private String orderType;
/**
* 用户昵称
*/
@Schema(description = "用户昵称", example = "张三")
private String userName;
/**
* 地址id
*/
@Schema(description = "地址id(id > 0)", example = "12")
private Long addressId;
/**
* 优惠券id
*/
@Schema(description = "优惠券id(id > 0)", example = "2")
private Long couponId;
/**
* 订单备注
*/
@Schema(description = "订单备注", example = "希望能完整体验非遗文化,保持产品原貌,妥善包装")
private String note;
/**
* 购物车订单明细创建请求体
*/
@Schema(description = "购物车订单明细创建请求体")
private List<CartExperienceOrderItemAddRequest> cartOrderItemAddRequestList;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,30 @@
package com.cultural.heritage.model.dto.cartService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "购物车订单明细创建请求体", requiredProperties = {"cartRecordId", "quantity"})
public class CartExperienceOrderItemAddRequest implements Serializable {
/**
* 购物车id
*/
@Schema(description = "购物车id(id > 0)", example = "20")
private Long cartRecordId;
/**
* 数量
*/
@Schema(description = "商品数量(quantity > 0)", example = "3")
private Integer quantity;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,43 @@
package com.cultural.heritage.model.dto.cartService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "购物车记录更新请求体", requiredProperties = {"id", "quantity"})
public class CartExperienceUpdateRequest implements Serializable {
/**
* 购物车记录id
*/
@Schema(description = "购物车记录Id(id > 0)", example = "5")
private Long id;
/**
* 数量
*/
@Schema(description = "商品数量(quantity > 0)", example = "3")
private Integer quantity;
/**
* 预约日期
*/
@Schema(description = "预约日期", example = "2025-02-08")
private String reservationDate;
/**
* 预约时间段
*/
@Schema(description = "预约时间段", example = "10:00-12:00")
private String timeSlot;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,75 @@
package com.cultural.heritage.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 服务类商品购物车
* @TableName cart_experience
*/
@Data
@TableName("cart_experience")
public class CartExperience implements Serializable {
/**
* 购物车记录id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 商品id
*/
private Long goodId;
/**
* 数量
*/
private Integer quantity;
/**
* 小计
*/
private BigDecimal subtotal;
/**
* 预约日期
*/
private String reservationDate;
/**
* 预约时间段
*/
private String timeSlot;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -11,7 +11,7 @@ import java.math.BigDecimal;
import java.util.Date;
/**
* 常规类购物车添加商品
* 常规类商品购物车
* @TableName cart_record
*/
@Data
@ -56,10 +56,6 @@ public class CartRecord implements Serializable {
*/
private Date updateTime;
/**
* 是否删除
*/
private Integer isDelete;

View File

@ -3,7 +3,6 @@ package com.cultural.heritage.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
@ -18,7 +17,6 @@ import java.util.Date;
*/
@Data
@TableName(value = "refund_record")
@Schema(description = "退款记录", requiredProperties = {"id", "outTradeNo", "outRefundNo", "refundAmount"})
public class RefundRecord implements Serializable {

View File

@ -21,7 +21,6 @@ public class CartOrderVO implements Serializable {
private Integer quantity;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -32,7 +32,7 @@ public class CartRecordVO implements Serializable {
/**
* 购物车商品详情信息
* 常规类购物车商品详情信息
*/
private CartGoodVO cartGoodVO;

View File

@ -0,0 +1,41 @@
package com.cultural.heritage.model.vo.cartService;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class CartExperienceGoodVO implements Serializable {
/**
* 商品编号
*/
private Long id;
/**
* 商品名
*/
private String name;
/**
* 商品类型
*/
private String type;
/**
* 商品价格
*/
private BigDecimal price;
/**
* 商品图片
*/
private String goodImg;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,38 @@
package com.cultural.heritage.model.vo.cartService;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class CartExperienceOrderVO implements Serializable {
/**
* 商品详细信息
*/
private CartExperienceGoodVO cartExperienceGoodVO;
/**
* 商品购买数量
*/
private Integer quantity;
/**
* 预约日期
*/
private String reservationDate;
/**
* 预约时间段
*/
private String timeSlot;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,54 @@
package com.cultural.heritage.model.vo.cartService;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class CartExperienceVO implements Serializable {
/**
* 购物车记录id
*/
private Long id;
/**
* 商品id
*/
private Long goodId;
/**
* 数量
*/
private Integer quantity;
/**
* 小计
*/
private BigDecimal subtotal;
/**
* 预约日期
*/
private String reservationDate;
/**
* 预约时间段
*/
private String timeSlot;
/**
* 服务类购物车商品详情信息
*/
private CartExperienceGoodVO cartExperienceGoodVO;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,45 @@
package com.cultural.heritage.service.good;
import com.baomidou.mybatisplus.extension.service.IService;
import com.cultural.heritage.model.dto.cartService.CartExperienceAddRequest;
import com.cultural.heritage.model.entity.CartExperience;
import com.cultural.heritage.model.vo.cartService.CartExperienceVO;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
public interface CartExperienceService extends IService<CartExperience> {
/**
* 更新购物车的商品属性
*/
boolean updateCartGoodAttribute(CartExperienceAddRequest cartExperienceAddRequest, HttpServletRequest request);
/**
* 封装用户购物车中的商品信息
*/
List<CartExperienceVO> transformToCartRecordVOList(List<CartExperience> cartExperienceList);
/**
* 校验购物车中的商品信息
*/
void validCart(CartExperience cartExperience, boolean update);
// /**
// * 在提交订单页校验购物车商品项的准确性
// */
// boolean validIsConsistent(List<CartOrderItemAddRequest> cartOrderItemAddRequestList);
/**
* 找出存在问题的购物车id列表
*/
List<Long> getInvalidCartIds(List<CartExperience> cartExperienceList);
}

View File

@ -33,4 +33,6 @@ public interface GoodService extends IService<Good> {
* 更新购物车中的小计
*/
List<CartRecord> updateCartGoodPrice(Long goodId, BigDecimal targetPrice);
}

View File

@ -0,0 +1,249 @@
package com.cultural.heritage.service.good.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.CartExperienceMapper;
import com.cultural.heritage.model.dto.cartService.CartExperienceAddRequest;
import com.cultural.heritage.model.entity.CartExperience;
import com.cultural.heritage.model.entity.Good;
import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.model.vo.cartService.CartExperienceGoodVO;
import com.cultural.heritage.model.vo.cartService.CartExperienceVO;
import com.cultural.heritage.service.good.CartExperienceService;
import com.cultural.heritage.service.good.GoodService;
import com.cultural.heritage.service.user.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class CartExperienceServiceImpl extends ServiceImpl<CartExperienceMapper, CartExperience> implements CartExperienceService {
@Resource
private GoodService goodService;
@Resource
private UserService userService;
/**
* 更新购物车的商品属性
*/
@Override
public boolean updateCartGoodAttribute(CartExperienceAddRequest cartExperienceAddRequest, HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
Long goodId = cartExperienceAddRequest.getGoodId();
Good good = goodService.getById(goodId);
ThrowUtils.throwIf(good == null || good.getIsShelves() == 0, ErrorCode.OPERATION_ERROR, "商品不存在或者已下架");
QueryWrapper<CartExperience> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userId", userId);
queryWrapper.eq("goodId", goodId);
CartExperience cartExperience = this.baseMapper.selectOne(queryWrapper);
if (cartExperience != null) {
// 判断数量是否超出库存
int currentQuantity = cartExperience.getQuantity() + cartExperienceAddRequest.getQuantity();
if (currentQuantity > good.getInventory()) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "商品库存不足, 无法添加");
}
// 如果购物车中已存在该商品, 就叠加数量
cartExperience.setQuantity(currentQuantity);
cartExperience.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(currentQuantity)));
boolean result = this.updateById(cartExperience);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "更新购物车商品数量失败");
} else {
// 判断数量是否超出库存
Integer currentQuantity = cartExperienceAddRequest.getQuantity();
if (currentQuantity > good.getInventory()) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "商品库存不足, 无法添加");
}
// 如果购物车不存在该商品就向购物车中添加一项
CartExperience cartExperienceRecord = new CartExperience();
BeanUtils.copyProperties(cartExperienceAddRequest, cartExperienceRecord);
cartExperienceRecord.setUserId(userId);
cartExperienceRecord.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartExperienceRecord.getQuantity())));
// 校验
this.validCart(cartExperienceRecord, false);
boolean result = this.save(cartExperienceRecord);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
}
return true;
}
/**
* 封装用户购物车中的商品信息
*/
@Override
public List<CartExperienceVO> transformToCartRecordVOList(List<CartExperience> cartExperienceList) {
// 获取所有商品id
List<Long> goodIds = cartExperienceList.stream().map(CartExperience::getGoodId).toList();
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", goodIds);
List<Good> goodList = goodService.list(queryWrapper);
// 封装map集合商品id, 商品详情信息
Map<Long, Good> map = new HashMap<>();
for (Good good : goodList) {
map.put(good.getId(), good);
}
return cartExperienceList.stream().map(cartExperience -> {
CartExperienceVO cartExperienceVO = new CartExperienceVO();
BeanUtils.copyProperties(cartExperience, cartExperienceVO);
CartExperienceGoodVO cartExperienceGoodVO = new CartExperienceGoodVO();
Long goodId = cartExperience.getGoodId();
Good good = map.get(goodId);
BeanUtils.copyProperties(good, cartExperienceGoodVO);
cartExperienceVO.setCartExperienceGoodVO(cartExperienceGoodVO);
return cartExperienceVO;
}).toList();
}
/**
* 校验购物车中的商品信息
*/
@Override
public void validCart(CartExperience cartExperience, boolean update) {
Long userId = cartExperience.getUserId();
Long goodId = cartExperience.getGoodId();
Integer quantity = cartExperience.getQuantity();
BigDecimal subtotal = cartExperience.getSubtotal();
String reservationDate = cartExperience.getReservationDate();
String timeSlot = cartExperience.getTimeSlot();
if (update) {
if (userId == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
}
Good good = goodService.getById(goodId);
if (good == null || good.getIsShelves() == 0) {
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "不存在该商品或该商品已下架");
}
if (StringUtils.isAnyBlank(reservationDate, timeSlot)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "预约日期或者预约时间段参数为空");
}
String startTime = timeSlot.split("-")[0];
String advanceDateTimeStr = reservationDate + " " + startTime + ":00";
String currentDateTimeStr = DateUtil.now();
Date advanceDateTime = DateUtil.parse(advanceDateTimeStr, "yyyy-MM-dd HH:mm:ss");
Date currentDateTime = DateUtil.parse(currentDateTimeStr, "yyyy-MM-dd HH:mm:ss");
int result = DateUtil.compare(advanceDateTime, currentDateTime);
ThrowUtils.throwIf(result <= 0, ErrorCode.OPERATION_ERROR, "当前时间段已过期");
if (ObjectUtils.isEmpty(quantity) || quantity < 1) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请传递正确的商品数量");
}
if (ObjectUtils.isEmpty(subtotal) || subtotal.compareTo(BigDecimal.ZERO) <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "价格错误");
}
}
/**
* 校验购物车商品项的准确性
*/
private boolean validIsConsistent(CartExperience cartExperience, Good good) {
// 校验购物车中的商品是否存在
if (good == null || good.getIsShelves() == 0) {
log.info("商品不存在或者已下架, 购物车id为" + cartExperience.getId());
return false;
}
// 判断当前时间是否晚于预约时间
String reservationDate = cartExperience.getReservationDate();
String startTime = cartExperience.getTimeSlot().split("-")[0];
String advanceDateTimeStr = reservationDate + " " + startTime + ":00";
String currentDateTimeStr = DateUtil.now();
Date advanceDateTime = DateUtil.parse(advanceDateTimeStr, "yyyy-MM-dd HH:mm:ss");
Date currentDateTime = DateUtil.parse(currentDateTimeStr, "yyyy-MM-dd HH:mm:ss");
int result = DateUtil.compare(advanceDateTime, currentDateTime);
return result > 0;
}
// /**
// * 在提交订单页校验购物车商品项的准确性
// */
// @Override
// public boolean validIsConsistent(List<CartOrderItemAddRequest> cartOrderItemAddRequestList) {
// if (cartOrderItemAddRequestList.size() == 0) {
// throw new BusinessException(ErrorCode.PARAMS_ERROR, "购物车中没有商品");
// }
// // 封装map集合购物车id, 购买数量
// Map<Long, Integer> map = new HashMap<>();
// for (CartOrderItemAddRequest cartOrderItemAddRequest : cartOrderItemAddRequestList) {
// Long cartRecordId = cartOrderItemAddRequest.getCartRecordId();
// Integer quantity = cartOrderItemAddRequest.getQuantity();
// map.put(cartRecordId, quantity);
// }
// // 修改购物车商品项的购买数量
// List<Long> cartRecordIds = cartOrderItemAddRequestList.stream().map(CartOrderItemAddRequest::getCartRecordId).toList();
// QueryWrapper<CartRecord> queryWrapper = new QueryWrapper<>();
// queryWrapper.in("id", cartRecordIds);
// List<CartRecord> cartRecordList = this.list(queryWrapper);
// for (CartRecord cartRecord : cartRecordList) {
// Long id = cartRecord.getId();
// Integer quantity = map.get(id);
// cartRecord.setQuantity(quantity);
// }
// List<Long> cartIds = getInvalidCartIds(cartRecordList);
// return cartIds.isEmpty();
// }
/**
* 找出存在问题的购物车id列表
*/
@Override
public List<Long> getInvalidCartIds(List<CartExperience> cartExperienceList) {
// 获取购物车的商品id列表
List<Long> goodIds = cartExperienceList.stream().map(CartExperience::getGoodId).toList();
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", goodIds);
List<Good> goodList = goodService.list(queryWrapper);
// 封装map集合商品id, 商品详情信息
Map<Long, Good> map = new HashMap<>();
for (Good good : goodList) {
map.put(good.getId(), good);
}
List<CartExperience> cartExperiences = cartExperienceList.stream().filter(cartExperience -> {
Long goodId = cartExperience.getGoodId();
Good good = map.get(goodId);
return !validIsConsistent(cartExperience, good);
}).toList();
return cartExperiences.stream().map(CartExperience::getId).toList();
}
}

View File

@ -6,7 +6,6 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.CartRecordMapper;
import com.cultural.heritage.mapper.GoodMapper;
import com.cultural.heritage.model.dto.cart.CartOrderItemAddRequest;
import com.cultural.heritage.model.dto.cart.CartRecordAddRequest;
import com.cultural.heritage.model.entity.CartRecord;
@ -34,9 +33,6 @@ import java.util.Map;
public class CartRecordServiceImpl extends ServiceImpl<CartRecordMapper, CartRecord> implements CartRecordService {
@Resource
private GoodMapper goodMapper;
@Resource
private GoodService goodService;

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cultural.heritage.mapper.CartExperienceMapper">
</mapper>

View File

@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cultural.heritage.model.dto.refund.RefundRecordAddRequest">
<mapper namespace="com.cultural.heritage.mapper.RefundRecordMapper">
</mapper>