|
@@ -1,5 +1,6 @@
|
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
@@ -10,6 +11,7 @@ import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
@@ -38,6 +40,9 @@ import com.fs.hisStore.param.FsStoreProductQueryParam;
|
|
|
import com.fs.hisStore.service.IFsStoreProductAttrValueScrmService;
|
|
|
import com.fs.hisStore.vo.*;
|
|
|
import com.fs.statis.dto.ProductAuditDTO;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -55,6 +60,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+@Slf4j
|
|
|
public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
{
|
|
|
@Autowired
|
|
@@ -78,6 +84,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Autowired
|
|
|
private ConfigUtil configUtil;
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
|
@Autowired
|
|
|
@Qualifier("hzOMSErpGoodsServiceImpl")
|
|
@@ -92,9 +100,6 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
@Autowired
|
|
|
private FsStoreScrmServiceImpl fsStoreScrmService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MedicalMallConfig medicalMallConfig;
|
|
|
-
|
|
|
@Autowired
|
|
|
private CloudHostProper cloudHostProper;
|
|
|
|
|
@@ -148,13 +153,62 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
{
|
|
|
fsStoreProduct.setUpdateTime(DateUtils.getNowDate());
|
|
|
storeAuditLogUtil.addOperLog(fsStoreProduct.getProductId());
|
|
|
- //对已上架的商品进行修改需要重新审核
|
|
|
- if(1 == fsStoreProduct.getIsShow() && "1".equals(fsStoreProduct.getIsAudit())){
|
|
|
- fsStoreProduct.setIsAudit("0");
|
|
|
+ FsStoreProductScrm oldFsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(fsStoreProduct.getProductId());
|
|
|
+ Boolean isAudit = configUtil.generateConfigByKey("medicalMall.func.switch").getBoolean("isAudit");
|
|
|
+ try {
|
|
|
+ if (isAudit != null && isAudit) {
|
|
|
+ if (oldFsStoreProduct.getIsAudit() != null && "1".equals(oldFsStoreProduct.getIsAudit())) {
|
|
|
+ Map<String, Object> diff = getDiff(oldFsStoreProduct, fsStoreProduct);
|
|
|
+ Set<String> diff_columns = diff.keySet();
|
|
|
+ JSONArray productColumns = configUtil.generateConfigByKey("medicalMall.func.switch").getJSONArray("productColumns");
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotEmpty(productColumns)){
|
|
|
+ //判断diff_columns是否在productColumns中,不是则将isAudit设置为0
|
|
|
+ for (String column : diff_columns) {
|
|
|
+ if (!productColumns.contains(column)) {
|
|
|
+ fsStoreProduct.setIsAudit("0");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ fsStoreProduct.setIsAudit("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ log.error("获取diff出错", e);
|
|
|
}
|
|
|
return fsStoreProductMapper.updateFsStoreProduct(fsStoreProduct);
|
|
|
}
|
|
|
|
|
|
+ public static Map<String, Object> getDiff(Object obj1, Object obj2) throws IllegalAccessException {
|
|
|
+ Map<String, Object> diff = new HashMap<>();
|
|
|
+ if (obj1 == null || obj2 == null || !obj1.getClass().equals(obj2.getClass())) {
|
|
|
+ return diff;
|
|
|
+ }
|
|
|
+
|
|
|
+ Field[] fields = obj1.getClass().getDeclaredFields();
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ Object value1 = field.get(obj1);
|
|
|
+ Object value2 = field.get(obj2);
|
|
|
+
|
|
|
+ // BigDecimal类型特殊处理
|
|
|
+ if (value1 instanceof BigDecimal && value2 instanceof BigDecimal) {
|
|
|
+ BigDecimal bd1 = (BigDecimal) value1;
|
|
|
+ BigDecimal bd2 = (BigDecimal) value2;
|
|
|
+ // 使用compareTo方法比较,避免精度问题
|
|
|
+ if (bd1.compareTo(bd2) != 0) {
|
|
|
+ diff.put(field.getName(), new Object[]{value1, value2});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 其他类型使用默认比较
|
|
|
+ else if (!Objects.equals(value1, value2)) {
|
|
|
+ diff.put(field.getName(), new Object[]{value1, value2});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return diff;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除商品
|
|
|
*
|
|
@@ -370,9 +424,29 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
|
|
|
if(param.getProductId() != null && param.getProductId() > 0){
|
|
|
- //对已上架的商品进行修改需要重新审核
|
|
|
- if(1 == product.getIsShow() && "1".equals(product.getIsAudit())){
|
|
|
- product.setIsAudit("0");
|
|
|
+ FsStoreProductScrm oldFsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(product.getProductId());
|
|
|
+ Boolean isAudit = configUtil.generateConfigByKey("medicalMall.func.switch").getBoolean("isAudit");
|
|
|
+ try {
|
|
|
+ if (isAudit != null && isAudit) {
|
|
|
+ if (oldFsStoreProduct.getIsAudit() != null && "1".equals(oldFsStoreProduct.getIsAudit())) {
|
|
|
+ Map<String, Object> diff = getDiff(oldFsStoreProduct, product);
|
|
|
+ Set<String> diff_columns = diff.keySet();
|
|
|
+ JSONArray productColumns = configUtil.generateConfigByKey("medicalMall.func.switch").getJSONArray("productColumns");
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotEmpty(productColumns)){
|
|
|
+ //判断diff_columns是否在productColumns中,不是则将isAudit设置为0
|
|
|
+ for (String column : diff_columns) {
|
|
|
+ if (!productColumns.contains(column)) {
|
|
|
+ product.setIsAudit("0");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ product.setIsAudit("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ log.error("获取diff出错", e);
|
|
|
}
|
|
|
fsStoreProductMapper.updateFsStoreProduct(product);
|
|
|
if (param.getSpecType().equals(0)) {
|
|
@@ -679,6 +753,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public List<FsStoreProductListQueryVO> selectFsStoreProductListQuery(FsStoreProductQueryParam param) {
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
boolean stores = medicalMallConfig.isStores();
|
|
|
param.setIsStores(stores?1:0);
|
|
|
return fsStoreProductMapper.selectFsStoreProductListQuery(param);
|
|
@@ -686,6 +762,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public FsStoreProductQueryVO selectFsStoreProductByIdQuery(Long productId,String storeId) {
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
return fsStoreProductMapper.selectFsStoreProductByIdQuery(productId,storeId,medicalMallConfig);
|
|
|
}
|
|
|
|
|
@@ -711,6 +789,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
@Override
|
|
|
public List<FsStoreProductListQueryVO> selectFsStoreProductNewQuery(int count) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
map.put("count", count);
|
|
|
map.put("config", medicalMallConfig);
|
|
|
return fsStoreProductMapper.selectFsStoreProductNewQuery(map);
|
|
@@ -719,6 +799,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
@Override
|
|
|
public List<FsStoreProductListQueryVO> selectFsStoreProductHotQuery(int count) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
map.put("count", count);
|
|
|
map.put("config", medicalMallConfig);
|
|
|
return fsStoreProductMapper.selectFsStoreProductHotQuery(map);
|
|
@@ -726,16 +808,22 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public List<FsStoreProductListQueryVO> selectFsStoreProductGoodQuery(int count) {
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
return fsStoreProductMapper.selectFsStoreProductGoodQuery(count,medicalMallConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery() {
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
return fsStoreProductMapper.selectFsStoreProductTuiListQuery(medicalMallConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<FsStoreProductListQueryVO> selectFsStoreProductGoodListQuery() {
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
return fsStoreProductMapper.selectFsStoreProductGoodListQuery(medicalMallConfig);
|
|
|
}
|
|
|
|
|
@@ -1049,7 +1137,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<FsStoreProductActivityListVO> selectFsStoreProductByIdsAudit(String productIds) {
|
|
|
+ public List<FsStoreProductActivityListVO> selectFsStoreProductByIdsAudit(String productIds) {SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
|
|
|
return fsStoreProductMapper.selectFsStoreProductByIdsAudit(productIds,medicalMallConfig);
|
|
|
}
|
|
|
|
|
@@ -1148,4 +1237,21 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, String>> getStoreProductColumns() {
|
|
|
+ List<Map<String, String> > list = fsStoreProductMapper.getStoreProductColumns();
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
+ for (Map<String, String> column : list) {
|
|
|
+ Map<String, String> camelCaseColumn = new HashMap<>();
|
|
|
+ String columnName = column.get("colName");
|
|
|
+ String camelCaseName = com.fs.common.utils.StringUtils.toCamelCase(columnName);;
|
|
|
+ camelCaseColumn.put("colName", camelCaseName);
|
|
|
+ camelCaseColumn.put("colComment", column.get("colComment"));
|
|
|
+ result.add(camelCaseColumn);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|