From e9707e9c4da8e528a10b9a33ec550bfbddc0fe9f Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Sat, 1 Mar 2025 08:57:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/OrderStatusConstant.java | 3 -- .../book/PhotoProductsController.java | 42 +++++++++++++++---- .../controller/good/GoodController.java | 7 ++-- .../order/AdvanceOrderController.java | 22 +++++++++- .../heritage/model/entity/BookingTime.java | 2 + .../model/vo/bookingTime/BookingTimeVO.java | 1 + .../book/impl/AdvanceOrderServiceImpl.java | 7 ++-- .../service/good/impl/GoodServiceImpl.java | 5 +-- .../service/wx/impl/WeChatServiceImpl.java | 2 +- 9 files changed, 69 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java b/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java index 91291c3..eeb9258 100644 --- a/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java +++ b/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java @@ -21,7 +21,4 @@ public interface OrderStatusConstant { String PAYMENT_REFUNDED = "已退款"; - String PENDING_CONSUME = "待消费"; - - } diff --git a/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java b/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java index de719d5..07b7cb9 100644 --- a/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java +++ b/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java @@ -10,6 +10,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; @@ -20,15 +21,16 @@ import com.cultural.heritage.model.dto.bookingTime.BookingTimeAddRequest; import com.cultural.heritage.model.dto.photoProducts.PhotoProductsAddRequest; import com.cultural.heritage.model.dto.photoProducts.PhotoProductsQueryRequest; import com.cultural.heritage.model.dto.photoProducts.PhotoProductsUpdateRequest; +import com.cultural.heritage.model.entity.AdvanceOrder; import com.cultural.heritage.model.entity.BookingDate; import com.cultural.heritage.model.entity.BookingTime; import com.cultural.heritage.model.entity.PhotoProducts; import com.cultural.heritage.model.vo.bookingDate.BookingDateVO; import com.cultural.heritage.model.vo.bookingTime.BookingTimeVO; import com.cultural.heritage.model.vo.photoProducts.PhotoProductsVO; +import com.cultural.heritage.service.book.AdvanceOrderService; import com.cultural.heritage.service.book.BookingDateService; import com.cultural.heritage.service.book.BookingTimeService; -import com.cultural.heritage.service.book.PhotoCategoryService; import com.cultural.heritage.service.book.PhotoProductsService; import com.cultural.heritage.service.common.CommonService; import io.swagger.v3.oas.annotations.Operation; @@ -43,7 +45,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/photoProducts") @@ -56,22 +60,26 @@ public class PhotoProductsController { private PhotoProductsService photoProductsService; - @Resource - private PhotoCategoryService photoCategoryService; - @Resource private BookingDateService bookingDateService; + @Resource private BookingTimeService bookingTimeService; + @Resource private CommonService commonService; + + @Resource + private AdvanceOrderService advanceOrderService; + + /** * Web端管理员添加写真产品 * @param photoProductsAddRequest 写真产品添加请求体 @@ -302,6 +310,18 @@ public class PhotoProductsController { if (commonRequest == null || commonRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); } + + // 获取所有写真预约类订单 + Map isOccupiedMap = new HashMap<>(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("orderStatus", OrderStatusConstant.PENDING_PAYMENT).or().eq("orderStatus", OrderStatusConstant.PENDING_SHIPMENT); + List advanceOrderList = advanceOrderService.list(queryWrapper); + for (AdvanceOrder advanceOrder : advanceOrderList) { + String specificDate = advanceOrder.getSpecificDate(); + String timePoint = advanceOrder.getTimePoint(); + isOccupiedMap.put(specificDate + "&" + timePoint, 1); + } + Long id = commonRequest.getId(); PhotoProducts photoProducts = photoProductsService.getById(id); ThrowUtils.throwIf(photoProducts == null || photoProducts.getIsShelves() == 0, ErrorCode.OPERATION_ERROR, "该商品已被删除或者已下架"); @@ -347,18 +367,24 @@ public class PhotoProductsController { String today = DateUtil.today(); int result = DateUtil.compare(DateUtil.parse(specificDate), DateUtil.parse(today)); if (result < 0) continue; - // 如果预约日期相同,过滤掉预约时间 + // 如果预约日期相同,过滤掉预约时间以及被占用的时间 + List bookingTimeVOS = bookingDateVO.getBookingTimeVOList(); if (result == 0) { - List bookingTimeVOS = bookingDateVO.getBookingTimeVOList(); bookingTimeVOS = bookingTimeVOS.stream().filter(bookingTimeVO -> { String timePoint = bookingTimeVO.getTimePoint() + ":00"; DateTime targetTime = DateUtil.parse(timePoint, "HH:mm:ss"); DateTime now = DateUtil.date(); DateTime currentTime = DateUtil.parse(now.toString("HH:mm:ss"), "HH:mm:ss"); - return currentTime.compareTo(targetTime) < 0; + return currentTime.compareTo(targetTime) < 0 && isOccupiedMap.get(specificDate + "&" + timePoint) == null; + }).toList(); + } else { + bookingTimeVOS = bookingTimeVOS.stream().filter(bookingTimeVO -> { + String timePoint = bookingTimeVO.getTimePoint(); + return isOccupiedMap.get(specificDate + "&" + timePoint) == null; }).toList(); - if (bookingTimeVOS.isEmpty()) continue; } + if (bookingTimeVOS.isEmpty()) continue; + bookingDateVO.setBookingTimeVOList(bookingTimeVOS); bookingDateVOList.add(bookingDateVO); } diff --git a/src/main/java/com/cultural/heritage/controller/good/GoodController.java b/src/main/java/com/cultural/heritage/controller/good/GoodController.java index 0405174..bdd7ab5 100644 --- a/src/main/java/com/cultural/heritage/controller/good/GoodController.java +++ b/src/main/java/com/cultural/heritage/controller/good/GoodController.java @@ -613,9 +613,10 @@ public class GoodController { @Operation(summary = "小程序端展示服务类商品卡片", description = "参数:无,权限:所有人,方法名:listServiceGoodCardVO") public BaseResponse> listServiceGoodCardVO(HttpServletRequest request) { userService.getLoginUser(request); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("isGoodType", 0); - List goodList = goodService.list(queryWrapper); + Map map = new HashMap<>(); + map.put("isGoodType", 0); + map.put("isShelves", 1); + List goodList = commonService.findByFieldEqTargetFields(map, goodService); List serviceGoodCardVOS = commonService.convertList(goodList, ServiceGoodCardVO.class); return ResultUtils.success(serviceGoodCardVOS); } diff --git a/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java b/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java index ba330fb..71b2917 100644 --- a/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java +++ b/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java @@ -203,12 +203,32 @@ public class AdvanceOrderController { List advanceOrderList = advanceOrderService.list(queryWrapper); // 封装成写真预约订单VO List advanceOrderVOS = commonService.convertList(advanceOrderList, AdvanceOrderVO.class); - Collections.reverse(advanceOrderList); + Collections.reverse(advanceOrderVOS); return ResultUtils.success(advanceOrderVOS); } + /** + * 小程序端用户根据id删除写真预约订单 + * @return 是否删除成功 + */ + @PostMapping("/delete") + @Operation(summary = "小程序端用户根据id删除写真预约订单", description = "参数:无, 权限:所有人,方法名:delAdvanceOrderById") + public BaseResponse delAdvanceOrderById(@RequestBody CommonRequest commonRequest, HttpServletRequest request) { + if (commonRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + userService.getLoginUser(request); + Long id = commonRequest.getId(); + AdvanceOrder advanceOrder = advanceOrderService.getById(id); + ThrowUtils.throwIf(advanceOrder == null || !advanceOrder.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.OPERATION_ERROR, "订单不存在或状态错误"); + boolean result = advanceOrderService.removeById(id); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单删除失败"); + return ResultUtils.success(true); + } + + } diff --git a/src/main/java/com/cultural/heritage/model/entity/BookingTime.java b/src/main/java/com/cultural/heritage/model/entity/BookingTime.java index 8629f50..554faee 100644 --- a/src/main/java/com/cultural/heritage/model/entity/BookingTime.java +++ b/src/main/java/com/cultural/heritage/model/entity/BookingTime.java @@ -35,11 +35,13 @@ public class BookingTime implements Serializable { */ private Long bookingDateId; + /** * 创建时间 */ private Date createTime; + /** * 更新时间 */ diff --git a/src/main/java/com/cultural/heritage/model/vo/bookingTime/BookingTimeVO.java b/src/main/java/com/cultural/heritage/model/vo/bookingTime/BookingTimeVO.java index 7f1dd09..0303ba4 100644 --- a/src/main/java/com/cultural/heritage/model/vo/bookingTime/BookingTimeVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/bookingTime/BookingTimeVO.java @@ -24,6 +24,7 @@ public class BookingTimeVO implements Serializable { private Long bookingDateId; + @Serial private static final long serialVersionUID = 1L; } diff --git a/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java b/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java index 00dfe4b..7dc827f 100644 --- a/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java @@ -128,9 +128,10 @@ public class AdvanceOrderServiceImpl extends ServiceImpl= 0, ErrorCode.OPERATION_ERROR, "当前预约时间已过期"); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("specificDate", specificDate); - queryWrapper.eq("timePoint", timePoint); - queryWrapper.eq("orderStatus", OrderStatusConstant.PENDING_CONSUME); + queryWrapper.eq("specificDate", specificDate) + .eq("timePoint", timePoint) + .and(wrapper -> wrapper.eq("orderStatus", OrderStatusConstant.PENDING_PAYMENT) + .or().eq("orderStatus", OrderStatusConstant.PENDING_SHIPMENT)); AdvanceOrder order = this.getOne(queryWrapper); ThrowUtils.throwIf(order != null, ErrorCode.OPERATION_ERROR, "当前时间已约满"); } diff --git a/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java index bd8fabb..418f579 100644 --- a/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java @@ -220,9 +220,8 @@ public class GoodServiceImpl extends ServiceImpl implements Go Long pendingId = pendingServiceGood.getId(); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("pendingId", pendingId); - queryWrapper.eq("orderItemStatus", OrderStatusConstant.PENDING_SHIPMENT); - queryWrapper.or().eq("orderItemStatus", OrderStatusConstant.PENDING_PAYMENT); + queryWrapper.eq("pendingId", pendingId) + .and(wrapper -> wrapper.eq("orderItemStatus", OrderStatusConstant.PENDING_SHIPMENT).or().eq("orderItemStatus", OrderStatusConstant.PENDING_PAYMENT)); List pendingServiceOrderList = pendingServiceOrderService.list(queryWrapper); Integer totalNumber = 0; for (PendingServiceOrder pendingServiceOrder : pendingServiceOrderList) { diff --git a/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java b/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java index 310df9e..d8f60c0 100644 --- a/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java @@ -191,7 +191,7 @@ public class WeChatServiceImpl implements WeChatService { AdvanceOrder advanceOrder = getAdvanceOrderInfoByOrderNumber(orderNumber); // 修改订单状态 - modifyAdvanceOrderStatus(advanceOrder, OrderStatusConstant.PENDING_CONSUME); + modifyAdvanceOrderStatus(advanceOrder, OrderStatusConstant.PENDING_SHIPMENT); System.out.println("---------------------------微信支付回调(结束)-------------------------------"); return true; }