完善了订单信息
This commit is contained in:
parent
ab163a2b58
commit
f88b3d60e5
|
@ -13,12 +13,16 @@ import com.cultural.heritage.exception.ThrowUtils;
|
|||
import com.cultural.heritage.model.dto.CommonDelBatchRequest;
|
||||
import com.cultural.heritage.model.dto.CommonRequest;
|
||||
import com.cultural.heritage.model.dto.appointment.AppointmentDateAddRequest;
|
||||
import com.cultural.heritage.model.dto.appointment.AppointmentDateUpdateRequest;
|
||||
import com.cultural.heritage.model.dto.good.GoodAddRequest;
|
||||
import com.cultural.heritage.model.dto.good.GoodQueryRequest;
|
||||
import com.cultural.heritage.model.dto.good.GoodUpdateRequest;
|
||||
import com.cultural.heritage.model.dto.good.service.ServiceGoodAddRequest;
|
||||
import com.cultural.heritage.model.dto.good.service.ServiceGoodUpdateRequest;
|
||||
import com.cultural.heritage.model.entity.AppointmentDate;
|
||||
import com.cultural.heritage.model.entity.Good;
|
||||
import com.cultural.heritage.model.vo.good.ServiceGoodCardVO;
|
||||
import com.cultural.heritage.model.vo.good.ServiceGoodVO;
|
||||
import com.cultural.heritage.service.good.AppointmentDateService;
|
||||
import com.cultural.heritage.service.good.GoodService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -26,11 +30,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
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 org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -197,6 +200,7 @@ public class GoodController {
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除商品
|
||||
* @param commonDelBatchRequest 批量删除请求体
|
||||
|
@ -235,6 +239,157 @@ public class GoodController {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取服务类商品列表
|
||||
* @param goodQueryRequest 商品查询请求体
|
||||
* @return 服务类商品列表
|
||||
*/
|
||||
@PostMapping("/service/list/page")
|
||||
@Operation(summary = "Web端管理员分页查询服务类商品")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Page<ServiceGoodVO>> listServiceGoodVOByPage(@RequestBody GoodQueryRequest goodQueryRequest) {
|
||||
if (goodQueryRequest == null) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
long current = goodQueryRequest.getCurrent();
|
||||
long pageSize = goodQueryRequest.getPageSize();
|
||||
QueryWrapper<Good> goodQueryWrapper = goodService.getGoodQueryWrapper(goodQueryRequest);
|
||||
Page<Good> page = goodService.page(new Page<>(current, pageSize), goodQueryWrapper);
|
||||
List<Good> records = page.getRecords();
|
||||
List<ServiceGoodVO> serviceGoodVOList = records.stream().map(good -> {
|
||||
ServiceGoodVO serviceGoodVO = new ServiceGoodVO();
|
||||
BeanUtils.copyProperties(good, serviceGoodVO);
|
||||
Long id = good.getId();
|
||||
QueryWrapper<AppointmentDate> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("goodId", id);
|
||||
List<AppointmentDate> list = appointmentDateService.list(queryWrapper);
|
||||
serviceGoodVO.setAppointmentDateList(list);
|
||||
return serviceGoodVO;
|
||||
}).toList();
|
||||
Page<ServiceGoodVO> serviceGoodVOPage = new Page<>();
|
||||
serviceGoodVOPage.setRecords(serviceGoodVOList);
|
||||
serviceGoodVOPage.setCurrent(current);
|
||||
serviceGoodVOPage.setPages(pageSize);
|
||||
serviceGoodVOPage.setTotal(page.getTotal());
|
||||
return ResultUtils.success(serviceGoodVOPage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询服务类商品信息
|
||||
* @param commonRequest 根据id查询请求体
|
||||
* @return 服务类商品信息
|
||||
*/
|
||||
@PostMapping("/service/list/id")
|
||||
@Operation(summary = "小程序端用户根据id查询服务类商品")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<ServiceGoodVO> listServiceGoodVO(@RequestBody CommonRequest commonRequest) {
|
||||
if (commonRequest == null || commonRequest.getId() <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
Long id = commonRequest.getId();
|
||||
Good good = goodService.getById(id);
|
||||
ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR, "商品不存在");
|
||||
Integer isGoodType = good.getIsGoodType();
|
||||
if (isGoodType == 1) {
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "请求结果不是服务类商品");
|
||||
}
|
||||
ServiceGoodVO serviceGoodVO = new ServiceGoodVO();
|
||||
BeanUtils.copyProperties(good, serviceGoodVO);
|
||||
QueryWrapper<AppointmentDate> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("goodId", id);
|
||||
List<AppointmentDate> appointmentDateList = appointmentDateService.list(queryWrapper);
|
||||
serviceGoodVO.setAppointmentDateList(appointmentDateList);
|
||||
return ResultUtils.success(serviceGoodVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 展示服务类商品卡片
|
||||
* @return 服务类商品卡片列表
|
||||
*/
|
||||
@GetMapping("/service/list/card")
|
||||
@Operation(summary = "小程序端展示服务类商品卡片")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<List<ServiceGoodCardVO>> listServiceGoodCardVO() {
|
||||
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();
|
||||
return ResultUtils.success(serviceGoodCardVOS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新服务类商品
|
||||
* @param serviceGoodUpdateRequest 服务类商品更新请求体
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PostMapping("/service/update")
|
||||
@Operation(summary = "Web端管理员更新服务类商品")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> updateServiceGoodById(@RequestBody ServiceGoodUpdateRequest serviceGoodUpdateRequest) {
|
||||
if (serviceGoodUpdateRequest == null || serviceGoodUpdateRequest.getId() <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
// 更新商品的基本信息
|
||||
ServiceGoodVO serviceGoodVO = new ServiceGoodVO();
|
||||
BeanUtils.copyProperties(serviceGoodUpdateRequest, serviceGoodVO);
|
||||
boolean result = goodService.updateById(serviceGoodVO);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
|
||||
|
||||
// 获取当前商品原有的预约日期列表
|
||||
Long id = serviceGoodUpdateRequest.getId();
|
||||
QueryWrapper<AppointmentDate> dateQueryWrapper = new QueryWrapper<>();
|
||||
dateQueryWrapper.eq("goodId", id);
|
||||
List<AppointmentDate> appointmentDates = appointmentDateService.list(dateQueryWrapper);
|
||||
List<Long> dateIds = appointmentDates.stream().map(appointmentDate -> {
|
||||
Long dateId = appointmentDate.getId();
|
||||
return dateId;
|
||||
}).toList();
|
||||
|
||||
// 获取需要更新的预约日期列表
|
||||
List<AppointmentDateUpdateRequest> appointmentDateUpdateRequestList = serviceGoodUpdateRequest.getAppointmentDateUpdateRequestList();
|
||||
List<Long> updateDateIds = appointmentDateUpdateRequestList.stream().map(appointmentDateUpdateRequest -> {
|
||||
Long dateId = appointmentDateUpdateRequest.getId();
|
||||
return dateId;
|
||||
}).toList();
|
||||
|
||||
// 获取需要删除的预约日期id
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
dateIds.forEach(dateId -> {
|
||||
if (!updateDateIds.contains(dateId)) {
|
||||
deleteIds.add(dateId);
|
||||
}
|
||||
});
|
||||
|
||||
// 如果存在需要删除的预约日期id, 就删除
|
||||
if (!CollectionUtils.isEmpty(deleteIds)) {
|
||||
boolean isSuccessDelete = appointmentDateService.removeBatchByIds(deleteIds);
|
||||
ThrowUtils.throwIf(!isSuccessDelete, ErrorCode.OPERATION_ERROR);
|
||||
}
|
||||
|
||||
// 更新当前商品的预约日期
|
||||
List<AppointmentDate> appointmentDateList = appointmentDateUpdateRequestList.stream().map(appointmentDateUpdateRequest -> {
|
||||
AppointmentDate appointmentDate = new AppointmentDate();
|
||||
BeanUtils.copyProperties(appointmentDateUpdateRequest, appointmentDate);
|
||||
appointmentDate.setGoodId(id);
|
||||
return appointmentDate;
|
||||
}).toList();
|
||||
boolean isSuccess = appointmentDateService.updateBatchById(appointmentDateList);
|
||||
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -33,17 +33,10 @@ public class AppointmentDateAddRequest implements Serializable {
|
|||
|
||||
|
||||
/**
|
||||
* 最小预约人数
|
||||
* 预约人数范围
|
||||
*/
|
||||
@Schema(description = "最小预约人数", example = "5")
|
||||
private Integer minNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 最大预约人数
|
||||
*/
|
||||
@Schema(description = "最大预约人数", example = "10")
|
||||
private Integer maxNumber;
|
||||
@Schema(description = "预约人数范围", example = "(3,5);(4,6)")
|
||||
private String numberRange;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.cultural.heritage.model.dto.appointment;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AppointmentDateUpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 预约日期id
|
||||
*/
|
||||
@Schema(description = "预约日期id", example = "12")
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 预约具体日期
|
||||
*/
|
||||
@Schema(description = "预约具体日期", example = "2024-11-09")
|
||||
private String specificDate;
|
||||
|
||||
|
||||
/**
|
||||
* 预约时间段
|
||||
*/
|
||||
@Schema(description = "预约时间段", example = "9:00-11:00;12:00-14:00")
|
||||
private String timeSlot;
|
||||
|
||||
|
||||
/**
|
||||
* 是否可预约
|
||||
*/
|
||||
@Schema(description = "是否可预约", example = "1")
|
||||
private Integer isAvailable;
|
||||
|
||||
|
||||
/**
|
||||
* 预约人数范围
|
||||
*/
|
||||
@Schema(description = "预约人数范围", example = "(3,5);(4,6)")
|
||||
private String numberRange;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -17,7 +17,7 @@ public class ServiceGoodAddRequest extends GoodAddRequest implements Serializabl
|
|||
/**
|
||||
* 未来几天的预约详情
|
||||
*/
|
||||
@Schema(description = "未来n个月的预约详情")
|
||||
@Schema(description = "未来几天的预约详情")
|
||||
private List<AppointmentDateAddRequest> appointmentDateAddRequestList;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.cultural.heritage.model.dto.good.service;
|
||||
|
||||
import com.cultural.heritage.model.dto.appointment.AppointmentDateUpdateRequest;
|
||||
import com.cultural.heritage.model.dto.good.GoodUpdateRequest;
|
||||
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 = {"appointmentDateUpdateRequestList"})
|
||||
public class ServiceGoodUpdateRequest extends GoodUpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 未来几天的预约详情
|
||||
*/
|
||||
@Schema(description = "未来几天的预约详情")
|
||||
private List<AppointmentDateUpdateRequest> appointmentDateUpdateRequestList;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -41,16 +41,11 @@ public class AppointmentDate implements Serializable {
|
|||
*/
|
||||
private Integer isAvailable;
|
||||
|
||||
/**
|
||||
* 最小预约人数
|
||||
*/
|
||||
private Integer minNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 最大预约人数
|
||||
* 预约人数范围
|
||||
*/
|
||||
private Integer maxNumber;
|
||||
private String numberRange;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,11 @@ public class GoodVO implements Serializable {
|
|||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 是否是常规类商品
|
||||
*/
|
||||
private Integer isGoodType;
|
||||
|
||||
|
||||
|
||||
@Serial
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.cultural.heritage.model.vo.good;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ServiceGoodCardVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
private String goodImg;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.cultural.heritage.model.vo.good;
|
||||
|
||||
import com.cultural.heritage.model.entity.AppointmentDate;
|
||||
import com.cultural.heritage.model.entity.Good;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ServiceGoodVO extends Good implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 未来几天的预约详情
|
||||
*/
|
||||
@Schema(description = "未来几天的预约详情")
|
||||
private List<AppointmentDate> appointmentDateList;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -27,6 +27,10 @@ public class OrderVO implements Serializable {
|
|||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 订单类别
|
||||
*/
|
||||
private String orderType;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
|
|
Loading…
Reference in New Issue
Block a user