更新了写真预约模块
This commit is contained in:
parent
0ab17a9393
commit
8026b76afe
src/main/java/com/cultural/heritage/controller/good
|
@ -196,9 +196,7 @@ public class CartExperienceController {
|
|||
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);
|
||||
List<CartExperience> cartExperienceList = commonService.findByFieldEqTargetField("userId", userId, cartExperienceService);
|
||||
// 找出存在问题的购物车id列表
|
||||
List<Long> invalidCartIds = cartExperienceService.getInvalidCartIds(cartExperienceList);
|
||||
return ResultUtils.success(invalidCartIds);
|
||||
|
|
|
@ -174,9 +174,7 @@ public class CartRecordController {
|
|||
public BaseResponse<List<Long>> listInvalidCartIds (HttpServletRequest request) {
|
||||
User loginUser = userService.getLoginUser(request);
|
||||
Long userId = loginUser.getId();
|
||||
QueryWrapper<CartRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("userId", userId);
|
||||
List<CartRecord> cartRecords = cartRecordService.list(queryWrapper);
|
||||
List<CartRecord> cartRecords = commonService.findByFieldEqTargetField("userId", userId, cartRecordService);
|
||||
// 找出存在问题的购物车id列表
|
||||
List<Long> invalidCartIds = cartRecordService.getInvalidCartIds(cartRecords);
|
||||
return ResultUtils.success(invalidCartIds);
|
||||
|
|
|
@ -99,15 +99,11 @@ public class CategoryController {
|
|||
ThrowUtils.throwIf(category == null, ErrorCode.OPERATION_ERROR, "当前类别不存在");
|
||||
|
||||
String typeName = category.getTypeName();
|
||||
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("type", typeName);
|
||||
List<Good> goodList = goodService.list(queryWrapper);
|
||||
List<Good> goodList = commonService.findByFieldEqTargetField("type", typeName, goodService);
|
||||
|
||||
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);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "类别删除失败");
|
||||
|
@ -131,16 +127,11 @@ public class CategoryController {
|
|||
List<Long> idList = commonDelBatchRequest.getIdList();
|
||||
// 批量删除当前类别下的所有商品
|
||||
List<Category> categoryList = commonService.findByFieldInTargetField(idList, categoryService, id -> id, "id");
|
||||
List<String> typeNameList = categoryList.stream().map(Category::getTypeName).toList();
|
||||
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("type", typeNameList);
|
||||
List<Good> goodList = goodService.list(queryWrapper);
|
||||
List<Good> goodList = commonService.findByFieldInTargetField(categoryList, goodService, Category::getTypeName, "type");
|
||||
|
||||
// 如果该类别下有商品,就删除
|
||||
if (!goodList.isEmpty()) {
|
||||
boolean result = goodService.removeBatchByIds(goodList);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
|
||||
}
|
||||
// 批量删除商品
|
||||
boolean result = goodService.removeBatchByIds(goodList);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
|
||||
|
||||
// 批量删除当前类别
|
||||
boolean remove = categoryService.removeBatchByIds(categoryList);
|
||||
|
@ -215,15 +206,10 @@ public class CategoryController {
|
|||
@Operation(summary = "小程序端用户查询商品类别", description = "参数:无,权限:所有人,方法名:listCategory")
|
||||
public BaseResponse<List<Category>> listCategory(HttpServletRequest request) {
|
||||
userService.getLoginUser(request);
|
||||
QueryWrapper<Good> goodQueryWrapper = new QueryWrapper<>();
|
||||
goodQueryWrapper.eq("isShelves", 1);
|
||||
List<Good> goodList = goodService.list(goodQueryWrapper);
|
||||
List<String> typeNameList = goodList.stream().map(Good::getType).toList();
|
||||
|
||||
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("typeName", typeNameList);
|
||||
List<Category> categoryList = categoryService.list(queryWrapper);
|
||||
|
||||
// 获取所有已上架的商品
|
||||
List<Good> goodList = commonService.findByFieldEqTargetField("isShelves", 1, goodService);
|
||||
// 获取所有存在上架商品的商品类别
|
||||
List<Category> categoryList = commonService.findByFieldInTargetField(goodList, categoryService, Good::getType, "typeName");
|
||||
return ResultUtils.success(categoryList);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.cultural.heritage.model.entity.User;
|
|||
import com.cultural.heritage.model.entity.UserCoupon;
|
||||
import com.cultural.heritage.model.vo.coupon.CouponVO;
|
||||
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.UserCouponService;
|
||||
import com.cultural.heritage.service.user.UserService;
|
||||
|
@ -39,7 +40,9 @@ import org.springframework.util.CollectionUtils;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
|
@ -60,6 +63,10 @@ public class CouponController {
|
|||
private UserCouponService userCouponService;
|
||||
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -132,7 +139,6 @@ public class CouponController {
|
|||
boolean result = couponService.saveOrUpdate(coupon);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券更新失败");
|
||||
|
||||
|
||||
// 向消息队列中发送优惠券创建的消息
|
||||
couponService.sendCouponCreateMessage(coupon);
|
||||
|
||||
|
@ -193,7 +199,6 @@ public class CouponController {
|
|||
if (couponQueryRequest == null) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
// 对优惠券是否过期预处理
|
||||
long current = couponQueryRequest.getCurrent();
|
||||
long pageSize = couponQueryRequest.getPageSize();
|
||||
|
@ -270,17 +275,13 @@ public class CouponController {
|
|||
}
|
||||
User loginUser = userService.getLoginUser(request);
|
||||
Long userId = loginUser.getId();
|
||||
QueryWrapper<UserCoupon> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("userId", userId);
|
||||
queryWrapper.eq("isUsed", 0);
|
||||
List<UserCoupon> userCouponList = userCouponService.list();
|
||||
Map<String, Object> fieldConditions = new HashMap<>();
|
||||
fieldConditions.put("userId", userId);
|
||||
fieldConditions.put("isUsed", 0);
|
||||
List<UserCoupon> userCouponList = commonService.findByFieldEqTargetFields(fieldConditions, userCouponService);
|
||||
userCouponList = userCouponList.stream().filter(userCoupon -> userCoupon.getCouponVO().getStatus().equals(status)).toList();
|
||||
|
||||
List<UserCouponVO> userCouponVOS = userCouponList.stream().map(userCoupon -> {
|
||||
UserCouponVO userCouponVO = new UserCouponVO();
|
||||
BeanUtils.copyProperties(userCoupon, userCouponVO);
|
||||
return userCouponVO;
|
||||
}).toList();
|
||||
List<UserCouponVO> userCouponVOS = commonService.convertList(userCouponList, UserCouponVO.class);
|
||||
return ResultUtils.success(userCouponVOS);
|
||||
}
|
||||
|
||||
|
@ -296,11 +297,7 @@ public class CouponController {
|
|||
QueryWrapper<Coupon> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status", "可用");
|
||||
List<Coupon> coupons = couponService.list(queryWrapper);
|
||||
List<CouponVO> couponVOS = coupons.stream().map(coupon -> {
|
||||
CouponVO couponVO = new CouponVO();
|
||||
BeanUtils.copyProperties(coupon, couponVO);
|
||||
return couponVO;
|
||||
}).toList();
|
||||
List<CouponVO> couponVOS = commonService.convertList(coupons, CouponVO.class);
|
||||
return ResultUtils.success(couponVOS);
|
||||
}
|
||||
|
||||
|
@ -372,11 +369,11 @@ public class CouponController {
|
|||
}
|
||||
User loginUser = userService.getLoginUser(request);
|
||||
Long userId = loginUser.getId();
|
||||
QueryWrapper<UserCoupon> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("userId", userId);
|
||||
queryWrapper.eq("isUsed", 0);
|
||||
queryWrapper.eq("status", "可用");
|
||||
List<UserCoupon> userCouponList = userCouponService.list(queryWrapper);
|
||||
Map<String, Object> fieldConditions = new HashMap<>();
|
||||
fieldConditions.put("userId", userId);
|
||||
fieldConditions.put("isUsed", 0);
|
||||
fieldConditions.put("status", "可用");
|
||||
List<UserCoupon> userCouponList = commonService.findByFieldEqTargetFields(fieldConditions, userCouponService);
|
||||
userCouponList = userCouponList.stream().filter(userCoupon -> userCoupon.getCouponVO().getStatus().equals("可用")).toList();
|
||||
|
||||
// 获取(不)可使用的优惠券
|
||||
|
@ -388,12 +385,7 @@ public class CouponController {
|
|||
return isAvailable == (result >= 0);
|
||||
}).toList();
|
||||
|
||||
List<UserCouponVO> userCouponVOS = userCoupons.stream().map(userCoupon -> {
|
||||
UserCouponVO userCouponVO = new UserCouponVO();
|
||||
BeanUtils.copyProperties(userCoupon, userCouponVO);
|
||||
return userCouponVO;
|
||||
}).toList();
|
||||
|
||||
List<UserCouponVO> userCouponVOS = commonService.convertList(userCoupons, UserCouponVO.class);
|
||||
return ResultUtils.success(userCouponVOS);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.ServiceGoodVO;
|
||||
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.order.PendingServiceGoodService;
|
||||
import com.cultural.heritage.service.user.UserService;
|
||||
|
@ -86,6 +87,10 @@ public class GoodController {
|
|||
private PendingServiceGoodService pendingServiceGoodService;
|
||||
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -225,21 +230,18 @@ public class GoodController {
|
|||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
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<>();
|
||||
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);
|
||||
boolean remove = timePeriodService.removeBatchByIds(timePeriodList);
|
||||
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
|
||||
|
||||
// 删除预约日期表中与该商品关联的记录
|
||||
boolean isSuccess = appointmentDateService.remove(dateQueryWrapper);
|
||||
boolean isSuccess = appointmentDateService.removeBatchByIds(appointmentDateList);
|
||||
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
|
||||
|
||||
// 删除商品表中的服务类商品
|
||||
boolean result = goodService.removeById(id);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败");
|
||||
|
@ -273,25 +275,20 @@ public class GoodController {
|
|||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
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<>();
|
||||
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);
|
||||
boolean success = timePeriodService.removeBatchByIds(timePeriodList);
|
||||
ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
|
||||
|
||||
// 删除预约日期表中与该商品关联的记录
|
||||
boolean remove = appointmentDateService.remove(queryWrapper);
|
||||
boolean remove = appointmentDateService.removeBatchByIds(appointmentDateList);
|
||||
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
|
||||
|
||||
// 删除商品表中的服务类商品
|
||||
boolean result = goodService.removeBatchByIds(ids);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败");
|
||||
|
||||
|
||||
// 批量删除服务类商品待处理记录
|
||||
QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>();
|
||||
goodQueryWrapper.in("goodId", ids);
|
||||
|
@ -316,7 +313,6 @@ public class GoodController {
|
|||
if (goodUpdateRequest == null || goodUpdateRequest.getId() <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
// 获取原来的商品价格
|
||||
Long sourceId = goodUpdateRequest.getId();
|
||||
Good resourceGood = goodService.getById(sourceId);
|
||||
|
@ -357,11 +353,7 @@ public class GoodController {
|
|||
QueryWrapper<Good> goodQueryWrapper = goodService.getGoodQueryWrapper(goodQueryRequest, false);
|
||||
Page<Good> page = goodService.page(new Page<>(current, pageSize), goodQueryWrapper);
|
||||
List<Good> records = page.getRecords();
|
||||
List<GoodPageVO> goodPageVOS = records.stream().map(good -> {
|
||||
GoodPageVO goodPageVO = new GoodPageVO();
|
||||
BeanUtils.copyProperties(good, goodPageVO);
|
||||
return goodPageVO;
|
||||
}).toList();
|
||||
List<GoodPageVO> goodPageVOS = commonService.convertList(records, GoodPageVO.class);
|
||||
Page<GoodPageVO> goodPageVOPage = new Page<>();
|
||||
goodPageVOPage.setRecords(goodPageVOS);
|
||||
goodPageVOPage.setTotal(page.getTotal());
|
||||
|
@ -384,6 +376,9 @@ public class GoodController {
|
|||
@Operation(summary = "Web端管理员批量删除常规类商品", description = "参数:商品批量删除请求体,权限:管理员(admin, boss),方法名:delBatchGoods")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
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();
|
||||
boolean result = goodService.removeBatchByIds(idList);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
|
||||
|
@ -407,7 +402,7 @@ public class GoodController {
|
|||
}
|
||||
Long id = getByIdRequest.getId();
|
||||
Good good = goodService.getById(id);
|
||||
ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR);
|
||||
ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "商品不存在");
|
||||
GoodPageVO goodPageVO = new GoodPageVO();
|
||||
BeanUtils.copyProperties(good, goodPageVO);
|
||||
return ResultUtils.success(goodPageVO);
|
||||
|
@ -573,7 +568,6 @@ public class GoodController {
|
|||
AppointmentDateVO appointmentDateVO = dateMap.get(dateId);
|
||||
// 过滤掉没有空闲的预约日期
|
||||
if (appointmentDateVO.getIsAvailable() == 0) continue;
|
||||
|
||||
// 过滤掉已过期的预约时间段
|
||||
String specificDate = appointmentDateVO.getSpecificDate();
|
||||
String today = DateUtil.today();
|
||||
|
@ -619,11 +613,7 @@ public class GoodController {
|
|||
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("isGoodType", 0);
|
||||
List<Good> goodList = goodService.list(queryWrapper);
|
||||
List<ServiceGoodCardVO> serviceGoodCardVOS = goodList.stream().map(good -> {
|
||||
ServiceGoodCardVO serviceGoodCardVO = new ServiceGoodCardVO();
|
||||
BeanUtils.copyProperties(good, serviceGoodCardVO);
|
||||
return serviceGoodCardVO;
|
||||
}).toList();
|
||||
List<ServiceGoodCardVO> serviceGoodCardVOS = commonService.convertList(goodList, ServiceGoodCardVO.class);
|
||||
return ResultUtils.success(serviceGoodCardVOS);
|
||||
}
|
||||
|
||||
|
@ -674,20 +664,16 @@ public class GoodController {
|
|||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
Long id = commonRequest.getId();
|
||||
//删除预约时间段表中与该商品关联的记录
|
||||
QueryWrapper<AppointmentDate> dateQueryWrapper = new QueryWrapper<>();
|
||||
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);
|
||||
// 获取预约日期列表
|
||||
List<AppointmentDate> appointmentDateList = commonService.findByFieldEqTargetField("goodId", id, appointmentDateService);
|
||||
// 获取预约时间段列表
|
||||
List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId");
|
||||
// 删除预约时间段表中与该商品关联的记录
|
||||
boolean remove = timePeriodService.removeBatchByIds(timePeriodList);
|
||||
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
|
||||
|
||||
// 删除预约日期表中与该商品关联的记录
|
||||
boolean isSuccess = appointmentDateService.remove(dateQueryWrapper);
|
||||
boolean isSuccess = appointmentDateService.removeBatchByIds(appointmentDateList);
|
||||
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
|
||||
|
||||
// 删除服务类商品待处理记录
|
||||
QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("goodId", id);
|
||||
|
@ -765,6 +751,7 @@ public class GoodController {
|
|||
// 获取当前服务类商品的上(下)架状态
|
||||
Long id = commonRequest.getId();
|
||||
Good good = goodService.getById(id);
|
||||
ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "商品不存在");
|
||||
Integer status = good.getIsShelves() == 0 ? 1 : 0;
|
||||
UpdateWrapper<Good> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user