Quellcode durchsuchen

新增商品后点击编辑商品规格回显错误,商品通过审核后会进入商品总库草稿状态保存

Guos vor 3 Wochen
Ursprung
Commit
59e2155e42

+ 5 - 1
fs-service/src/main/java/com/fs/hisStore/domain/FsPlatformProductScrm.java

@@ -26,7 +26,6 @@ public class FsPlatformProductScrm extends BaseEntity {
     /**
      * 商品id
      */
-    @TableId(value = "product_id", type = IdType.ID_WORKER)
     private Long productId;
 
     /**
@@ -576,4 +575,9 @@ public class FsPlatformProductScrm extends BaseEntity {
      * **/
     private String medicalDeviceCode;
 
+    /**
+     * 来自店铺的商品-商品id
+     * **/
+    private Long storeProductId;
+
 }

+ 61 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsPlatFormProductAddEditParam.java

@@ -6,6 +6,7 @@ import com.fs.hisStore.dto.ProductArrtDTO;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -259,8 +260,10 @@ public class FsPlatFormProductAddEditParam {
 
     //属性项目
     private List<ProductArrtDTO> items;
+
     //sku结果集
     private List<FsStoreProductAttrValueScrm> values;
+
     // 指定企业
     private String companyIds;
 
@@ -374,4 +377,62 @@ public class FsPlatFormProductAddEditParam {
      * **/
     private String medicalDeviceCode;
 
+    /**
+     * 来自店铺的商品-商品id
+     * **/
+    private Long storeProductId;
+
+//    //不一致的错误信息
+//    /**
+//     * 生产许可证件有效期开始
+//     **/
+//    private LocalDate licenseStart;
+//
+//    /**
+//     * 生产许可证件有效期结束
+//     **/
+//    private LocalDate licenseEnd;
+//
+//    /**
+//     * 注册证书有效期开始
+//     **/
+//    private LocalDate certificateStart;
+//
+//    /**
+//     * 注册证书有效期结束
+//     **/
+//    private LocalDate certificateEnd;
+//
+//    /**
+//     * 营业执照有效期开始
+//     **/
+//    private LocalDate businessStart;
+//
+//    /**
+//     * 营业执照有效期结束
+//     **/
+//    private LocalDate businessEnd;
+//
+//    /**
+//     * 备案证书有效期开始
+//     **/
+//    private LocalDate voucherStart;
+//
+//    /**
+//     * 备案证书有效期结束
+//     **/
+//    private LocalDate voucherEnd;
+//
+//    /**
+//     * GMP认证有效期开始
+//     **/
+//    private LocalDate gmpAuthStart;
+//
+//    /**
+//     * GMP认证有效期结束
+//     **/
+//    private LocalDate gmpAuthEnd;
+
+
+
 }

+ 4 - 6
fs-service/src/main/java/com/fs/hisStore/service/impl/FsPlatformProductScrmServiceImpl.java

@@ -30,6 +30,7 @@ import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.function.Consumer;
+import com.fs.hisStore.util.FsProductUtils;
 
 /**
  * @description:
@@ -148,7 +149,7 @@ public class FsPlatformProductScrmServiceImpl implements IFsPlatformProductScrmS
         copyProductInfo.setIsShow(1);
 
         //插入复制商品
-        copyProductInfo.setProductId(createId());
+        copyProductInfo.setProductId(FsProductUtils.createId());
         if(fsPlatformProductScrmMapper.insertFsPlatformProduct(copyProductInfo) < 1){
             return R.error("操作失败,复制信息异常!");
         }
@@ -199,7 +200,6 @@ public class FsPlatformProductScrmServiceImpl implements IFsPlatformProductScrmS
         product.setBusinessLink(param.getBusinessLink());
         product.setCreateTime(new Date());
 
-
         //这里是更新
         if(param.getProductId() != null && param.getProductId() > 0){
             FsPlatformProductScrm oldFsStoreProduct = fsPlatformProductScrmMapper.selectFsPlatformProductById(product.getProductId());
@@ -237,7 +237,7 @@ public class FsPlatformProductScrmServiceImpl implements IFsPlatformProductScrmS
                 product.setIsAudit("1");
             }
             //复制新的id
-            product.setProductId(createId());
+            product.setProductId(FsProductUtils.createId());
             fsPlatformProductScrmMapper.insertFsPlatformProduct(product);
         }
         storeAuditLogUtil.addOperLog(product.getProductId());
@@ -441,9 +441,7 @@ public class FsPlatformProductScrmServiceImpl implements IFsPlatformProductScrmS
         return diff;
     }
 
-    private static Long createId(){
-        return IdWorker.getId()  % 100000000L;  // 返回后8位(又重复风险);
-    }
+
 
 
 }

+ 37 - 13
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -39,6 +39,7 @@ import com.fs.hisStore.domain.*;
 import com.fs.hisStore.dto.ForbiddenDrugItemDTO;
 import com.fs.hisStore.dto.FsStoreProductScrmInfoDTO;
 import com.fs.hisStore.mapper.*;
+import com.fs.hisStore.param.FsPlatFormProductAddEditParam;
 import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.hisStore.service.IFsPlatformProductScrmService;
 import com.fs.hisStore.service.IFsStoreProductCategoryScrmService;
@@ -46,6 +47,7 @@ import com.fs.hisStore.service.categoryVal.AbstractHandler;
 import com.fs.hisStore.service.categoryVal.ProductCategoryCheckFactory;
 import com.fs.hisStore.util.DrugComponentAnalyzer;
 import com.fs.hisStore.util.ForbiddenDrugListManager;
+import com.fs.hisStore.util.FsProductUtils;
 import com.fs.hisStore.utils.StoreAuditLogUtil;
 import com.fs.hisStore.util.BusinessScopeProductTypeUtil;
 import com.fs.statis.dto.ModifyMoreDTO;
@@ -132,7 +134,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
 
     @Lazy
     @Autowired
-    private IFsPlatformProductScrmService ifsPlatformProductService;
+    private IFsPlatformProductScrmMapper iFsPlatformProductScrmMapper;
 
 
     private ForbiddenDrugListManager forbiddenListManager = new ForbiddenDrugListManager();
@@ -399,7 +401,6 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
 //            if(StringUtils.isNotEmpty(item.getStoreId()))
 //                item.setStoreName(fsStoreScrmService.selectFsStoreByStoreId(Long.parseLong(item.getStoreId())).getStoreName());
         }
-
         return fsStoreProductListVOS;
     }
 
@@ -601,7 +602,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             fsStoreProductMapper.insertFsStoreProduct(product);
         }
         storeAuditLogUtil.addOperLog(product.getProductId());
-        //处理规格
+        //处理规格
         handleProductAttributes(param, product, storeId);
         return R.ok();
     }
@@ -614,7 +615,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     .build();
             List<ProductArrtDTO> items=new ArrayList<>();
             items.add(fromatDetailDto);
-            param.getValues().get(0).setSku("每"+param.getUnitName());
+            param.getValues().get(0).setSku(param.getUnitName());
             addProductAttr(product.getProductId(),items, param.getValues(), storeId);
         } else {
             addProductAttr(product.getProductId(), param.getItems(), param.getValues(), storeId);
@@ -628,7 +629,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
      * @param values 属性值
      * @param storeId 店铺id
      */
-    private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsStoreProductAttrValueScrm> values,Long storeId){
+private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsStoreProductAttrValueScrm> values,Long storeId){
         //清空attr
         fsStoreProductAttrMapper.clear(productId);
         //清空values
@@ -1318,14 +1319,37 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         // 正常情况是退回后可以申请重新上架的如果不通过2,那么show就变回0(直接在sql中去做的),按照原有逻辑去做
         fsStoreProductMapper.batchAudit(auditDTO);
         storeAuditLogUtil.addBatchAuditList(auditDTO.getProductIds(),auditDTO.getReason(),auditDTO.getAttachImage());
-        //TODO 平台商品库
-//        if(auditDTO.getIsAudit() == 1){
-//            //复制一份到平台商品库
-//            for(Long productId : auditDTO.getProductIds()){
-//                fsStoreProductMapper.selectFsStoreProductById(auditDTO.getProductIds());
-//                ifsPlatformProductService.addOrEdit(auditDTO);
-//            }
-//        }
+        //审核通过进入、平台商品库
+        if(auditDTO.getIsAudit() == 1){
+            //复制一份到平台商品库
+            for(Long storeProductId : auditDTO.getProductIds()){
+                //复制商品
+                FsStoreProductScrm fsStoreProductScrm = fsStoreProductMapper.selectFsStoreProductById(storeProductId);
+                FsPlatformProductScrm fsPlatformProductScrm = new FsPlatformProductScrm();
+                BeanUtils.copyProperties(fsStoreProductScrm, fsPlatformProductScrm); //copy
+//                Long storeProductId = fsPlatformProductScrm.getProductId();//店铺商品id
+                Long id = FsProductUtils.createId();//平台总库商品id
+                fsPlatformProductScrm.setStoreProductId(storeProductId);
+                fsPlatformProductScrm.setProductId(id);
+                fsPlatformProductScrm.setIsShow(9);//对比字典store_product_is_show,草稿
+                fsPlatformProductScrm.setStoreId(null);
+                iFsPlatformProductScrmMapper.insertFsPlatformProduct(fsPlatformProductScrm);
+                //复制规格
+                List<FsStoreProductAttrScrm> fsStoreProductAttrScrms = fsStoreProductAttrMapper.selectFsStoreProductAttrByProductId(storeProductId);
+                for (FsStoreProductAttrScrm fsStoreProductAttrScrm : fsStoreProductAttrScrms){
+                    fsStoreProductAttrScrm.setId(null);
+                    fsStoreProductAttrScrm.setProductId(id);
+                    fsStoreProductAttrMapper.insertFsStoreProductAttr(fsStoreProductAttrScrm);
+                }
+                List<FsStoreProductAttrValueScrm> fsStoreProductAttrValueScrms = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(storeProductId);
+                for (FsStoreProductAttrValueScrm fsStoreProductAttrValueScrm : fsStoreProductAttrValueScrms){
+                    fsStoreProductAttrValueScrm.setId(null);
+                    fsStoreProductAttrValueScrm.setProductId(id);
+                    fsStoreProductAttrValueScrm.setStoreId(null);
+                    fsStoreProductAttrValueMapper.insertFsStoreProductAttrValue(fsStoreProductAttrValueScrm);
+                }
+            }
+        }
     }
 
     @Override

