shinnosuke
2026-08-18 99bfc2060840436d5ed06e5f37a2ce6ae0ab44e8
talent-card-server/src/main/java/com/talentcard/server/business/admin/AdminBusinessService.java
@@ -652,6 +652,7 @@
   @Transactional
   public Map<String, Object> createProduct(ProductCreateRequest request) {
      ensureMerchantExists(request.merchantId());
      validateProductConfiguration(request.merchantId(), request.salePrice(), request.productImages());
      validateProductRights(request.merchantId(), request.rightsConfig());
      String productNo = BusinessIdGenerator.next("P");
      BigDecimal subsidyAmount = valueOrZero(request.subsidyAmount());
@@ -686,6 +687,7 @@
   @Transactional
   public Map<String, Object> updateProduct(Long id, ProductUpdateRequest request) {
      ensureMerchantExists(request.merchantId());
      validateProductConfiguration(request.merchantId(), request.salePrice(), request.productImages());
      validateProductRights(request.merchantId(), request.rightsConfig());
      BigDecimal subsidyAmount = valueOrZero(request.subsidyAmount());
      int updated = jdbcTemplate.update("""
@@ -1057,7 +1059,7 @@
      if (rightsConfig == null) {
         return;
      }
      if (isHotelMerchant(merchantId)) {
      if (isHotelMerchant(merchantId) || isHealthCheckMerchant(merchantId)) {
         return;
      }
      for (Map<String, Object> right : rightsConfig) {
@@ -1076,16 +1078,37 @@
      }
   }
   private void validateProductConfiguration(Long merchantId, BigDecimal salePrice, List<String> productImages) {
      if (isHealthCheckMerchant(merchantId)) {
         return;
      }
      if (salePrice == null) {
         throw new BusinessException(ErrorCode.BAD_REQUEST, "商品金额不能为空");
      }
      if (productImages == null || productImages.isEmpty()) {
         throw new BusinessException(ErrorCode.BAD_REQUEST, "请至少添加一张商品图片");
      }
   }
   private boolean isHotelMerchant(Long merchantId) {
      String type = merchantType(merchantId);
      return "hotel".equalsIgnoreCase(type) || "酒店服务".equals(type);
   }
   private boolean isHealthCheckMerchant(Long merchantId) {
      String type = merchantType(merchantId);
      return "healthCheck".equalsIgnoreCase(type) || "免费体检".equals(type);
   }
   private String merchantType(Long merchantId) {
      List<String> types = jdbcTemplate.queryForList(
            "select merchant_type from merchant where deleted = 0 and id = ? limit 1",
            String.class,
            merchantId);
      if (types.isEmpty()) {
         return false;
         return "";
      }
      String type = types.get(0) == null ? "" : types.get(0).trim();
      return "hotel".equalsIgnoreCase(type) || "酒店服务".equals(type);
      return types.get(0) == null ? "" : types.get(0).trim();
   }
   private void validateCouponConfiguration(String validStart, String validEnd, String productScope, List<Long> productIds) {