fix: 允许编辑进行中的拼团/秒杀活动及修复成团检测

- 移除拼团活动"进行中不能修改"限制
- 编辑拼团/秒杀时不再限制开始时间必须晚于当前
- 编辑时日期选择器不禁用过去日期
- 修复JPA缓存导致成团检测失效的问题(clearAutomatically)
This commit is contained in:
2026-03-17 00:19:50 +08:00
parent 28f41754d0
commit 665603704b
4 changed files with 12 additions and 12 deletions

View File

@@ -275,10 +275,12 @@ const getStockRate = (item: FlashSale) => {
return Math.round((item.remainingStock / item.flashStock) * 100) return Math.round((item.remainingStock / item.flashStock) * 100)
} }
const disablePastDate = (date: Date) => dayjs(date).endOf('day').isBefore(dayjs()) const disablePastDate = (date: Date) => {
if (formMode.value === 'edit') return false
return dayjs(date).endOf('day').isBefore(dayjs())
}
const validateTimeRange = () => { const validateTimeRange = () => {
const now = dayjs()
const startTime = dayjs(form.startTime) const startTime = dayjs(form.startTime)
const endTime = dayjs(form.endTime) const endTime = dayjs(form.endTime)
@@ -287,7 +289,7 @@ const validateTimeRange = () => {
return false return false
} }
if (!startTime.isAfter(now)) { if (formMode.value === 'create' && !startTime.isAfter(dayjs())) {
ElMessage.error('开始时间必须晚于当前时间') ElMessage.error('开始时间必须晚于当前时间')
return false return false
} }

View File

@@ -235,10 +235,12 @@ const getStatusType = (status: string) => {
} }
} }
const disablePastDate = (date: Date) => dayjs(date).endOf('day').isBefore(dayjs()) const disablePastDate = (date: Date) => {
if (editingId.value) return false
return dayjs(date).endOf('day').isBefore(dayjs())
}
const validateTimeRange = () => { const validateTimeRange = () => {
const now = dayjs()
const startTime = dayjs(form.startTime) const startTime = dayjs(form.startTime)
const endTime = dayjs(form.endTime) const endTime = dayjs(form.endTime)
@@ -247,7 +249,7 @@ const validateTimeRange = () => {
return false return false
} }
if (!startTime.isAfter(now)) { if (!editingId.value && !startTime.isAfter(dayjs())) {
ElMessage.error('开始时间必须晚于当前时间') ElMessage.error('开始时间必须晚于当前时间')
return false return false
} }

View File

@@ -33,11 +33,11 @@ public interface GroupBuyingGroupRepository extends JpaRepository<GroupBuyingGro
long countByGroupBuyingIdAndStatus(Long groupBuyingId, Integer status); long countByGroupBuyingIdAndStatus(Long groupBuyingId, Integer status);
@Modifying @Modifying(clearAutomatically = true)
@Query("UPDATE GroupBuyingGroup g SET g.currentMembers = g.currentMembers + 1 WHERE g.id = :id") @Query("UPDATE GroupBuyingGroup g SET g.currentMembers = g.currentMembers + 1 WHERE g.id = :id")
int incrementCurrentMembers(@Param("id") Long id); int incrementCurrentMembers(@Param("id") Long id);
@Modifying @Modifying(clearAutomatically = true)
@Query("UPDATE GroupBuyingGroup g SET g.currentMembers = g.currentMembers - 1 WHERE g.id = :id AND g.currentMembers > 0") @Query("UPDATE GroupBuyingGroup g SET g.currentMembers = g.currentMembers - 1 WHERE g.id = :id AND g.currentMembers > 0")
int decrementCurrentMembers(@Param("id") Long id); int decrementCurrentMembers(@Param("id") Long id);

View File

@@ -109,10 +109,6 @@ public class GroupBuyingService {
GroupBuying gb = groupBuyingRepository.findById(id) GroupBuying gb = groupBuyingRepository.findById(id)
.orElseThrow(() -> new RuntimeException("拼团活动不存在")); .orElseThrow(() -> new RuntimeException("拼团活动不存在"));
if (gb.getStatus() == 2) {
throw new RuntimeException("进行中的活动不能修改");
}
if (updateDTO.getProductId() != null) gb.setProductId(updateDTO.getProductId()); if (updateDTO.getProductId() != null) gb.setProductId(updateDTO.getProductId());
if (updateDTO.getGroupPrice() != null) gb.setGroupPrice(updateDTO.getGroupPrice()); if (updateDTO.getGroupPrice() != null) gb.setGroupPrice(updateDTO.getGroupPrice());
if (updateDTO.getRequiredMembers() != null) gb.setRequiredMembers(updateDTO.getRequiredMembers()); if (updateDTO.getRequiredMembers() != null) gb.setRequiredMembers(updateDTO.getRequiredMembers());