From c920c574d9587ef798d0c7f82d574e3e30bfde3a Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期三, 19 八月 2026 11:07:41 +0800
Subject: [PATCH] 又又更新
---
talent-card-server/src/main/java/com/talentcard/server/business/admin/AdminBusinessService.java | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/admin/AdminBusinessService.java b/talent-card-server/src/main/java/com/talentcard/server/business/admin/AdminBusinessService.java
index 1b131e1..1b03fab 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/admin/AdminBusinessService.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/admin/AdminBusinessService.java
@@ -429,11 +429,6 @@
if (!Set.of("景区服务", "餐饮服务").contains(request.merchantType())) {
return;
}
- if (request.businessHours() == null || request.businessHours().isEmpty()
- || request.businessHours().stream().anyMatch(item -> item.startTime() == null || item.endTime() == null
- || item.startTime().isBlank() || item.endTime().isBlank() || item.startTime().equals(item.endTime()))) {
- throw new BusinessException(ErrorCode.BAD_REQUEST, "请选择有效的营业时间");
- }
if (request.loginAccount() == null || !request.loginAccount().trim().matches("^[A-Za-z0-9]{1,32}$")) {
throw new BusinessException(ErrorCode.BAD_REQUEST, "商户登录账号只能包含英文字母和数字");
}
@@ -463,13 +458,13 @@
private void syncMerchantBusinessHours(Long merchantId, Long storeId, List<MerchantBusinessHourRequest> businessHours) {
if (businessHours == null) return;
+ jdbcTemplate.update("delete from merchant_business_hours where merchant_id = ? and store_id = ?", merchantId, storeId);
if (businessHours.isEmpty()) {
- throw new BusinessException(ErrorCode.BAD_REQUEST, "请至少配置一个营业时间段");
+ return;
}
if (businessHours.stream().anyMatch(item -> item.startTime().equals(item.endTime()))) {
throw new BusinessException(ErrorCode.BAD_REQUEST, "营业开始时间和结束时间不能相同");
}
- jdbcTemplate.update("delete from merchant_business_hours where merchant_id = ? and store_id = ?", merchantId, storeId);
for (int index = 0; index < businessHours.size(); index++) {
MerchantBusinessHourRequest item = businessHours.get(index);
jdbcTemplate.update("""
@@ -981,15 +976,19 @@
where s.status = 1 and s.deleted = 0 and h.merchant_id in (""" + placeholders + ")", merchantIds.toArray()));
LocalTime now = LocalTime.now(ZoneId.of("Asia/Shanghai"));
Set<Long> openMerchantIds = new HashSet<>();
+ Set<Long> merchantsWithBusinessHours = new HashSet<>();
for (Map<String, Object> period : periods) {
+ Long merchantId = Long.valueOf(String.valueOf(period.get("merchantId")));
+ merchantsWithBusinessHours.add(merchantId);
if (isWithinBusinessPeriod(now, String.valueOf(period.get("startTime")), String.valueOf(period.get("endTime")))) {
- openMerchantIds.add(Long.valueOf(String.valueOf(period.get("merchantId"))));
+ openMerchantIds.add(merchantId);
}
}
for (Map<String, Object> merchant : merchants) {
Long merchantId = Long.valueOf(String.valueOf(merchant.get("id")));
boolean enabled = "1".equals(String.valueOf(merchant.get("status")));
- merchant.put("businessStatus", enabled && openMerchantIds.contains(merchantId) ? "营业中" : "休息中");
+ boolean open = !merchantsWithBusinessHours.contains(merchantId) || openMerchantIds.contains(merchantId);
+ merchant.put("businessStatus", enabled && open ? "营业中" : "休息中");
}
}
--
Gitblit v1.7.1