Преглед на файлове

Merge remote-tracking branch 'origin/ScrmStores' into ScrmStores

yjwang преди 6 дни
родител
ревизия
e5701c4f41

+ 5 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductAttrValueScrmMapper.java

@@ -85,7 +85,7 @@ public interface FsStoreProductAttrValueScrmMapper
     int incProductAttrStock(@Param("num")Long num,@Param("productId") Long productId,@Param("productAttrValueId") Long productAttrValueId);
     @Select({"<script> " +
             "select v.*,p.product_name,p.product_type,c.cate_name  from fs_store_product_attr_value_scrm v inner join fs_store_product_scrm p on p.product_id=v.product_id left join fs_store_product_category_scrm c on c.cate_id=p.cate_id   " +
-            "where 1=1 and v.bar_code is not null " +
+            "where 1=1 and v.bar_code is not null and  p.is_show=1" +
             "<if test = 'maps.productName != null and  maps.productName !=\"\"    '> " +
             "and p.product_name like CONCAT('%',#{maps.productName},'%') " +
             "</if>" +
@@ -104,6 +104,10 @@ public interface FsStoreProductAttrValueScrmMapper
             "and find_in_set(#{maps.companyId},p.company_ids)  " +
             "</if>" +
 
+            "<if test = 'maps.storeId != null    '> " +
+            "and p.store_id = #{maps.storeId}  " +
+            "</if>" +
+
             " order by v.id desc "+
             "</script>"})
     List<FsStoreProductAttrValueVO> selectFsStoreProductAttrValueListVO(@Param("maps")FsProductAttrValueParam param);

+ 34 - 4
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreScrmMapper.java

@@ -137,12 +137,42 @@ public interface FsStoreScrmMapper
     List<FsStoreScrm> getStoreInfoByproductId(@Param("productIds") Set<Long> productIds);
 
 
-    @Select("SELECT COUNT(DISTINCT merchant_id) FROM fs_store_scrm WHERE merchant_id LIKE CONCAT(#{datePrefix}, '%')")
-    Long countMerchantsByDatePrefix(@Param("datePrefix") String datePrefix );
 
     /**
      * 查询当天已生成的店铺数量
      */
-    @Select("SELECT COUNT(*) FROM fs_store_scrm WHERE merchant_id = #{merchantId} AND store_seq LIKE CONCAT(#{date}, '%')")
-    Long countByStoreSeqPrefix(@Param("merchantId") String merchantId,@Param("date") String date);
+    @Select("SELECT COUNT(*) FROM fs_store_scrm WHERE store_seq LIKE CONCAT(#{date}, '%')")
+    Long countByStoreSeqPrefix(@Param("date") String date);
+
+    /**
+     * 检查营业执照是否已存在
+     */
+    @Select(" SELECT COUNT(*) > 0 FROM fs_store_scrm WHERE business_code = #{businessCode}")
+    boolean existsByBusinessCode(@Param("businessCode") String businessCode);
+
+    /**
+     * 根据营业执照编码查找商家ID
+     */
+    @Select("SELECT merchant_id FROM fs_store_scrm \n" +
+            "    WHERE business_code = #{businessCode} \n" +
+            "    LIMIT 1")
+    String findMerchantIdByBusinessCode(@Param("businessCode") String businessCode);
+
+    /**
+     * 检查同一商家下店铺名称是否重复
+     */
+    @Select(" SELECT COUNT(*) > 0 FROM fs_store_scrm \n" +
+            "    WHERE merchant_id = #{merchantId} AND store_name = #{storeName}")
+    boolean existsStoreNameInMerchant(@Param("merchantId") String merchantId,
+                                      @Param("storeName") String storeName);
+
+    /**
+     * 查询当天新商家的数量(基于营业执照)
+     */
+    Long countNewMerchantsByDate(@Param("datePrefix") String datePrefix);
+
+    /**
+     * 查询商家下的店铺数量
+     */
+    Integer countStoresByMerchant(@Param("merchantId") String merchantId);
 }

+ 1 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsProductAttrValueParam.java

@@ -13,4 +13,5 @@ public class FsProductAttrValueParam implements Serializable
     private Integer isShow;
     Integer tuiCateId;
     private Long companyId;
+    private Long storeId;
 }

+ 62 - 26
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreScrmServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.hisStore.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.ServiceException;
+import com.fs.common.exception.base.BaseException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.his.param.FsStoreAuditParam;
@@ -102,10 +103,23 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
         StoreMD5PasswordEncoder storeMD5PasswordEncoder = new StoreMD5PasswordEncoder();
         fsStore.setPassword(storeMD5PasswordEncoder.encode("XyzAbc~12"));
         fsStore.setCreateTime(DateUtils.getNowDate());
+        if (fsStore.getBusinessCode() != null && !fsStore.getBusinessCode().trim().isEmpty()) {
+            boolean exists = fsStoreMapper.existsByBusinessCode(fsStore.getBusinessCode());
+            if (exists) {
+                // 检查是否是同一个商家
+                String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(fsStore.getBusinessCode());
+                if (existingMerchantId != null) {
+                    // 同一商家下检查店铺名称是否重复
+                    if (fsStoreMapper.existsStoreNameInMerchant(existingMerchantId, fsStore.getStoreName())) {
+                        throw new BaseException("该商家下已存在同名店铺");
+                    }
+                }
+            }
+        }
         //生成商家id
-        String merchantId = generateMerchantId();
+        String merchantId = generateMerchantId(fsStore.getBusinessCode());
         //生成店铺id
