更新了服务类订单模块
This commit is contained in:
parent
dc1d3913c4
commit
b4dadea685
|
@ -19,6 +19,7 @@ import com.cultural.heritage.model.entity.AppointmentDate;
|
|||
import com.cultural.heritage.model.entity.Good;
|
||||
import com.cultural.heritage.model.entity.PendingServiceGood;
|
||||
import com.cultural.heritage.model.entity.TimePeriod;
|
||||
import com.cultural.heritage.service.common.CommonService;
|
||||
import com.cultural.heritage.service.good.AppointmentDateService;
|
||||
import com.cultural.heritage.service.good.GoodService;
|
||||
import com.cultural.heritage.service.good.TimePeriodService;
|
||||
|
@ -35,7 +36,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("/appointmentDate")
|
||||
|
@ -58,10 +61,17 @@ public class AppointmentDateController {
|
|||
private PendingServiceGoodService pendingServiceGoodService;
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private GoodService goodService;
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Web端管理员根据id删除预约日期
|
||||
* @param commonRequest 预约日期id
|
||||
|
@ -148,6 +158,12 @@ public class AppointmentDateController {
|
|||
updateWrapper.set("isAvailable", status);
|
||||
boolean update = appointmentDateService.update(updateWrapper);
|
||||
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "预约日期状态修改失败");
|
||||
|
||||
// 批量更新服务类商品待处理记录
|
||||
UpdateWrapper<PendingServiceGood> goodUpdateWrapper = new UpdateWrapper<>();
|
||||
goodUpdateWrapper.eq("appointmentDateId", id).set("isAvailable", status);
|
||||
boolean result = pendingServiceGoodService.update(goodUpdateWrapper);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录批量更新失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
@ -178,7 +194,7 @@ public class AppointmentDateController {
|
|||
boolean update = timePeriodService.updateById(timePeriod);
|
||||
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "预约时间段人数修改失败");
|
||||
|
||||
// 删除服务类商品待处理记录
|
||||
// 更新服务类商品待处理记录
|
||||
UpdateWrapper<PendingServiceGood> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("timePeriodId", id);
|
||||
updateWrapper.set("minNumber", timePeriodSingleUpdateRequest.getMinNumber());
|
||||
|
@ -225,6 +241,7 @@ public class AppointmentDateController {
|
|||
pendingServiceGood.setPrice(good.getPrice());
|
||||
pendingServiceGood.setTimePeriodId(timePeriod.getId());
|
||||
pendingServiceGood.setReservationDate(appointmentDate.getSpecificDate());
|
||||
pendingServiceGood.setIsAvailable(appointmentDate.getIsAvailable());
|
||||
|
||||
boolean result = pendingServiceGoodService.save(pendingServiceGood);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录添加失败");
|
||||
|
@ -270,6 +287,15 @@ public class AppointmentDateController {
|
|||
Good good = goodService.getById(goodId);
|
||||
ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "当前商品不存在");
|
||||
|
||||
// 获取预约日期列表
|
||||
List<AppointmentDate> appointmentDateList = commonService.getItemsByIds(timePeriodList, appointmentDateService, TimePeriod::getAppointmentDateId);
|
||||
|
||||
// 封装map集合(键:预约日期id, 值:是否可预约)
|
||||
Map<Long, Integer> map = new HashMap<>();
|
||||
for (AppointmentDate appDate : appointmentDateList) {
|
||||
map.put(appDate.getId(), appDate.getIsAvailable());
|
||||
}
|
||||
|
||||
List<PendingServiceGood> pendingServiceGoodList = new ArrayList<>();
|
||||
for (TimePeriod timePeriod : timePeriodList) {
|
||||
PendingServiceGood pendingServiceGood = new PendingServiceGood();
|
||||
|
@ -278,6 +304,7 @@ public class AppointmentDateController {
|
|||
pendingServiceGood.setPrice(good.getPrice());
|
||||
pendingServiceGood.setAppointmentDateId(appointmentDate.getId());
|
||||
pendingServiceGood.setReservationDate(appointmentDate.getSpecificDate());
|
||||
pendingServiceGood.setIsAvailable(map.get(appointmentDate.getId()));
|
||||
|
||||
pendingServiceGood.setTimePeriodId(timePeriod.getId());
|
||||
pendingServiceGood.setTimeSlot(timePeriod.getTimeSlot());
|
||||
|
|
Loading…
Reference in New Issue
Block a user