|
|
@@ -110,7 +110,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
* @return 商品
|
|
|
*/
|
|
|
@Override
|
|
|
- public FsStoreProductScrm selectFsStoreProductById(Long productId) {
|
|
|
+ public FsStoreProductScrm selectFsStoreProductById(Long productId)
|
|
|
+ {
|
|
|
return fsStoreProductMapper.selectFsStoreProductById(productId);
|
|
|
}
|
|
|
|
|
|
@@ -121,7 +122,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
* @return 商品
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<FsStoreProductScrm> selectFsStoreProductList(FsStoreProductScrm fsStoreProduct) {
|
|
|
+ public List<FsStoreProductScrm> selectFsStoreProductList(FsStoreProductScrm fsStoreProduct)
|
|
|
+ {
|
|
|
return fsStoreProductMapper.selectFsStoreProductList(fsStoreProduct);
|
|
|
}
|
|
|
|
|
|
@@ -132,7 +134,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertFsStoreProduct(FsStoreProductScrm fsStoreProduct) {
|
|
|
+ public int insertFsStoreProduct(FsStoreProductScrm fsStoreProduct)
|
|
|
+ {
|
|
|
fsStoreProduct.setCreateTime(DateUtils.getNowDate());
|
|
|
fsStoreProductMapper.insertFsStoreProduct(fsStoreProduct);
|
|
|
storeAuditLogUtil.addOperLog(fsStoreProduct.getProductId());
|
|
|
@@ -146,7 +149,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateFsStoreProduct(FsStoreProductScrm fsStoreProduct) {
|
|
|
+ public int updateFsStoreProduct(FsStoreProductScrm fsStoreProduct)
|
|
|
+ {
|
|
|
fsStoreProduct.setUpdateTime(DateUtils.getNowDate());
|
|
|
storeAuditLogUtil.addOperLog(fsStoreProduct.getProductId());
|
|
|
FsStoreProductScrm oldFsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(fsStoreProduct.getProductId());
|
|
|
@@ -157,7 +161,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
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)) {
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotEmpty(productColumns)){
|
|
|
//判断diff_columns是否在productColumns中,不是则将isAudit设置为0
|
|
|
for (String column : diff_columns) {
|
|
|
if (!productColumns.contains(column)) {
|
|
|
@@ -165,7 +169,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
+ }else{
|
|
|
fsStoreProduct.setIsAudit("0");
|
|
|
}
|
|
|
}
|
|
|
@@ -212,7 +216,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteFsStoreProductByIds(Long[] productIds) {
|
|
|
+ public int deleteFsStoreProductByIds(Long[] productIds)
|
|
|
+ {
|
|
|
storeAuditLogUtil.addBatchAuditArray(productIds, "", "");
|
|
|
return fsStoreProductMapper.deleteFsStoreProductByIds(productIds);
|
|
|
}
|
|
|
@@ -224,7 +229,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteFsStoreProductById(Long productId) {
|
|
|
+ public int deleteFsStoreProductById(Long productId)
|
|
|
+ {
|
|
|
return fsStoreProductMapper.deleteFsStoreProductById(productId);
|
|
|
}
|
|
|
|
|
|
@@ -233,20 +239,20 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
List<FsStoreProductListVO> fsStoreProductListVOS = fsStoreProductMapper.selectFsStoreProductListVO(fsStoreProduct);
|
|
|
|
|
|
for (FsStoreProductListVO item : fsStoreProductListVOS) {
|
|
|
- if (StringUtils.isNotBlank(item.getCompanyIds())) {
|
|
|
+ if(StringUtils.isNotBlank(item.getCompanyIds())){
|
|
|
List<String> companyNameList = new ArrayList<>();
|
|
|
String[] split = item.getCompanyIds().split(",");
|
|
|
|
|
|
for (String companyId : split) {
|
|
|
- if (StringUtils.isNotBlank(companyId)) {
|
|
|
+ if(StringUtils.isNotBlank(companyId)) {
|
|
|
String companyName = companyCacheService.selectCompanyNameById(Long.valueOf(companyId));
|
|
|
companyNameList.add(companyName);
|
|
|
}
|
|
|
}
|
|
|
- item.setCompanyName(String.join(",", companyNameList));
|
|
|
+ item.setCompanyName(String.join(",",companyNameList));
|
|
|
}
|
|
|
//店铺名称
|
|
|
- if (StringUtils.isNotEmpty(item.getStoreId()))
|
|
|
+ if(StringUtils.isNotEmpty(item.getStoreId()))
|
|
|
item.setStoreName(fsStoreScrmService.selectFsStoreByStoreId(Long.parseLong(item.getStoreId())).getStoreName());
|
|
|
}
|
|
|
|
|
|
@@ -258,7 +264,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
List<FsStoreProductListVO> fsStoreProductListVOS = fsStoreProductMapper.selectFsStoreProductBarCodeListVO(fsStoreProduct);
|
|
|
|
|
|
for (FsStoreProductListVO item : fsStoreProductListVOS) {
|
|
|
- if (StringUtils.isNotBlank(item.getCompanyIds())) {
|
|
|
+ if(StringUtils.isNotBlank(item.getCompanyIds())){
|
|
|
List<String> companyNameList = new ArrayList<>();
|
|
|
String[] split = item.getCompanyIds().split(",");
|
|
|
|
|
|
@@ -266,14 +272,14 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
String companyName = companyCacheService.selectCompanyNameById(Long.valueOf(companyId));
|
|
|
companyNameList.add(companyName);
|
|
|
}
|
|
|
- item.setCompanyName(String.join(",", companyNameList));
|
|
|
+ item.setCompanyName(String.join(",",companyNameList));
|
|
|
}
|
|
|
}
|
|
|
return fsStoreProductListVOS;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> getFormatAttr(Long productId, String jsonStr, Long[] stores) {
|
|
|
+ public Map<String, Object> getFormatAttr(Long productId, String jsonStr,Long[] stores) {
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
|
|
Map<String, Object> resultMap = new LinkedHashMap<>(3);
|
|
|
if (jsonObject == null || jsonObject.get("attrs") == null || jsonObject.getJSONArray("attrs").isEmpty()) {
|
|
|
@@ -339,13 +345,13 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
valueMap.put("brokerageThree", 0);
|
|
|
valueMap.put("integral", 0);
|
|
|
if (productId > 0) {
|
|
|
- FsStoreProductAttrValueScrm attrValueMap = new FsStoreProductAttrValueScrm();
|
|
|
+ FsStoreProductAttrValueScrm attrValueMap=new FsStoreProductAttrValueScrm();
|
|
|
attrValueMap.setProductId(productId);
|
|
|
attrValueMap.setSku(sku);
|
|
|
List<FsStoreProductAttrValueScrm> values = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueList(attrValueMap);
|
|
|
- if (values != null && values.size() == 1) {
|
|
|
- valueMap.put("id", values.get(0).getId());
|
|
|
- valueMap.put("sku", values.get(0).getSku());
|
|
|
+ if (values != null&&values.size()==1) {
|
|
|
+ valueMap.put("id",values.get(0).getId());
|
|
|
+ valueMap.put("sku",values.get(0).getSku());
|
|
|
valueMap.put("image", values.get(0).getImage());
|
|
|
valueMap.put("price", values.get(0).getPrice());
|
|
|
valueMap.put("cost", values.get(0).getCost());
|
|
|
@@ -374,9 +380,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public R addOrEdit(FsStoreProductAddEditParam param) {
|
|
|
- ProductAttrCountDto countDto = computedProductCount(param.getValues());
|
|
|
- FsStoreProductScrm product = new FsStoreProductScrm();
|
|
|
- BeanUtils.copyProperties(param, product);
|
|
|
+ ProductAttrCountDto countDto=computedProductCount(param.getValues());
|
|
|
+ FsStoreProductScrm product=new FsStoreProductScrm();
|
|
|
+ BeanUtils.copyProperties(param,product);
|
|
|
product.setPrice(countDto.getMinPrice());
|
|
|
product.setOtPrice(countDto.getMinOtPrice());
|
|
|
product.setCost(countDto.getMinCost());
|
|
|
@@ -388,42 +394,35 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
product.setStoreId(storeId);
|
|
|
product.setIsDrug(param.getIsDrug().toString());
|
|
|
product.setInstructionManual(param.getInstructionManual());
|
|
|
- product.setReviewAudit(param.getReviewAudit());
|
|
|
- product.setQualificationCertificate(param.getQualificationCertificate());
|
|
|
- if (param.getQualificationCertificateStart() != null) {
|
|
|
- product.setQualificationCertificateStart(LocalDate.parse(param.getQualificationCertificateStart()));
|
|
|
- }
|
|
|
- if (param.getQualificationCertificateEnd() != null) {
|
|
|
- product.setQualificationCertificateEnd(LocalDate.parse(param.getQualificationCertificateEnd()));
|
|
|
- }
|
|
|
+
|
|
|
//获取商品编码
|
|
|
- if (!param.getValues().isEmpty()) {
|
|
|
- if (param.getValues().get(0).getBarCode() != null) {
|
|
|
+ if(!param.getValues().isEmpty()){
|
|
|
+ if(param.getValues().get(0).getBarCode() != null){
|
|
|
product.setBarCode(param.getValues().get(0).getBarCode());
|
|
|
}
|
|
|
}
|
|
|
//校验店铺资质信息
|
|
|
//获取店铺
|
|
|
FsStoreScrm store = fsStoreScrmService.selectFsStoreByStoreId(product.getStoreId());
|
|
|
- if (store == null || 1 != store.getStatus()) {
|
|
|
+ if(store == null || 1 != store.getStatus()){
|
|
|
return R.error("店铺不存在或未启用");
|
|
|
- } else {
|
|
|
+ }else{
|
|
|
//验证资质
|
|
|
- switch (product.getProductType()) {
|
|
|
+ switch (product.getProductType()){
|
|
|
case 1://非处方
|
|
|
break;
|
|
|
case 2://处方
|
|
|
- if (StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) || LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd())) {
|
|
|
+ if(StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) || LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd())){
|
|
|
return R.error("店铺药品资质为空或已过期,请完善后再添加");
|
|
|
}
|
|
|
break;
|
|
|
case 3://食品
|
|
|
- if (StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) || LocalDate.now().isAfter(store.getFoodLicenseExpiryEnd())) {
|
|
|
+ if(StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) || LocalDate.now().isAfter(store.getFoodLicenseExpiryEnd())){
|
|
|
return R.error("店铺食品资质为空或已过期,请完善后再添加");
|
|
|
}
|
|
|
break;
|
|
|
case 4://器械
|
|
|
- if (StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) || LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd())) {
|
|
|
+ if(StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) || LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd())){
|
|
|
return R.error("店铺器械资质为空或已过期,请完善后再添加");
|
|
|
}
|
|
|
break;
|
|
|
@@ -432,11 +431,11 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ("纯正堂".equals(cloudHostProper.getCompanyName())) {
|
|
|
+ if("纯正堂".equals(cloudHostProper.getCompanyName())){
|
|
|
product.setIsAudit("1");
|
|
|
}
|
|
|
|
|
|
- if (param.getProductId() != null && param.getProductId() > 0) {
|
|
|
+ if(param.getProductId() != null && param.getProductId() > 0){
|
|
|
FsStoreProductScrm oldFsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(product.getProductId());
|
|
|
Boolean isAudit = configUtil.generateConfigByKey("medicalMall.func.switch").getBoolean("isAudit");
|
|
|
try {
|
|
|
@@ -445,7 +444,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
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)) {
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotEmpty(productColumns)){
|
|
|
//判断diff_columns是否在productColumns中,不是则将isAudit设置为0
|
|
|
for (String column : diff_columns) {
|
|
|
if (!productColumns.contains(column)) {
|
|
|
@@ -453,7 +452,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
+ }else{
|
|
|
product.setIsAudit("0");
|
|
|
}
|
|
|
}
|
|
|
@@ -467,14 +466,15 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
.value("规格")
|
|
|
.detail(ListUtil.toList("默认"))
|
|
|
.build();
|
|
|
- List<ProductArrtDTO> items = new ArrayList<>();
|
|
|
+ List<ProductArrtDTO> items=new ArrayList<>();
|
|
|
items.add(fromatDetailDto);
|
|
|
param.getValues().get(0).setSku("默认");
|
|
|
- addProductAttr(product.getProductId(), items, param.getValues(), storeId);
|
|
|
+ addProductAttr(product.getProductId(),items,param.getValues(),storeId);
|
|
|
} else {
|
|
|
- addProductAttr(product.getProductId(), param.getItems(), param.getValues(), storeId);
|
|
|
+ addProductAttr(product.getProductId(),param.getItems(),param.getValues(),storeId);
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else{
|
|
|
fsStoreProductMapper.insertFsStoreProduct(product);
|
|
|
}
|
|
|
storeAuditLogUtil.addOperLog(product.getProductId());
|
|
|
@@ -483,52 +483,52 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
.value("规格")
|
|
|
.detail(ListUtil.toList("默认"))
|
|
|
.build();
|
|
|
- List<ProductArrtDTO> items = new ArrayList<>();
|
|
|
+ List<ProductArrtDTO> items=new ArrayList<>();
|
|
|
items.add(fromatDetailDto);
|
|
|
param.getValues().get(0).setSku("默认");
|
|
|
- addProductAttr(product.getProductId(), items, param.getValues(), storeId);
|
|
|
+ addProductAttr(product.getProductId(),items,param.getValues(),storeId);
|
|
|
} else {
|
|
|
- addProductAttr(product.getProductId(), param.getItems(), param.getValues(), storeId);
|
|
|
+ addProductAttr(product.getProductId(),param.getItems(),param.getValues(),storeId);
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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
|
|
|
//查出商品属性所有ID;
|
|
|
- List<FsStoreProductAttrValueScrm> attrValues = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(productId);
|
|
|
+ List<FsStoreProductAttrValueScrm> attrValues=fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(productId);
|
|
|
fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByProductId(productId);
|
|
|
//写入attr
|
|
|
- for (ProductArrtDTO vo : items) {
|
|
|
- FsStoreProductAttrScrm attr = new FsStoreProductAttrScrm();
|
|
|
+ for(ProductArrtDTO vo:items){
|
|
|
+ FsStoreProductAttrScrm attr=new FsStoreProductAttrScrm();
|
|
|
attr.setProductId(productId);
|
|
|
attr.setAttrName(vo.getValue());
|
|
|
attr.setAttrValues(StringUtils.join(vo.getDetail(), ","));
|
|
|
fsStoreProductAttrMapper.insertFsStoreProductAttr(attr);
|
|
|
}
|
|
|
- Map<String, Object> map = new LinkedHashMap<>();
|
|
|
- map.put("attr", items);
|
|
|
+ Map<String,Object> map = new LinkedHashMap<>();
|
|
|
+ map.put("attr",items);
|
|
|
// map.put("value",values);
|
|
|
|
|
|
- for (FsStoreProductAttrValueScrm val : values) {
|
|
|
+ for(FsStoreProductAttrValueScrm val: values){
|
|
|
//更新套餐商品属性ID 获取套餐
|
|
|
- Long id = val.getId();
|
|
|
- if (val.getDetail() != null) {
|
|
|
+ Long id=val.getId();
|
|
|
+ if(val.getDetail()!=null){
|
|
|
List<String> stringList = new ArrayList<>(val.getDetail().values());
|
|
|
Collections.sort(stringList);
|
|
|
- val.setSku(StrUtil.join(",", stringList));
|
|
|
+ val.setSku(StrUtil.join(",",stringList));
|
|
|
}
|
|
|
val.setProductId(productId);
|
|
|
val.setStoreId(storeId);
|
|
|
fsStoreProductAttrValueMapper.insertFsStoreProductAttrValue(val);
|
|
|
- if (attrValues != null && attrValues.size() > 0) {
|
|
|
- for (FsStoreProductAttrValueScrm attrValue : attrValues) {
|
|
|
- if (attrValue.getId().equals(id)) {
|
|
|
- fsStoreProductGroupMapper.updateProducts(attrValue.getId(), val.getId());
|
|
|
- fsStoreProductPackageMapper.updateProducts(attrValue.getId(), val.getId());
|
|
|
+ if(attrValues!=null&&attrValues.size()>0){
|
|
|
+ for(FsStoreProductAttrValueScrm attrValue:attrValues){
|
|
|
+ if(attrValue.getId().equals(id)){
|
|
|
+ fsStoreProductGroupMapper.updateProducts(attrValue.getId(),val.getId());
|
|
|
+ fsStoreProductPackageMapper.updateProducts(attrValue.getId(),val.getId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -708,8 +708,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
private ProductAttrCountDto computedProductCount(List<FsStoreProductAttrValueScrm> values) {
|
|
|
- BigDecimal val = new BigDecimal(0);
|
|
|
+ BigDecimal val=new BigDecimal(0);
|
|
|
//取最小价格
|
|
|
BigDecimal minPrice = values
|
|
|
.stream()
|
|
|
@@ -762,34 +763,35 @@ 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 != null && medicalMallConfig.isStores();
|
|
|
- param.setIsStores(stores ? 1 : 0);
|
|
|
+ param.setIsStores(stores?1:0);
|
|
|
return fsStoreProductMapper.selectFsStoreProductListQuery(param);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public FsStoreProductQueryVO selectFsStoreProductByIdQuery(Long productId, String storeId) {
|
|
|
+ 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);
|
|
|
+ return fsStoreProductMapper.selectFsStoreProductByIdQuery(productId,storeId,medicalMallConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void decProductStock(Long productId, Long productAttrValueId, Integer cartNum) {
|
|
|
//处理属性sku
|
|
|
- fsStoreProductAttrValueMapper.decProductAttrStock(productAttrValueId, cartNum);
|
|
|
- fsStoreProductMapper.decProductAttrStock(productId, cartNum);
|
|
|
+ fsStoreProductAttrValueMapper.decProductAttrStock(productAttrValueId,cartNum);
|
|
|
+ fsStoreProductMapper.decProductAttrStock(productId,cartNum);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void incProductStock(Long num, Long productId, Long productAttrValueId) {
|
|
|
//处理属性sku
|
|
|
- if (productAttrValueId != null) {
|
|
|
+ if (productAttrValueId!=null) {
|
|
|
attrValueService.incProductAttrStock(num, productId, productAttrValueId);
|
|
|
}
|
|
|
//先处理商品库存
|
|
|
@@ -821,7 +823,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
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);
|
|
|
+ return fsStoreProductMapper.selectFsStoreProductGoodQuery(count,medicalMallConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -845,7 +847,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public Long selectFsStoreProductCount(int type, Long companyId) {
|
|
|
- return fsStoreProductMapper.selectFsStoreProductCompanyCount(type, companyId);
|
|
|
+ return fsStoreProductMapper.selectFsStoreProductCompanyCount(type,companyId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -867,17 +869,19 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
@Override
|
|
|
public String importStoreProduct(List<FsStoreProductExportVO> list, boolean updateSupport) {
|
|
|
storeAuditLogUtil.generateOperId();
|
|
|
- if (com.fs.common.utils.StringUtils.isNull(list) || list.size() == 0) {
|
|
|
+ if (com.fs.common.utils.StringUtils.isNull(list) || list.size() == 0)
|
|
|
+ {
|
|
|
throw new CustomException("导入商品数据不能为空!");
|
|
|
}
|
|
|
int successNum = 0;
|
|
|
int failureNum = 0;
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
- for (FsStoreProductExportVO productVO : list) {
|
|
|
- try {
|
|
|
+ for (FsStoreProductExportVO productVO : list){
|
|
|
+ try
|
|
|
+ {
|
|
|
FsStoreProductScrm product = BeanCopyUtils.copy(productVO, FsStoreProductScrm.class);
|
|
|
- if (product.getBarCode() == null || product.getBarCode() == "") {
|
|
|
+ if (product.getBarCode()==null || product.getBarCode()==""){
|
|
|
throw new CustomException("商品编号为空");
|
|
|
}
|
|
|
this.insertFsStoreProduct(product);
|
|
|
@@ -885,36 +889,36 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
.value("规格")
|
|
|
.detail(ListUtil.toList("默认"))
|
|
|
.build();
|
|
|
- List<ProductArrtDTO> items = new ArrayList<>();
|
|
|
+ List<ProductArrtDTO> items=new ArrayList<>();
|
|
|
items.add(formatDetailDto);
|
|
|
FsStoreProductAttrValueScrm p = new FsStoreProductAttrValueScrm();
|
|
|
p.setProductId(product.getProductId());
|
|
|
p.setSku("默认");
|
|
|
p.setStock(product.getStock().intValue());
|
|
|
- if (product.getStock() == null) {
|
|
|
+ if (product.getStock()==null){
|
|
|
p.setStock(0);
|
|
|
}
|
|
|
p.setSales(product.getSales().intValue());
|
|
|
- if (product.getSales() == null) {
|
|
|
+ if (product.getSales()==null){
|
|
|
p.setStock(0);
|
|
|
}
|
|
|
p.setPrice(product.getPrice());
|
|
|
- if (product.getPrice() == null) {
|
|
|
+ if (product.getPrice()==null){
|
|
|
p.setPrice(new BigDecimal(0));
|
|
|
}
|
|
|
p.setImage(product.getImage());
|
|
|
p.setCost(product.getCost());
|
|
|
- if (product.getCost() == null) {
|
|
|
+ if (product.getCost()==null){
|
|
|
p.setCost(new BigDecimal(0));
|
|
|
}
|
|
|
p.setBarCode(product.getBarCode());
|
|
|
p.setGroupBarCode(product.getBarCode());
|
|
|
p.setOtPrice(product.getOtPrice());
|
|
|
- if (product.getOtPrice() == null) {
|
|
|
+ if (product.getOtPrice()==null){
|
|
|
p.setOtPrice(new BigDecimal(0));
|
|
|
}
|
|
|
p.setWeight(productVO.getWeight());
|
|
|
- if (productVO.getWeight() == null) {
|
|
|
+ if (productVO.getWeight()==null){
|
|
|
p.setWeight(new BigDecimal(0));
|
|
|
}
|
|
|
|
|
|
@@ -933,18 +937,23 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
fsStoreProductAttrMapper.insertFsStoreProductAttr(attr);
|
|
|
successNum++;
|
|
|
successMsg.append("<br/>" + successNum + "、商品 " + product.getProductName() + " 导入成功");
|
|
|
- } catch (Exception e) {
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
|
|
|
failureNum++;
|
|
|
- String msg = "<br/>" + failureNum + "、商品 " + productVO.getProductName() + " 导入失败:";
|
|
|
+ String msg = "<br/>" + failureNum + "、商品 " + productVO.getProductName() + " 导入失败:";
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if (failureNum > 0) {
|
|
|
+ if (failureNum > 0)
|
|
|
+ {
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
throw new CustomException(failureMsg.toString());
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
}
|
|
|
return successMsg.toString();
|
|
|
@@ -952,7 +961,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public void batchModify(ModifyMoreDTO modifyMoreDTO) {
|
|
|
- storeAuditLogUtil.addBatchAuditList(modifyMoreDTO.getProductId(), "", null);
|
|
|
+ storeAuditLogUtil.addBatchAuditList(modifyMoreDTO.getProductId(),"",null);
|
|
|
fsStoreProductMapper.batchModify(modifyMoreDTO);
|
|
|
}
|
|
|
|
|
|
@@ -972,7 +981,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
|
//存储商品Id
|
|
|
- List<Long> jstProductIds = new LinkedList<>();
|
|
|
+ List<Long> jstProductIds=new LinkedList<>();
|
|
|
for (FsStoreProductExcelVO productVO : productList) {
|
|
|
try {
|
|
|
|
|
|
@@ -1066,17 +1075,17 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
Integer erpOpen = sysConfig.getErpOpen();
|
|
|
if (erpOpen == null || erpOpen == 0) {
|
|
|
//不作操作
|
|
|
- } else {
|
|
|
+ } else{
|
|
|
//判断erp类型
|
|
|
Integer erpType = sysConfig.getErpType();
|
|
|
if (erpType == null) {
|
|
|
//不作操作
|
|
|
- } else if (erpType == 3) {
|
|
|
+ }else if (erpType == 3) {
|
|
|
ErpGoods params = new ErpGoods();
|
|
|
params.setStoreProductId(product.getProductId());
|
|
|
//瀚智OMS 维护添加商品
|
|
|
hzOMSErpGoodsService.addGoodsScrm(params);
|
|
|
- } else if (erpType == 5) {
|
|
|
+ }else if(erpType == 5){
|
|
|
jstProductIds.add(product.getProductId());
|
|
|
}
|
|
|
}
|
|
|
@@ -1089,7 +1098,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
|
|
|
//验证聚水潭商品Id
|
|
|
- if (!jstProductIds.isEmpty()) {
|
|
|
+ if(!jstProductIds.isEmpty()){
|
|
|
//同步聚水潭商品
|
|
|
ErpGoods params = new ErpGoods();
|
|
|
params.setProductIdList(jstProductIds);
|
|
|
@@ -1132,7 +1141,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
@Transactional
|
|
|
public void batchAudit(ProductAuditDTO auditDTO) {
|
|
|
fsStoreProductMapper.batchAudit(auditDTO);
|
|
|
- storeAuditLogUtil.addBatchAuditList(auditDTO.getProductIds(), auditDTO.getReason(), auditDTO.getAttachImage());
|
|
|
+ storeAuditLogUtil.addBatchAuditList(auditDTO.getProductIds(),auditDTO.getReason(),auditDTO.getAttachImage());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1141,10 +1150,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<FsStoreProductActivityListVO> selectFsStoreProductByIdsAudit(String productIds) {
|
|
|
- SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
|
|
|
+ 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);
|
|
|
+ return fsStoreProductMapper.selectFsStoreProductByIdsAudit(productIds,medicalMallConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1152,10 +1160,10 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
public R bulkCopyFsStoreProductByIds(Long[] productIds) {
|
|
|
storeAuditLogUtil.addBatchAuditArray(productIds, "", "");
|
|
|
List<FsStoreProductScrm> list = fsStoreProductMapper.bulkCopyFsStoreProductByIds(productIds);
|
|
|
- if (list != null && !list.isEmpty()) {
|
|
|
+ if(list != null && !list.isEmpty()){
|
|
|
for (FsStoreProductScrm product : list) {
|
|
|
List<FsStoreProductAttrValueScrm> param = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(product.getProductId());
|
|
|
- if (!("益善缘".equals(cloudHostProper.getCompanyName()))) {
|
|
|
+ if(!("益善缘".equals(cloudHostProper.getCompanyName()))) {
|
|
|
//获取店铺
|
|
|
FsStoreScrm store = fsStoreScrmService.selectFsStoreByStoreId(product.getStoreId());
|
|
|
if (store == null || 1 != store.getStatus()) {
|
|
|
@@ -1196,10 +1204,10 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
.value("规格")
|
|
|
.detail(ListUtil.toList("默认"))
|
|
|
.build();
|
|
|
- List<ProductArrtDTO> items = new ArrayList<>();
|
|
|
+ List<ProductArrtDTO> items=new ArrayList<>();
|
|
|
items.add(fromatDetailDto);
|
|
|
param.get(0).setSku("默认");
|
|
|
- addProductAttr(product.getProductId(), items, param, product.getStoreId());
|
|
|
+ addProductAttr(product.getProductId(),items,param,product.getStoreId());
|
|
|
} else {
|
|
|
List<FsStoreProductAttrScrm> items = fsStoreProductAttrMapper.selectFsStoreProductAttrByProductId(product.getProductId());
|
|
|
|
|
|
@@ -1207,33 +1215,33 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
fsStoreProductAttrMapper.clear(fsStoreProductId);
|
|
|
//清空values
|
|
|
//查出商品属性所有ID;
|
|
|
- List<FsStoreProductAttrValueScrm> attrValues = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProductId);
|
|
|
+ List<FsStoreProductAttrValueScrm> attrValues=fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProductId);
|
|
|
fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByProductId(fsStoreProductId);
|
|
|
|
|
|
//写入attr
|
|
|
- for (FsStoreProductAttrScrm vo : items) {
|
|
|
+ for(FsStoreProductAttrScrm vo:items){
|
|
|
vo.setProductId(fsStoreProductId);
|
|
|
fsStoreProductAttrMapper.insertFsStoreProductAttr(vo);
|
|
|
}
|
|
|
- Map<String, Object> map = new LinkedHashMap<>();
|
|
|
- map.put("attr", items);
|
|
|
+ Map<String,Object> map = new LinkedHashMap<>();
|
|
|
+ map.put("attr",items);
|
|
|
// map.put("value",values);
|
|
|
|
|
|
- for (FsStoreProductAttrValueScrm val : param) {
|
|
|
+ for(FsStoreProductAttrValueScrm val: param){
|
|
|
//更新套餐商品属性ID 获取套餐
|
|
|
- Long id = val.getId();
|
|
|
- if (val.getDetail() != null) {
|
|
|
+ Long id=val.getId();
|
|
|
+ if(val.getDetail()!=null){
|
|
|
List<String> stringList = new ArrayList<>(val.getDetail().values());
|
|
|
Collections.sort(stringList);
|
|
|
- val.setSku(StrUtil.join(",", stringList));
|
|
|
+ val.setSku(StrUtil.join(",",stringList));
|
|
|
}
|
|
|
val.setProductId(fsStoreProductId);
|
|
|
fsStoreProductAttrValueMapper.insertFsStoreProductAttrValue(val);
|
|
|
- if (attrValues != null && !attrValues.isEmpty()) {
|
|
|
- for (FsStoreProductAttrValueScrm attrValue : attrValues) {
|
|
|
- if (attrValue.getId().equals(id)) {
|
|
|
- fsStoreProductGroupMapper.updateProducts(attrValue.getId(), val.getId());
|
|
|
- fsStoreProductPackageMapper.updateProducts(attrValue.getId(), val.getId());
|
|
|
+ if(attrValues!=null && !attrValues.isEmpty()){
|
|
|
+ for(FsStoreProductAttrValueScrm attrValue:attrValues){
|
|
|
+ if(attrValue.getId().equals(id)){
|
|
|
+ fsStoreProductGroupMapper.updateProducts(attrValue.getId(),val.getId());
|
|
|
+ fsStoreProductPackageMapper.updateProducts(attrValue.getId(),val.getId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1252,14 +1260,16 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public R instructionsViewable(FsStoreCartCountParam param) {
|
|
|
- //判断商品是否存在
|
|
|
- FsStoreProductScrm productScrm = fsStoreProductMapper.selectFsStoreProductById(param.getProductId());
|
|
|
- if (productScrm == null || productScrm.getProductType() == null) {
|
|
|
- return R.error("商品数据不存在,或类型异常!");
|
|
|
- } else if (productScrm.getProductType() != 2) {
|
|
|
+ FsStoreProductScrm product = fsStoreProductMapper.selectFsStoreProductById(param.getProductId());
|
|
|
+ if (product == null || product.getProductType() == null) {
|
|
|
+ return R.error("商品数据不存在或类型异常!");
|
|
|
+ }
|
|
|
+ if (product.getProductType() != 2) {
|
|
|
return R.ok().put("data", true);
|
|
|
}
|
|
|
- return R.ok().put("data", fsStoreProductMapper.instructionsViewable(param) > 0);
|
|
|
+ Integer qualifiedCount = fsStoreProductMapper.instructionsViewable(param);
|
|
|
+ boolean isViewable = qualifiedCount != null && qualifiedCount > 0;
|
|
|
+ return R.ok().put("data", isViewable);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1269,13 +1279,12 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, String>> getStoreProductColumns() {
|
|
|
- List<Map<String, String>> list = fsStoreProductMapper.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);
|
|
|
- ;
|
|
|
+ String camelCaseName = com.fs.common.utils.StringUtils.toCamelCase(columnName);;
|
|
|
camelCaseColumn.put("colName", camelCaseName);
|
|
|
camelCaseColumn.put("colComment", column.get("colComment"));
|
|
|
result.add(camelCaseColumn);
|