+ 16 - 0
fs-service/src/main/java/com/fs/hisStore/util/FsProductUtils.java

@@ -0,0 +1,16 @@
+package com.fs.hisStore.util;
+
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+
+/**
+ * @description:
+ * @author: Guos
+ * @time: 2025/12/18 下午3:22
+ */
+public class FsProductUtils {
+
+    public static Long createId(){
+        return IdWorker.getId()  % 100000000L;  // 返回后8位(又重复风险);
+    }
+
+}

+ 6 - 18
fs-service/src/main/resources/mapper/hisStore/FsPlatformProductScrmMapper.xml

@@ -126,12 +126,7 @@
     <select id="selectList" resultType="com.fs.hisStore.vo.FsPlatformProductListVO">
         SELECT
         <include refid="baseSql"/>,
-        case
-        when p.is_show = 1 and p.is_audit = 1 then 1
-        when p.is_show = 0 and p.is_audit = 0 then 0
-        when p.is_show = 1 and p.is_audit = 0 then 3
-        when p.is_show = 0 and p.is_audit = 2 then 4
-        end AS is_show,
+        p.is_show,
         pc.cate_name
         FROM
         fs_platform_product_scrm p
@@ -140,22 +135,15 @@
         WHERE 1=1
         and p.is_del = 0 and p.is_drug = 1
         <if test="maps.isAudit == null and maps.isShow != null">
