更新了写真预约模块

This commit is contained in:
chen-xin-zhi 2025-02-17 20:05:05 +08:00
parent 0ab17a9393
commit 8026b76afe
5 changed files with 65 additions and 104 deletions

View File

@ -196,9 +196,7 @@ public class CartExperienceController {
public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) { public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) {
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
QueryWrapper<CartExperience> queryWrapper = new QueryWrapper<>(); List<CartExperience> cartExperienceList = commonService.findByFieldEqTargetField("userId", userId, cartExperienceService);
queryWrapper.eq("userId", userId);
List<CartExperience> cartExperienceList = cartExperienceService.list(queryWrapper);
// 找出存在问题的购物车id列表 // 找出存在问题的购物车id列表
List<Long> invalidCartIds = cartExperienceService.getInvalidCartIds(cartExperienceList); List<Long> invalidCartIds = cartExperienceService.getInvalidCartIds(cartExperienceList);
return ResultUtils.success(invalidCartIds); return ResultUtils.success(invalidCartIds);

View File

@ -174,9 +174,7 @@ public class CartRecordController {
public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) { public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) {
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
QueryWrapper<CartRecord> queryWrapper = new QueryWrapper<>(); List<CartRecord> cartRecords = commonService.findByFieldEqTargetField("userId", userId, cartRecordService);
queryWrapper.eq("userId", userId);
List<CartRecord> cartRecords = cartRecordService.list(queryWrapper);
// 找出存在问题的购物车id列表 // 找出存在问题的购物车id列表
List<Long> invalidCartIds = cartRecordService.getInvalidCartIds(cartRecords); List<Long> invalidCartIds = cartRecordService.getInvalidCartIds(cartRecords);
return ResultUtils.success(invalidCartIds); return ResultUtils.success(invalidCartIds);

View File

@ -99,15 +99,11 @@ public class CategoryController {
ThrowUtils.throwIf(category == null, ErrorCode.OPERATION_ERROR, "当前类别不存在"); ThrowUtils.throwIf(category == null, ErrorCode.OPERATION_ERROR, "当前类别不存在");
String typeName = category.getTypeName(); String typeName = category.getTypeName();
QueryWrapper<Good> queryWrapper = new QueryWrapper<>(); List<Good> goodList = commonService.findByFieldEqTargetField("type", typeName, goodService);
queryWrapper.eq("type", typeName);
List<Good> goodList = goodService.list(queryWrapper); boolean isSuccess = goodService.removeBatchByIds(goodList);
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
// 如果该类别下有商品就删除
if (!goodList.isEmpty()) {
boolean isSuccess = goodService.removeBatchByIds(goodList);
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
}
// 删除当前类别 // 删除当前类别
boolean result = categoryService.removeById(id); boolean result = categoryService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "类别删除失败"); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "类别删除失败");
@ -131,16 +127,11 @@ public class CategoryController {
List<Long> idList = commonDelBatchRequest.getIdList(); List<Long> idList = commonDelBatchRequest.getIdList();
// 批量删除当前类别下的所有商品 // 批量删除当前类别下的所有商品
List<Category> categoryList = commonService.findByFieldInTargetField(idList, categoryService, id -> id, "id"); List<Category> categoryList = commonService.findByFieldInTargetField(idList, categoryService, id -> id, "id");
List<String> typeNameList = categoryList.stream().map(Category::getTypeName).toList(); List<Good> goodList = commonService.findByFieldInTargetField(categoryList, goodService, Category::getTypeName, "type");
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
queryWrapper.in("type", typeNameList);
List<Good> goodList = goodService.list(queryWrapper);
// 如果该类别下有商品就删除 // 批量删除商品
if (!goodList.isEmpty()) { boolean result = goodService.removeBatchByIds(goodList);
boolean result = goodService.removeBatchByIds(goodList); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
}
// 批量删除当前类别 // 批量删除当前类别
boolean remove = categoryService.removeBatchByIds(categoryList); boolean remove = categoryService.removeBatchByIds(categoryList);
@ -215,15 +206,10 @@ public class CategoryController {
@Operation(summary = "小程序端用户查询商品类别", description = "参数权限所有人方法名listCategory") @Operation(summary = "小程序端用户查询商品类别", description = "参数权限所有人方法名listCategory")
public BaseResponse<List<Category>> listCategory(HttpServletRequest request) { public BaseResponse<List<Category>> listCategory(HttpServletRequest request) {
userService.getLoginUser(request); userService.getLoginUser(request);
QueryWrapper<Good> goodQueryWrapper = new QueryWrapper<>(); // 获取所有已上架的商品
goodQueryWrapper.eq("isShelves", 1); List<Good> goodList = commonService.findByFieldEqTargetField("isShelves", 1, goodService);
List<Good> goodList = goodService.list(goodQueryWrapper); // 获取所有存在上架商品的商品类别
List<String> typeNameList = goodList.stream().map(Good::getType).toList(); List<Category> categoryList = commonService.findByFieldInTargetField(goodList, categoryService, Good::getType, "typeName");
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.in("typeName", typeNameList);
List<Category> categoryList = categoryService.list(queryWrapper);
return ResultUtils.success(categoryList); return ResultUtils.success(categoryList);
} }

View File

@ -24,6 +24,7 @@ import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.model.entity.UserCoupon; import com.cultural.heritage.model.entity.UserCoupon;
import com.cultural.heritage.model.vo.coupon.CouponVO; import com.cultural.heritage.model.vo.coupon.CouponVO;
import com.cultural.heritage.model.vo.coupon.UserCouponVO; import com.cultural.heritage.model.vo.coupon.UserCouponVO;
import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.service.good.CouponService; import com.cultural.heritage.service.good.CouponService;
import com.cultural.heritage.service.good.UserCouponService; import com.cultural.heritage.service.good.UserCouponService;
import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.service.user.UserService;
@ -39,7 +40,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@ -60,6 +63,10 @@ public class CouponController {
private UserCouponService userCouponService; private UserCouponService userCouponService;
@Resource
private CommonService commonService;
/** /**
@ -132,7 +139,6 @@ public class CouponController {
boolean result = couponService.saveOrUpdate(coupon); boolean result = couponService.saveOrUpdate(coupon);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券更新失败"); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券更新失败");
// 向消息队列中发送优惠券创建的消息 // 向消息队列中发送优惠券创建的消息
couponService.sendCouponCreateMessage(coupon); couponService.sendCouponCreateMessage(coupon);
@ -193,7 +199,6 @@ public class CouponController {
if (couponQueryRequest == null) { if (couponQueryRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
// 对优惠券是否过期预处理 // 对优惠券是否过期预处理
long current = couponQueryRequest.getCurrent(); long current = couponQueryRequest.getCurrent();
long pageSize = couponQueryRequest.getPageSize(); long pageSize = couponQueryRequest.getPageSize();
@ -270,17 +275,13 @@ public class CouponController {
} }
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
QueryWrapper<UserCoupon> queryWrapper = new QueryWrapper<>(); Map<String, Object> fieldConditions = new HashMap<>();
queryWrapper.eq("userId", userId); fieldConditions.put("userId", userId);
queryWrapper.eq("isUsed", 0); fieldConditions.put("isUsed", 0);
List<UserCoupon> userCouponList = userCouponService.list(); List<UserCoupon> userCouponList = commonService.findByFieldEqTargetFields(fieldConditions, userCouponService);
userCouponList = userCouponList.stream().filter(userCoupon -> userCoupon.getCouponVO().getStatus().equals(status)).toList(); userCouponList = userCouponList.stream().filter(userCoupon -> userCoupon.getCouponVO().getStatus().equals(status)).toList();
List<UserCouponVO> userCouponVOS = userCouponList.stream().map(userCoupon -> { List<UserCouponVO> userCouponVOS = commonService.convertList(userCouponList, UserCouponVO.class);
UserCouponVO userCouponVO = new UserCouponVO();
BeanUtils.copyProperties(userCoupon, userCouponVO);
return userCouponVO;
}).toList();
return ResultUtils.success(userCouponVOS); return ResultUtils.success(userCouponVOS);
} }
@ -296,11 +297,7 @@ public class CouponController {
QueryWrapper<Coupon> queryWrapper = new QueryWrapper<>(); QueryWrapper<Coupon> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status", "可用"); queryWrapper.eq("status", "可用");
List<Coupon> coupons = couponService.list(queryWrapper); List<Coupon> coupons = couponService.list(queryWrapper);
List<CouponVO> couponVOS = coupons.stream().map(coupon -> { List<CouponVO> couponVOS = commonService.convertList(coupons, CouponVO.class);
CouponVO couponVO = new CouponVO();
BeanUtils.copyProperties(coupon, couponVO);
return couponVO;
}).toList();
return ResultUtils.success(couponVOS); return ResultUtils.success(couponVOS);
} }
@ -372,11 +369,11 @@ public class CouponController {
} }
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
QueryWrapper<UserCoupon> queryWrapper = new QueryWrapper<>(); Map<String, Object> fieldConditions = new HashMap<>();
queryWrapper.eq("userId", userId); fieldConditions.put("userId", userId);
queryWrapper.eq("isUsed", 0); fieldConditions.put("isUsed", 0);
queryWrapper.eq("status", "可用"); fieldConditions.put("status", "可用");
List<UserCoupon> userCouponList = userCouponService.list(queryWrapper); List<UserCoupon> userCouponList = commonService.findByFieldEqTargetFields(fieldConditions, userCouponService);
userCouponList = userCouponList.stream().filter(userCoupon -> userCoupon.getCouponVO().getStatus().equals("可用")).toList(); userCouponList = userCouponList.stream().filter(userCoupon -> userCoupon.getCouponVO().getStatus().equals("可用")).toList();
// 获取()可使用的优惠券 // 获取()可使用的优惠券
@ -388,12 +385,7 @@ public class CouponController {
return isAvailable == (result >= 0); return isAvailable == (result >= 0);
}).toList(); }).toList();
List<UserCouponVO> userCouponVOS = userCoupons.stream().map(userCoupon -> { List<UserCouponVO> userCouponVOS = commonService.convertList(userCoupons, UserCouponVO.class);
UserCouponVO userCouponVO = new UserCouponVO();
BeanUtils.copyProperties(userCoupon, userCouponVO);
return userCouponVO;
}).toList();
return ResultUtils.success(userCouponVOS); return ResultUtils.success(userCouponVOS);
} }

View File

@ -32,6 +32,7 @@ import com.cultural.heritage.model.vo.good.GoodPageVO;
import com.cultural.heritage.model.vo.good.ServiceGoodCardVO; import com.cultural.heritage.model.vo.good.ServiceGoodCardVO;
import com.cultural.heritage.model.vo.good.ServiceGoodVO; import com.cultural.heritage.model.vo.good.ServiceGoodVO;
import com.cultural.heritage.model.vo.timePeriod.TimePeriodVO; import com.cultural.heritage.model.vo.timePeriod.TimePeriodVO;
import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.service.good.*; import com.cultural.heritage.service.good.*;
import com.cultural.heritage.service.order.PendingServiceGoodService; import com.cultural.heritage.service.order.PendingServiceGoodService;
import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.service.user.UserService;
@ -86,6 +87,10 @@ public class GoodController {
private PendingServiceGoodService pendingServiceGoodService; private PendingServiceGoodService pendingServiceGoodService;
@Resource
private CommonService commonService;
/** /**
@ -225,21 +230,18 @@ public class GoodController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = deleteRequest.getId(); Long id = deleteRequest.getId();
// 获取预约日期列表
List<AppointmentDate> appointmentDateList = commonService.findByFieldEqTargetField("goodId", id, appointmentDateService);
// 获取预约时间段列表
List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId");
// 删除预约时间段表中与该商品关联的记录 // 删除预约时间段表中与该商品关联的记录
QueryWrapper<AppointmentDate> dateQueryWrapper = new QueryWrapper<>(); boolean remove = timePeriodService.removeBatchByIds(timePeriodList);
dateQueryWrapper.eq("goodId", id);
List<AppointmentDate> appointmentDateList = appointmentDateService.list(dateQueryWrapper);
List<Long> ids = appointmentDateList.stream().map(AppointmentDate::getId).toList();
QueryWrapper<TimePeriod> timePeriodQueryWrapper = new QueryWrapper<>();
timePeriodQueryWrapper.in("appointmentDateId", ids);
boolean remove = timePeriodService.remove(timePeriodQueryWrapper);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败"); ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
// 删除预约日期表中与该商品关联的记录 // 删除预约日期表中与该商品关联的记录
boolean isSuccess = appointmentDateService.remove(dateQueryWrapper); boolean isSuccess = appointmentDateService.removeBatchByIds(appointmentDateList);
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败"); ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
// 删除商品表中的服务类商品 // 删除商品表中的服务类商品
boolean result = goodService.removeById(id); boolean result = goodService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败"); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败");
@ -273,25 +275,20 @@ public class GoodController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
List<Long> ids = commonBatchRequest.getIdList(); List<Long> ids = commonBatchRequest.getIdList();
// 获取预约日期列表
List<AppointmentDate> appointmentDateList = commonService.findByFieldEqTargetField("goodId", ids, appointmentDateService);
// 获取预约时间段列表
List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId");
//删除预约时间段表中与该商品关联的记录 //删除预约时间段表中与该商品关联的记录
QueryWrapper<AppointmentDate> queryWrapper = new QueryWrapper<>(); boolean success = timePeriodService.removeBatchByIds(timePeriodList);
queryWrapper.in("goodId", ids);
List<AppointmentDate> appointmentDateList = appointmentDateService.list(queryWrapper);
List<Long> appointmentDateIds = appointmentDateList.stream().map(AppointmentDate::getId).toList();
QueryWrapper<TimePeriod> timePeriodQueryWrapper = new QueryWrapper<>();
timePeriodQueryWrapper.in("appointmentDateId", appointmentDateIds);
boolean success = timePeriodService.remove(timePeriodQueryWrapper);
ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败"); ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
// 删除预约日期表中与该商品关联的记录 // 删除预约日期表中与该商品关联的记录
boolean remove = appointmentDateService.remove(queryWrapper); boolean remove = appointmentDateService.removeBatchByIds(appointmentDateList);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败"); ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
// 删除商品表中的服务类商品 // 删除商品表中的服务类商品
boolean result = goodService.removeBatchByIds(ids); boolean result = goodService.removeBatchByIds(ids);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败"); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败");
// 批量删除服务类商品待处理记录 // 批量删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>();
goodQueryWrapper.in("goodId", ids); goodQueryWrapper.in("goodId", ids);
@ -316,7 +313,6 @@ public class GoodController {
if (goodUpdateRequest == null || goodUpdateRequest.getId() <= 0) { if (goodUpdateRequest == null || goodUpdateRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
// 获取原来的商品价格 // 获取原来的商品价格
Long sourceId = goodUpdateRequest.getId(); Long sourceId = goodUpdateRequest.getId();
Good resourceGood = goodService.getById(sourceId); Good resourceGood = goodService.getById(sourceId);
@ -357,11 +353,7 @@ public class GoodController {
QueryWrapper<Good> goodQueryWrapper = goodService.getGoodQueryWrapper(goodQueryRequest, false); QueryWrapper<Good> goodQueryWrapper = goodService.getGoodQueryWrapper(goodQueryRequest, false);
Page<Good> page = goodService.page(new Page<>(current, pageSize), goodQueryWrapper); Page<Good> page = goodService.page(new Page<>(current, pageSize), goodQueryWrapper);
List<Good> records = page.getRecords(); List<Good> records = page.getRecords();
List<GoodPageVO> goodPageVOS = records.stream().map(good -> { List<GoodPageVO> goodPageVOS = commonService.convertList(records, GoodPageVO.class);
GoodPageVO goodPageVO = new GoodPageVO();
BeanUtils.copyProperties(good, goodPageVO);
return goodPageVO;
}).toList();
Page<GoodPageVO> goodPageVOPage = new Page<>(); Page<GoodPageVO> goodPageVOPage = new Page<>();
goodPageVOPage.setRecords(goodPageVOS); goodPageVOPage.setRecords(goodPageVOS);
goodPageVOPage.setTotal(page.getTotal()); goodPageVOPage.setTotal(page.getTotal());
@ -384,6 +376,9 @@ public class GoodController {
@Operation(summary = "Web端管理员批量删除常规类商品", description = "参数:商品批量删除请求体,权限:管理员(admin, boss)方法名delBatchGoods") @Operation(summary = "Web端管理员批量删除常规类商品", description = "参数:商品批量删除请求体,权限:管理员(admin, boss)方法名delBatchGoods")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> delBatchGoods(@RequestBody CommonBatchRequest commonDelBatchRequest) { public BaseResponse<Boolean> delBatchGoods(@RequestBody CommonBatchRequest commonDelBatchRequest) {
if (commonDelBatchRequest == null || CollectionUtils.isEmpty(commonDelBatchRequest.getIdList())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
List<Long> idList = commonDelBatchRequest.getIdList(); List<Long> idList = commonDelBatchRequest.getIdList();
boolean result = goodService.removeBatchByIds(idList); boolean result = goodService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
@ -407,7 +402,7 @@ public class GoodController {
} }
Long id = getByIdRequest.getId(); Long id = getByIdRequest.getId();
Good good = goodService.getById(id); Good good = goodService.getById(id);
ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR); ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "商品不存在");
GoodPageVO goodPageVO = new GoodPageVO(); GoodPageVO goodPageVO = new GoodPageVO();
BeanUtils.copyProperties(good, goodPageVO); BeanUtils.copyProperties(good, goodPageVO);
return ResultUtils.success(goodPageVO); return ResultUtils.success(goodPageVO);
@ -573,7 +568,6 @@ public class GoodController {
AppointmentDateVO appointmentDateVO = dateMap.get(dateId); AppointmentDateVO appointmentDateVO = dateMap.get(dateId);
// 过滤掉没有空闲的预约日期 // 过滤掉没有空闲的预约日期
if (appointmentDateVO.getIsAvailable() == 0) continue; if (appointmentDateVO.getIsAvailable() == 0) continue;
// 过滤掉已过期的预约时间段 // 过滤掉已过期的预约时间段
String specificDate = appointmentDateVO.getSpecificDate(); String specificDate = appointmentDateVO.getSpecificDate();
String today = DateUtil.today(); String today = DateUtil.today();
@ -619,11 +613,7 @@ public class GoodController {
QueryWrapper<Good> queryWrapper = new QueryWrapper<>(); QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("isGoodType", 0); queryWrapper.eq("isGoodType", 0);
List<Good> goodList = goodService.list(queryWrapper); List<Good> goodList = goodService.list(queryWrapper);
List<ServiceGoodCardVO> serviceGoodCardVOS = goodList.stream().map(good -> { List<ServiceGoodCardVO> serviceGoodCardVOS = commonService.convertList(goodList, ServiceGoodCardVO.class);
ServiceGoodCardVO serviceGoodCardVO = new ServiceGoodCardVO();
BeanUtils.copyProperties(good, serviceGoodCardVO);
return serviceGoodCardVO;
}).toList();
return ResultUtils.success(serviceGoodCardVOS); return ResultUtils.success(serviceGoodCardVOS);
} }
@ -674,20 +664,16 @@ public class GoodController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = commonRequest.getId(); Long id = commonRequest.getId();
//删除预约时间段表中与该商品关联的记录 // 获取预约日期列表
QueryWrapper<AppointmentDate> dateQueryWrapper = new QueryWrapper<>(); List<AppointmentDate> appointmentDateList = commonService.findByFieldEqTargetField("goodId", id, appointmentDateService);
dateQueryWrapper.eq("goodId", id); // 获取预约时间段列表
List<AppointmentDate> appointmentDateList = appointmentDateService.list(dateQueryWrapper); List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId");
List<Long> ids = appointmentDateList.stream().map(AppointmentDate::getId).toList(); // 删除预约时间段表中与该商品关联的记录
QueryWrapper<TimePeriod> timePeriodQueryWrapper = new QueryWrapper<>(); boolean remove = timePeriodService.removeBatchByIds(timePeriodList);
timePeriodQueryWrapper.in("appointmentDateId", ids);
boolean remove = timePeriodService.remove(timePeriodQueryWrapper);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败"); ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
// 删除预约日期表中与该商品关联的记录 // 删除预约日期表中与该商品关联的记录
boolean isSuccess = appointmentDateService.remove(dateQueryWrapper); boolean isSuccess = appointmentDateService.removeBatchByIds(appointmentDateList);
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败"); ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
// 删除服务类商品待处理记录 // 删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("goodId", id); queryWrapper.eq("goodId", id);
@ -765,6 +751,7 @@ public class GoodController {
// 获取当前服务类商品的上()架状态 // 获取当前服务类商品的上()架状态
Long id = commonRequest.getId(); Long id = commonRequest.getId();
Good good = goodService.getById(id); Good good = goodService.getById(id);
ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "商品不存在");
Integer status = good.getIsShelves() == 0 ? 1 : 0; Integer status = good.getIsShelves() == 0 ? 1 : 0;
UpdateWrapper<Good> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Good> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);