-        String sequence = generateStoreSequence(merchantId);
+        String sequence = generateStoreSequence(merchantId,fsStore.getBusinessCode());
         fsStore.setMerchantId(merchantId);
         fsStore.setStoreSeq(sequence);
         fsStoreMapper.insertFsStore(fsStore);
@@ -116,36 +130,57 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
      * 生成商家ID:YJB202510180001
      * 格式:前缀 + 年月日 + 4位序列号
      */
-    public String generateMerchantId() {
-        // 获取当天日期
-        String datePart = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+    @Transactional
+    public String generateMerchantId(String businessCode) {
+        // 如果营业执照已存在,返回已有的商家ID
+        if (businessCode != null && !businessCode.trim().isEmpty()) {
+            String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(businessCode);
+            if (existingMerchantId != null) {
+                return existingMerchantId;
+            }
+        }
 
-        // 查询当天已生成的商家数量
-        Long todayCount = fsStoreMapper.countMerchantsByDatePrefix(MERCHANT_PREFIX + datePart);
+        // 新营业执照,生成新的商家ID
+        String datePart = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+        String prefix = MERCHANT_PREFIX + datePart;
 
-        // 生成序号 (从0001开始)
-        Long sequence = (todayCount == null) ? 1L : todayCount + 1;
-        String sequencePart = String.format("%04d", sequence);
+        // 查询当天已生成的新商家数量(基于营业执照)
+        Long todayNewMerchantCount = fsStoreMapper.countNewMerchantsByDate(prefix);
+        Long sequence = (todayNewMerchantCount == null) ? 1L : todayNewMerchantCount + 1;
 
-        return MERCHANT_PREFIX + datePart + sequencePart;
+        return prefix + String.format("%04d", sequence);
     }
 
+
+
     /**
      * 生成店铺序号:年月日 + 当天第几家店
      * 格式:202510180001
      */
-    public String generateStoreSequence(String merchantId) {
-        // 获取当天日期
+    @Transactional
+    public String generateStoreSequence(String merchantId, String businessCode) {
         String datePart = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
 
-        // 查询当天已生成的店铺数量
-        Long todayCount = fsStoreMapper.countByStoreSeqPrefix(merchantId, datePart);
-
-        // 生成序号 (从1开始)
-        Long sequence = (todayCount == null) ? 1L : todayCount + 1;
-        String sequencePart = String.format("%04d", sequence);
+        // 检查是否是新商家(根据营业执照是否已存在)
+        boolean isNewMerchant = false;
+        if (businessCode != null && !businessCode.trim().isEmpty()) {
+            String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(businessCode);
+            isNewMerchant = (existingMerchantId == null);
+        } else {
+            // 如果没有营业执照,检查商家ID是否已存在
+            Integer existingStoreCount = fsStoreMapper.countStoresByMerchant(merchantId);
+            isNewMerchant = (existingStoreCount == null || existingStoreCount == 0);
+        }
 
-        return datePart + sequencePart;
+        if (isNewMerchant) {
+            // 新商家,店铺序列从1开始
+            return datePart + "0001";
+        } else {
+            // 现有商家,获取当前商家的店铺数量+1
+            Integer storeCount = fsStoreMapper.countStoresByMerchant(merchantId);
+            Long sequence = (storeCount == null) ? 1L : storeCount + 1L;
+            return datePart + String.format("%04d", sequence);
+        }
     }
 
     /**
@@ -185,13 +220,14 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
 
         //验证资质日期是否正常
         LocalDate today = LocalDate.now(ZoneId.of("Asia/Shanghai"));
-        if (fsStore.getBusinessLicenseExpireEnd().isBefore(today) || fsStore.getDrugLicenseExpiryEnd().isBefore(today)
-                || fsStore.getMedicalDevice2ExpiryEnd().isBefore(today) || fsStore.getMedicalLicenseExpiryEnd().isBefore(today) || fsStore.getStatus() == 0) {
-            fsStore.setStatus(0);
-        } else {
-            fsStore.setStatus(1);
+        if (Objects.equals(String.valueOf(fsStore.getIsBusinessLicensePermanent()), "0")) {
+            if (fsStore.getBusinessLicenseExpireEnd().isBefore(today) || fsStore.getDrugLicenseExpiryEnd().isBefore(today)
+                    || fsStore.getMedicalDevice2ExpiryEnd().isBefore(today) || fsStore.getMedicalLicenseExpiryEnd().isBefore(today) || fsStore.getStatus() == 0) {
+                fsStore.setStatus(0);
+            } else {
+                fsStore.setStatus(1);
+            }
         }
-
         return fsStoreMapper.updateFsStore(fsStore);
     }
 

+ 1 - 1
fs-service/src/main/java/com/fs/hospital580/util/ThumbnailatorWatermark.java

@@ -47,7 +47,7 @@ public class ThumbnailatorWatermark {
             String watermarkImageUrl = "";
             switch (orderStatus) {
                 // 代付款
-                case 1:
+                case 0:
                     watermarkImageUrl = jsonObject.getStr("start");
                     break;
                 // 退款

+ 10 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreScrmMapper.xml

@@ -494,4 +494,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </foreach>
         GROUP BY ss.store_id
     </select>
+    <select id="countNewMerchantsByDate" resultType="java.lang.Long">
+        SELECT COUNT(DISTINCT business_code) FROM fs_store_scrm
+        WHERE merchant_id LIKE CONCAT(#{datePrefix}, '%')
+          AND business_code IS NOT NULL
+          AND business_code != ''
+    </select>
+    <select id="countStoresByMerchant" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM fs_store_scrm
+        WHERE merchant_id = #{merchantId}
+    </select>
 </mapper>