+            <if test="maps.isShow == -1">
+            </if>
             <if test="maps.isShow == 1">
-                AND p.is_audit = 1
                 AND p.is_show = 1
             </if>
-            <if test="maps.isShow == 0">
-                AND p.is_audit != 1
+            <if test="maps.isShow == 9">
                 AND p.is_show = #{maps.isShow}
             </if>
-            <if test="maps.isShow == -1">
-            </if>
-            <if test="maps.isShow == 3">
-                AND p.is_audit = 0
-                AND p.is_show = 1
-            </if>
-            <if test="maps.isShow == 4">
-                AND p.is_audit = 2
+            <if test="maps.isShow == 0">
                 AND p.is_show = 0
             </if>
         </if>
@@ -231,7 +219,7 @@
             AND p.prescribe_spec LIKE CONCAT('%', #{maps.prescribeSpec}, '%')
         </if>
         ORDER BY
-        p.product_id DESC
+        p.create_time DESC
     </select>
 
     <select id="getProductNoticeInfo" resultType="java.lang.String">

+ 4 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -882,7 +882,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     AND p.is_show = 0
                 </if>
             </if>
-            <if test="maps.isAudit != null">
+            <if test="maps.isAudit != null" >
+                <if test="maps.isAudit == '0' or maps.isAudit == 0 ">
+                    AND  p.is_show = 1
+                </if>
                 AND p.is_audit = #{maps.isAudit}
             </if>
             <if test="maps.commentContent != null and maps.commentContent.trim() != ''">