Explorar o código

普通商品插入逻辑优化

yjwang hai 3 días
pai
achega
b026bd9443

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

@@ -177,7 +177,7 @@ public interface FsStoreProductScrmMapper
         "from fs_store_product_scrm p " +
         "left join fs_store_product_category_scrm pc " +
         "on p.cate_id = pc.cate_id " +
-        "INNER JOIN fs_store_scrm ss " +
+        "left JOIN fs_store_scrm ss " +
         "on ss.store_id = p.store_id " +
         "left join ( " +
         "select product_id, push_status " +

+ 40 - 35
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -287,8 +287,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 item.setCompanyName(String.join(",",companyNameList));
             }
             //店铺名称
-            if(StringUtils.isNotEmpty(item.getStoreId()))
-                item.setStoreName(fsStoreScrmService.selectFsStoreByStoreId(Long.parseLong(item.getStoreId())).getStoreName());
+//            if(StringUtils.isNotEmpty(item.getStoreId()))
+//                item.setStoreName(fsStoreScrmService.selectFsStoreByStoreId(Long.parseLong(item.getStoreId())).getStoreName());
         }
 
         return fsStoreProductListVOS;
@@ -415,35 +415,39 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     @Override
     @Transactional
     public R addOrEdit(FsStoreProductAddEditParam param) {
+        FsStoreScrm store = null;
+        Long storeId = null;
+        //判断是否药品
+        if(param.getIsDrug() == 1){
+            //店铺判断
+            storeId = param.getStoreId();
+            store = fsStoreScrmService.selectFsStoreByStoreId(storeId);
+            if (store == null || 1 != store.getStatus()) {
+                return R.error("店铺不存在或未启用");
+            }
 
-        //店铺判断
-        Long storeId = param.getStoreId();
-        FsStoreScrm store = fsStoreScrmService.selectFsStoreByStoreId(storeId);
-        if (store == null || 1 != store.getStatus()) {
-            return R.error("店铺不存在或未启用");
-        }
-
-        //验证资质
-        switch (param.getProductType()) {
-            case 1://非处方
-                break;
-            case 2://处方
-                if (store.getIsDrugLicensePermanent() == 0 && StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) && (store.getDrugLicenseExpiryEnd() == null ||  LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd()))) {
-                    return R.error("店铺药品资质为空或已过期,请完善后再添加");
-                }
-                break;
-            case 3://食品
-                if (store.getIsFoodLicenseExpiryPermanent() == 0 && StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) && (store.getFoodLicenseExpiryEnd() == null ||  LocalDate.now().isAfter(store.getFoodLicenseExpiryEnd()))) {
-                    return R.error("店铺食品资质为空或已过期,请完善后再添加");
-                }
-                break;
-            case 4://器械
-                if (store.getIsMedicalDevice3ExpiryPermanent() == 0 && StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) && (store.getMedicalDevice3ExpiryEnd() == null ||  LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd()))) {
-                    return R.error("店铺器械资质为空或已过期,请完善后再添加");
-                }
-                break;
-            default:
-                return R.error("商品类型错误");
+            //验证资质
+            switch (param.getProductType()) {
+                case 1://非处方
+                    break;
+                case 2://处方
+                    if (store.getIsDrugLicensePermanent() == 0 && StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) && (store.getDrugLicenseExpiryEnd() == null ||  LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd()))) {
+                        return R.error("店铺药品资质为空或已过期,请完善后再添加");
+                    }
+                    break;
+                case 3://食品
+                    if (store.getIsFoodLicenseExpiryPermanent() == 0 && StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) && (store.getFoodLicenseExpiryEnd() == null ||  LocalDate.now().isAfter(store.getFoodLicenseExpiryEnd()))) {
+                        return R.error("店铺食品资质为空或已过期,请完善后再添加");
+                    }
+                    break;
+                case 4://器械
+                    if (store.getIsMedicalDevice3ExpiryPermanent() == 0 && StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) && (store.getMedicalDevice3ExpiryEnd() == null ||  LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd()))) {
+                        return R.error("店铺器械资质为空或已过期,请完善后再添加");
+                    }
+                    break;
+                default:
+                    return R.error("商品类型错误");
+            }
         }
 
         //基础信息
@@ -456,9 +460,10 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         populateDateRanges(product, param);
         setDefaultBarcodeIfAvailable(product, param);
         product.setBusinessLink(param.getBusinessLink());
+        product.setCreateTime(new Date());
 
         // 根据经营范围校验商品类型
-        if (com.fs.common.utils.StringUtils.isNotEmpty(store.getSelectableProductTypes())) {
+        if (store != null && com.fs.common.utils.StringUtils.isNotEmpty(store.getSelectableProductTypes())) {
             String productTypeName = getProductTypeName(product.getCateId());
             if (com.fs.common.utils.StringUtils.isNotEmpty(productTypeName)) {
                 // 直接使用工具类方法校验
@@ -470,8 +475,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             }
         }
 
-        //判断是否是纯正堂
-        if(CZT.equals(cloudHostProper.getCompanyName())){
+        //判断是否是纯正堂非药品商品不审核
+        if(CZT.equals(cloudHostProper.getCompanyName()) || param.getIsDrug() != 1){
             product.setIsAudit("1");
         }
 
@@ -487,7 +492,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             FsStoreProductScrm oldFsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(product.getProductId());
             Boolean isAudit = configUtil.generateConfigByKey("medicalMall.func.switch").getBoolean("isAudit");
             try {
-                if (isAudit != null && isAudit) {
+                if (isAudit != null && isAudit && param.getIsDrug() != 1) {
                     if (oldFsStoreProduct.getIsAudit() != null && "1".equals(oldFsStoreProduct.getIsAudit())) {
                         Map<String, Object> diff = getDiff(oldFsStoreProduct, product);
                         Set<String> diff_columns = diff.keySet();
@@ -521,7 +526,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             fsStoreProductMapper.insertFsStoreProduct(product);
         }
         storeAuditLogUtil.addOperLog(product.getProductId());
-        handleProductAttributes(param, product, storeId); //统一调用handleProductAttributes
+        handleProductAttributes(param, product, storeId);
         return R.ok();
     }