|
@@ -7,18 +7,23 @@ import com.kmall.admin.dao.mk.dist.MkDistSellAllocationDao;
|
|
|
import com.kmall.admin.dto.StoreGoodsDto;
|
|
|
import com.kmall.admin.entity.*;
|
|
|
import com.kmall.admin.entity.mk.dist.MkDistSellAllocationEntity;
|
|
|
+import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
import com.kmall.admin.service.ProductStoreRelaService;
|
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
|
import com.kmall.api.util.StockUtil;
|
|
|
import com.kmall.common.constant.Dict;
|
|
|
-import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
import com.kmall.common.utils.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Service实现类
|
|
@@ -65,6 +70,8 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
private MerchUserDao merchUserDao;
|
|
|
@Autowired
|
|
|
private ExportExceptionDataDao exportExceptionDataDao;
|
|
|
+ @Autowired
|
|
|
+ private GoodsBatchDao goodsBatchDao;
|
|
|
|
|
|
@Override
|
|
|
public ProductStoreRelaEntity queryObject(Integer id) {
|
|
@@ -117,13 +124,16 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
throw new RRException(r.get("msg").toString());
|
|
|
} else {
|
|
|
goodsEntity = goodsDao.queryObject(productStoreRela.getGoodsId());
|
|
|
+ if (goodsEntity == null) {
|
|
|
+ throw new RRException("该商品异常,未添加该商品");
|
|
|
+ }
|
|
|
isStockShare = StockUtil.getIsStockShareByGoodsEntity(goodsEntity.getIsSupplierGoods(),
|
|
|
goodsEntity.getIsStockShare(), goodsEntity.getIsStockShare());
|
|
|
- if(goodsEntity.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem())){
|
|
|
- if(isStockShare.equalsIgnoreCase(Dict.isStockShare.item_0.getItem())){
|
|
|
+ if (goodsEntity.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem())) {
|
|
|
+ if (isStockShare.equalsIgnoreCase(Dict.isStockShare.item_0.getItem())) {
|
|
|
builder.put("stockNum", "库存");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
builder.put("stockNum", "库存");
|
|
|
}
|
|
|
|
|
@@ -529,297 +539,366 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
return productStoreRelaDao.queryGoodsRealListByTopicIdTotal(map);
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public int uploadExcel(List<StoreGoodsDto> storeGoodsDtoList){
|
|
|
+// GoodsEntity goodsEntity = null;
|
|
|
+// String isStockShare = "";
|
|
|
+// SysUserEntity user = ShiroUtils.getUserEntity();
|
|
|
+// String merchSn = user.getMerchSn();
|
|
|
+// boolean isFail = false;
|
|
|
+// List<String> failThirdMerchSnList = new ArrayList<>(),
|
|
|
+// failGoodsSnList = new ArrayList<>(), failHaveNameList = new ArrayList<>(), failHaveGoodsSnList = new ArrayList<>()
|
|
|
+// , failParentCateList = new ArrayList<>(), failCateList = new ArrayList<>(), failHaveStoreNameList = new ArrayList<>()
|
|
|
+// , failBrandList = new ArrayList<>(), failFreightList = new ArrayList<>();
|
|
|
+// if (storeGoodsDtoList != null && storeGoodsDtoList.size() > 0) {
|
|
|
+// for (int i = 0; i < storeGoodsDtoList.size(); i++) {
|
|
|
+// StoreGoodsDto storeGoodsDto = storeGoodsDtoList.get(i);
|
|
|
+// ProductStoreRelaEntity storeRelaEntity = new ProductStoreRelaEntity();
|
|
|
+// Map<String, Object> valideDate = MapBeanUtil.fromObject(storeGoodsDto);
|
|
|
+// ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
|
|
|
+// builder.put("storeName", "门店名称");
|
|
|
+// builder.put("goodsSn", "商品编码");
|
|
|
+// builder.put("categoryName", "一级分类");
|
|
|
+// builder.put("attributeCategory", "二级分类");
|
|
|
+// builder.put("brandName", "品牌");
|
|
|
+// builder.put("freightName", "运费");
|
|
|
+//
|
|
|
+// R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+// if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+// throw new RRException(r.get("msg").toString());
|
|
|
+// }
|
|
|
+// StoreEntity store = storeDao.queryObjectByName(storeGoodsDto.getStoreName().trim());
|
|
|
+// if (store != null) {
|
|
|
+// storeRelaEntity.setStoreId(store.getId());
|
|
|
+// storeRelaEntity.setMerchSn(store.getMerchSn());
|
|
|
+// MerchEntity merchEntity = merchDao.findByMerchSn(store.getMerchSn());
|
|
|
+// if(merchEntity != null){
|
|
|
+// storeRelaEntity.setMerchName(merchEntity.getMerchName());
|
|
|
+// }
|
|
|
+// goodsEntity = goodsDao.queryGoodsByGoodsSnAndStoreId(storeGoodsDto.getGoodsSn(), store.getId());
|
|
|
+// if(goodsEntity == null){//商品不存在
|
|
|
+// isFail = true;
|
|
|
+// failGoodsSnList.add(storeGoodsDto.getStoreName());
|
|
|
+// }else {
|
|
|
+// storeRelaEntity.setSku(goodsEntity.getSku());
|
|
|
+// storeRelaEntity.setGoodsId(goodsEntity.getId());
|
|
|
+// storeRelaEntity.setGoodsBizType(goodsEntity.getGoodsBizType());
|
|
|
+// isStockShare = StockUtil.getIsStockShareByGoodsEntity(goodsEntity.getIsSupplierGoods(),
|
|
|
+// goodsEntity.getIsStockShare(), goodsEntity.getIsStockShareBySuppler());
|
|
|
+//
|
|
|
+// if(goodsEntity.getIsSupplierGoods().equalsIgnoreCase(Dict.isSupplierGoods.item_1.getItem())) {
|
|
|
+// builder.put("supplierThirdName", "商品供货商所属第三方商户");
|
|
|
+// }
|
|
|
+// if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsEntity.getGoodsBizType())){
|
|
|
+// if(Dict.isStockShare.item_0.getItem().equalsIgnoreCase(isStockShare)){
|
|
|
+// builder.put("stockNum", "库存");
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// builder.put("stockNum", "库存");
|
|
|
+// }
|
|
|
+// if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
|
|
|
+// // 普通商品校验商品规格
|
|
|
+// builder.put("specification", "产品规格");
|
|
|
+// }
|
|
|
+// builder.put("retailPrice", "零售价");
|
|
|
+// builder.put("marketPrice", "市场价");
|
|
|
+// r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+// if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+// throw new RRException(r.get("msg").toString());
|
|
|
+// }
|
|
|
+// //商品配置校验
|
|
|
+// if(!StringUtils.isNotEmpty(goodsEntity.getListPicUrl())){
|
|
|
+// throw new RRException("该商品列表图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品列表图信息,再来操作门店商品数据");
|
|
|
+// }
|
|
|
+// if(!StringUtils.isNotEmpty(goodsEntity.getPrimaryPicUrl())){
|
|
|
+// throw new RRException("该商品主图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品主图信息,再来操作门店商品数据");
|
|
|
+// }
|
|
|
+// List<GoodsGalleryEntity> galleryEntityList = goodsGalleryDao.queryObjectByGoodId(goodsEntity.getId());
|
|
|
+// if (galleryEntityList == null || galleryEntityList.size() <= 0) {
|
|
|
+// throw new RRException("该商品轮播图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品详情轮播图信息,再来操作门店商品数据");
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(goodsEntity.getIsSupplierGoods().equalsIgnoreCase(Dict.isSupplierGoods.item_1.getItem())) {
|
|
|
+// builder.put("supplierThirdCode", "商品供货商所属第三方商户");
|
|
|
+// ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(storeGoodsDto.getSupplierThirdCode());
|
|
|
+// if(thirdMerchantBizEntity != null){
|
|
|
+// storeRelaEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
|
|
|
+// storeRelaEntity.setSupplierThirdId(thirdMerchantBizEntity.getThirdMerchSn());
|
|
|
+// }else{//第三方商户不存在
|
|
|
+// isFail = true;
|
|
|
+// failThirdMerchSnList.add(storeGoodsDto.getStoreName());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// CategoryEntity parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn());
|
|
|
+// if(parentCategoryEntity == null){
|
|
|
+// isFail = true;
|
|
|
+// failParentCateList.add(storeGoodsDto.getStoreName());
|
|
|
+// }else {
|
|
|
+// storeRelaEntity.setAttributeCategory(parentCategoryEntity.getParentId());
|
|
|
+// }
|
|
|
+// CategoryEntity categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn());
|
|
|
+// if(categoryEntity == null){
|
|
|
+// isFail = true;
|
|
|
+// failCateList.add(storeGoodsDto.getStoreName());
|
|
|
+// }else {
|
|
|
+// storeRelaEntity.setCategoryId(categoryEntity.getId());
|
|
|
+// }
|
|
|
+// BrandEntity brandEntity = brandDao.queryBrandByBrandNameAndStoreId(storeGoodsDto.getBrandName(), store.getId());
|
|
|
+// if(brandEntity == null){
|
|
|
+// isFail = true;
|
|
|
+// failBrandList.add(storeGoodsDto.getStoreName());
|
|
|
+// }else {
|
|
|
+// storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
+// }
|
|
|
+// FreightEntity freightEntity = freightDao.queryFreightByDefaultFreightAndStoreId(storeGoodsDto.getBrandName(), store.getId());
|
|
|
+// if(freightEntity == null){
|
|
|
+// isFail = true;
|
|
|
+// failFreightList.add(storeGoodsDto.getStoreName());
|
|
|
+// }else {
|
|
|
+// storeRelaEntity.setFreightId(freightEntity.getId());
|
|
|
+// }
|
|
|
+//
|
|
|
+// //校验总库存
|
|
|
+// if(goodsEntity.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem()) && isStockShare.equalsIgnoreCase(Dict.isStockShare.item_1.getItem())){
|
|
|
+// Integer stockNum = Integer.parseInt(storeGoodsDto.getStockNum());
|
|
|
+// Integer goodsNumber = goodsEntity.getGoodsNumber();//商品总库存
|
|
|
+// if (stockNum.intValue() != goodsNumber.intValue()) {
|
|
|
+// throw new RRException("门店【" + store.getStoreName() + "】商品编码【" + storeGoodsDto.getGoodsSn()
|
|
|
+// + "】的门店商品分配库存不等于商品总库存!当前门店属于共享库存,需与总库存一致,该商品总库存【" + goodsNumber + "】");
|
|
|
+// } else {
|
|
|
+// storeRelaEntity.setStockNum(goodsEntity.getGoodsNumber());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if((!goodsEntity.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem()) && isStockShare.equalsIgnoreCase(Dict.isStockShare.item_1.getItem())) ||
|
|
|
+// isStockShare.equalsIgnoreCase(Dict.isStockShare.item_0.getItem())){
|
|
|
+// Integer stockNum = Integer.parseInt(storeGoodsDto.getStockNum());
|
|
|
+// Integer goodsNumber = goodsEntity.getGoodsNumber();//商品总库存
|
|
|
+// Integer storeTotalStockNum = 0;//商品分配库存
|
|
|
+// List<ProductStoreRelaEntity> proStoreList = productStoreRelaDao.queryByGoodsId(goodsEntity.getId());
|
|
|
+// for(ProductStoreRelaEntity relaEntity: proStoreList){
|
|
|
+// if(relaEntity.getStoreId().intValue() != store.getId().intValue()) {
|
|
|
+// storeTotalStockNum = storeTotalStockNum + relaEntity.getStockNum();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// Integer totalStockNum = storeTotalStockNum + stockNum;
|
|
|
+// if(goodsNumber < totalStockNum){
|
|
|
+// throw new RRException("门店【" + store.getStoreName() + "】商品编码【" + storeGoodsDto.getGoodsSn()
|
|
|
+// + "】的门店商品分配库存已超过商品总库存!当前门店商品分配库存【" + stockNum + "】,已在各门店分配库存总额【"+
|
|
|
+// storeTotalStockNum + "】,该商品总库存【" + goodsNumber + "】");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// String storeId = String.valueOf(store.getId());
|
|
|
+// String goodsId = String.valueOf(goodsEntity.getId());
|
|
|
+// Map<String, Object> map = Maps.newHashMap();
|
|
|
+// map.put("goodsId", goodsId);
|
|
|
+// map.put("storeId", storeId);
|
|
|
+// List<ProductStoreRelaEntity> storeRelaList = querySameList(map);
|
|
|
+// if (storeRelaList != null && storeRelaList.size() > 0) {
|
|
|
+//// throw new RRException("该门店已存在此商品!");
|
|
|
+// isFail = true;
|
|
|
+// failHaveNameList.add(storeGoodsDto.getStoreName());
|
|
|
+// failHaveGoodsSnList.add(storeGoodsDto.getGoodsSn());
|
|
|
+// }
|
|
|
+//
|
|
|
+// ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(goodsId, "");
|
|
|
+// if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
|
|
|
+// GoodsSpecificationEntity goodsSpecificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
|
|
|
+// if(goodsSpecificationEntity != null){
|
|
|
+// goodsSpecificationDao.delete(goodsSpecificationEntity.getId());
|
|
|
+// }
|
|
|
+// // 添加商品规格
|
|
|
+// GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
|
|
|
+// goodsSpecification.setGoodsId(goodsEntity.getId());
|
|
|
+// goodsSpecification.setValue(storeGoodsDto.getSpecification());
|
|
|
+// goodsSpecification.setSpecificationId(1);
|
|
|
+// goodsSpecificationDao.save(goodsSpecification);
|
|
|
+//
|
|
|
+// // 修改产品
|
|
|
+// if(product == null){
|
|
|
+// product = new ProductEntity();
|
|
|
+// product.setGoodsSn(goodsEntity.getGoodsSn());
|
|
|
+// product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
+// product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
+// product.setGoodsId(goodsEntity.getId());
|
|
|
+// product.setGoodsNumber(goodsEntity.getGoodsNumber());
|
|
|
+// product.setGoodsDefault(0);
|
|
|
+// productDao.save(product);
|
|
|
+// }else{
|
|
|
+// product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
+// product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
+// productDao.update(product);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 批量导入不添加商品参数
|
|
|
+// //新增库存操作记录
|
|
|
+// StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
|
+// storeMngChangeEntity.setChangeType(Dict.changeType.item_2.getItem());
|
|
|
+// storeMngChangeEntity.setChangeReason("新增门店商品");
|
|
|
+// storeMngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
|
|
|
+// storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(store.getId())));
|
|
|
+// storeMngChangeEntity.setMerchSn(store.getMerchSn());
|
|
|
+// storeMngChangeEntity.setCreateTime(new Date());
|
|
|
+// storeMngChangeEntity.setModTime(new Date());
|
|
|
+// storeMngChangeEntity.setStoreChangeNum(Integer.parseInt(storeGoodsDto.getStockNum()));
|
|
|
+// storeMngChangeEntity.setStoreOriginalNum(0);
|
|
|
+// storeMngChangeEntity.setStoreValidNum(Integer.parseInt(storeGoodsDto.getStockNum()));
|
|
|
+// storeMngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
+// storeMngChangeEntity.setModerSn(user.getUsername());
|
|
|
+// storeMngChangeEntity.setIsValid(0);
|
|
|
+// storeMngChangeDao.save(storeMngChangeEntity);
|
|
|
+//
|
|
|
+// //更新门店商品是否有修改字段
|
|
|
+// updateLoadGoodsByStoreId(storeId, user);
|
|
|
+//
|
|
|
+// storeRelaEntity.setProductId(product.getId());
|
|
|
+//// storeRelaEntity.setGoodsBizType(goodsEntity.getGoodsBizType());
|
|
|
+//// storeRelaEntity.setSku(goodsEntity.getSku());
|
|
|
+// storeRelaEntity.setRetailPrice(BigDecimal.valueOf(Long.valueOf(storeGoodsDto.getRetailPrice())));
|
|
|
+// storeRelaEntity.setMarketPrice(BigDecimal.valueOf(Long.valueOf(storeGoodsDto.getMarketPrice())));
|
|
|
+// storeRelaEntity.setCreaterSn(user.getUserId().toString());
|
|
|
+// storeRelaEntity.setCreateTime(new Date());
|
|
|
+// storeRelaEntity.setModerSn(user.getUserId().toString());
|
|
|
+// storeRelaEntity.setModTime(new Date());
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// isFail = true;
|
|
|
+// failHaveStoreNameList.add(storeGoodsDto.getStoreName());
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(!isFail){
|
|
|
+// productStoreRelaDao.save(storeRelaEntity);
|
|
|
+// }
|
|
|
+//
|
|
|
+// ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
|
|
|
+// exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
|
|
|
+// exportExceptionDataEntity.setUserId(user.getUserId().intValue());
|
|
|
+// exportExceptionDataEntity.setCreateTime(new Date());
|
|
|
+// exportExceptionDataEntity.setModTime(new Date());
|
|
|
+// exportExceptionDataEntity.setMerchSn(merchSn);
|
|
|
+// exportExceptionDataEntity.setStoreId(user.getStoreId());
|
|
|
+// exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_3.getItem());
|
|
|
+//
|
|
|
+// if(failHaveStoreNameList != null && failHaveStoreNameList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("门店名称不存在,请检查门店名称【"+failHaveStoreNameList+"】的门店名称信息!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failThirdMerchSnList != null && failThirdMerchSnList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("第三方商户代码不存在,请在商城配置》第三方商户管理中维护,请检查门店名称【"+failThirdMerchSnList+"】的第三方商户代码信息,请先维护再继续操作!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failHaveNameList != null && failHaveNameList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("门店商品已存在!请检查门店名称【" + failHaveNameList + "】商品编码【" + failHaveGoodsSnList + "】的门店商品信息");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failGoodsSnList != null && failGoodsSnList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("商户编码不存在,请检查门店名称【"+failGoodsSnList+"】的商户编码信息,请先维护再继续操作!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failParentCateList != null && failParentCateList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("一级分类不存在,请检查门店名称【"+failParentCateList+"】的一级分类信息,请先维护再继续操作!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failCateList != null && failCateList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("二级分类不存在,请检查门店名称【"+failCateList+"】的二级分类信息,请先维护再继续操作!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failBrandList != null && failBrandList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("品牌不存在,请检查门店名称【"+failBrandList+"】的品牌信息,请先维护再继续操作!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// if(failFreightList != null && failFreightList.size() > 0){
|
|
|
+// exportExceptionDataEntity.setExportExceptionData("运费模板不存在,请检查门店名称【"+failFreightList+"】的运费模板信息,请先维护再继续操作!");
|
|
|
+// exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
+// throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// throw new RRException("导入数据为空,或者检查数据是否为空");
|
|
|
+// }
|
|
|
+// throw new RRException("导入成功!");
|
|
|
+//// return 1;
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
- public int uploadExcel(List<StoreGoodsDto> storeGoodsDtoList){
|
|
|
- GoodsEntity goodsEntity = null;
|
|
|
- String isStockShare = "";
|
|
|
- SysUserEntity user = ShiroUtils.getUserEntity();
|
|
|
- String merchSn = user.getMerchSn();
|
|
|
- boolean isFail = false;
|
|
|
- List<String> failThirdMerchSnList = new ArrayList<>(),
|
|
|
- failGoodsSnList = new ArrayList<>(), failHaveNameList = new ArrayList<>(), failHaveGoodsSnList = new ArrayList<>()
|
|
|
- , failParentCateList = new ArrayList<>(), failCateList = new ArrayList<>(), failHaveStoreNameList = new ArrayList<>()
|
|
|
- , failBrandList = new ArrayList<>(), failFreightList = new ArrayList<>();
|
|
|
+ public List<ProductStoreRelaEntity> queryExportList(Map<String, Object> params) {
|
|
|
+ return productStoreRelaDao.queryExportList(params);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public int uploadExcel(List<StoreGoodsDto> storeGoodsDtoList) {
|
|
|
if (storeGoodsDtoList != null && storeGoodsDtoList.size() > 0) {
|
|
|
for (int i = 0; i < storeGoodsDtoList.size(); i++) {
|
|
|
StoreGoodsDto storeGoodsDto = storeGoodsDtoList.get(i);
|
|
|
ProductStoreRelaEntity storeRelaEntity = new ProductStoreRelaEntity();
|
|
|
- Map<String, Object> valideDate = MapBeanUtil.fromObject(storeGoodsDto);
|
|
|
- ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
|
|
|
- builder.put("storeName", "门店名称");
|
|
|
- builder.put("goodsSn", "商品编码");
|
|
|
- builder.put("categoryName", "一级分类");
|
|
|
- builder.put("attributeCategory", "二级分类");
|
|
|
- builder.put("brandName", "品牌");
|
|
|
- builder.put("freightName", "运费");
|
|
|
-
|
|
|
- R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
- if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
- throw new RRException(r.get("msg").toString());
|
|
|
- }
|
|
|
StoreEntity store = storeDao.queryObjectByName(storeGoodsDto.getStoreName().trim());
|
|
|
- if (store != null) {
|
|
|
- storeRelaEntity.setStoreId(store.getId());
|
|
|
- storeRelaEntity.setMerchSn(store.getMerchSn());
|
|
|
- MerchEntity merchEntity = merchDao.findByMerchSn(store.getMerchSn());
|
|
|
- if(merchEntity != null){
|
|
|
- storeRelaEntity.setMerchName(merchEntity.getMerchName());
|
|
|
- }
|
|
|
- goodsEntity = goodsDao.queryGoodsByGoodsSnAndStoreId(storeGoodsDto.getGoodsSn(), store.getId());
|
|
|
- if(goodsEntity == null){//商品不存在
|
|
|
- isFail = true;
|
|
|
- failGoodsSnList.add(storeGoodsDto.getStoreName());
|
|
|
- }else {
|
|
|
- storeRelaEntity.setSku(goodsEntity.getSku());
|
|
|
- storeRelaEntity.setGoodsId(goodsEntity.getId());
|
|
|
- storeRelaEntity.setGoodsBizType(goodsEntity.getGoodsBizType());
|
|
|
- isStockShare = StockUtil.getIsStockShareByGoodsEntity(goodsEntity.getIsSupplierGoods(),
|
|
|
- goodsEntity.getIsStockShare(), goodsEntity.getIsStockShareBySuppler());
|
|
|
-
|
|
|
- if(goodsEntity.getIsSupplierGoods().equalsIgnoreCase(Dict.isSupplierGoods.item_1.getItem())) {
|
|
|
- builder.put("supplierThirdName", "商品供货商所属第三方商户");
|
|
|
- }
|
|
|
- if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsEntity.getGoodsBizType())){
|
|
|
- if(Dict.isStockShare.item_0.getItem().equalsIgnoreCase(isStockShare)){
|
|
|
- builder.put("stockNum", "库存");
|
|
|
- }
|
|
|
- }else{
|
|
|
- builder.put("stockNum", "库存");
|
|
|
- }
|
|
|
- if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
|
|
|
- // 普通商品校验商品规格
|
|
|
- builder.put("specification", "产品规格");
|
|
|
- }
|
|
|
- builder.put("retailPrice", "零售价");
|
|
|
- builder.put("marketPrice", "市场价");
|
|
|
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
- if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
- throw new RRException(r.get("msg").toString());
|
|
|
- }
|
|
|
- //商品配置校验
|
|
|
- if(!StringUtils.isNotEmpty(goodsEntity.getListPicUrl())){
|
|
|
- throw new RRException("该商品列表图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品列表图信息,再来操作门店商品数据");
|
|
|
- }
|
|
|
- if(!StringUtils.isNotEmpty(goodsEntity.getPrimaryPicUrl())){
|
|
|
- throw new RRException("该商品主图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品主图信息,再来操作门店商品数据");
|
|
|
- }
|
|
|
- List<GoodsGalleryEntity> galleryEntityList = goodsGalleryDao.queryObjectByGoodId(goodsEntity.getId());
|
|
|
- if (galleryEntityList == null || galleryEntityList.size() <= 0) {
|
|
|
- throw new RRException("该商品轮播图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品详情轮播图信息,再来操作门店商品数据");
|
|
|
- }
|
|
|
-
|
|
|
- if(goodsEntity.getIsSupplierGoods().equalsIgnoreCase(Dict.isSupplierGoods.item_1.getItem())) {
|
|
|
- builder.put("supplierThirdCode", "商品供货商所属第三方商户");
|
|
|
- ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(storeGoodsDto.getSupplierThirdCode());
|
|
|
- if(thirdMerchantBizEntity != null){
|
|
|
- storeRelaEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
|
|
|
- storeRelaEntity.setSupplierThirdId(thirdMerchantBizEntity.getThirdMerchSn());
|
|
|
- }else{//第三方商户不存在
|
|
|
- isFail = true;
|
|
|
- failThirdMerchSnList.add(storeGoodsDto.getStoreName());
|
|
|
- }
|
|
|
- }
|
|
|
- CategoryEntity parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn());
|
|
|
- if(parentCategoryEntity == null){
|
|
|
- isFail = true;
|
|
|
- failParentCateList.add(storeGoodsDto.getStoreName());
|
|
|
- }else {
|
|
|
- storeRelaEntity.setAttributeCategory(parentCategoryEntity.getParentId());
|
|
|
- }
|
|
|
- CategoryEntity categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn());
|
|
|
- if(categoryEntity == null){
|
|
|
- isFail = true;
|
|
|
- failCateList.add(storeGoodsDto.getStoreName());
|
|
|
- }else {
|
|
|
- storeRelaEntity.setCategoryId(categoryEntity.getId());
|
|
|
- }
|
|
|
- BrandEntity brandEntity = brandDao.queryBrandByBrandNameAndStoreId(storeGoodsDto.getBrandName(), store.getId());
|
|
|
- if(brandEntity == null){
|
|
|
- isFail = true;
|
|
|
- failBrandList.add(storeGoodsDto.getStoreName());
|
|
|
- }else {
|
|
|
- storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
- }
|
|
|
- FreightEntity freightEntity = freightDao.queryFreightByDefaultFreightAndStoreId(storeGoodsDto.getBrandName(), store.getId());
|
|
|
- if(freightEntity == null){
|
|
|
- isFail = true;
|
|
|
- failFreightList.add(storeGoodsDto.getStoreName());
|
|
|
- }else {
|
|
|
- storeRelaEntity.setFreightId(freightEntity.getId());
|
|
|
- }
|
|
|
-
|
|
|
- //校验总库存
|
|
|
- if(goodsEntity.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem()) && isStockShare.equalsIgnoreCase(Dict.isStockShare.item_1.getItem())){
|
|
|
- Integer stockNum = Integer.parseInt(storeGoodsDto.getStockNum());
|
|
|
- Integer goodsNumber = goodsEntity.getGoodsNumber();//商品总库存
|
|
|
- if (stockNum.intValue() != goodsNumber.intValue()) {
|
|
|
- throw new RRException("门店【" + store.getStoreName() + "】商品编码【" + storeGoodsDto.getGoodsSn()
|
|
|
- + "】的门店商品分配库存不等于商品总库存!当前门店属于共享库存,需与总库存一致,该商品总库存【" + goodsNumber + "】");
|
|
|
- } else {
|
|
|
- storeRelaEntity.setStockNum(goodsEntity.getGoodsNumber());
|
|
|
- }
|
|
|
- }
|
|
|
- if((!goodsEntity.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem()) && isStockShare.equalsIgnoreCase(Dict.isStockShare.item_1.getItem())) ||
|
|
|
- isStockShare.equalsIgnoreCase(Dict.isStockShare.item_0.getItem())){
|
|
|
- Integer stockNum = Integer.parseInt(storeGoodsDto.getStockNum());
|
|
|
- Integer goodsNumber = goodsEntity.getGoodsNumber();//商品总库存
|
|
|
- Integer storeTotalStockNum = 0;//商品分配库存
|
|
|
- List<ProductStoreRelaEntity> proStoreList = productStoreRelaDao.queryByGoodsId(goodsEntity.getId());
|
|
|
- for(ProductStoreRelaEntity relaEntity: proStoreList){
|
|
|
- if(relaEntity.getStoreId().intValue() != store.getId().intValue()) {
|
|
|
- storeTotalStockNum = storeTotalStockNum + relaEntity.getStockNum();
|
|
|
- }
|
|
|
- }
|
|
|
- Integer totalStockNum = storeTotalStockNum + stockNum;
|
|
|
- if(goodsNumber < totalStockNum){
|
|
|
- throw new RRException("门店【" + store.getStoreName() + "】商品编码【" + storeGoodsDto.getGoodsSn()
|
|
|
- + "】的门店商品分配库存已超过商品总库存!当前门店商品分配库存【" + stockNum + "】,已在各门店分配库存总额【"+
|
|
|
- storeTotalStockNum + "】,该商品总库存【" + goodsNumber + "】");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String storeId = String.valueOf(store.getId());
|
|
|
- String goodsId = String.valueOf(goodsEntity.getId());
|
|
|
- Map<String, Object> map = Maps.newHashMap();
|
|
|
- map.put("goodsId", goodsId);
|
|
|
- map.put("storeId", storeId);
|
|
|
- List<ProductStoreRelaEntity> storeRelaList = querySameList(map);
|
|
|
- if (storeRelaList != null && storeRelaList.size() > 0) {
|
|
|
-// throw new RRException("该门店已存在此商品!");
|
|
|
- isFail = true;
|
|
|
- failHaveNameList.add(storeGoodsDto.getStoreName());
|
|
|
- failHaveGoodsSnList.add(storeGoodsDto.getGoodsSn());
|
|
|
- }
|
|
|
-
|
|
|
- ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(goodsId, "");
|
|
|
- if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
|
|
|
- GoodsSpecificationEntity goodsSpecificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
|
|
|
- if(goodsSpecificationEntity != null){
|
|
|
- goodsSpecificationDao.delete(goodsSpecificationEntity.getId());
|
|
|
- }
|
|
|
- // 添加商品规格
|
|
|
- GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
|
|
|
- goodsSpecification.setGoodsId(goodsEntity.getId());
|
|
|
- goodsSpecification.setValue(storeGoodsDto.getSpecification());
|
|
|
- goodsSpecification.setSpecificationId(1);
|
|
|
- goodsSpecificationDao.save(goodsSpecification);
|
|
|
-
|
|
|
- // 修改产品
|
|
|
- if(product == null){
|
|
|
- product = new ProductEntity();
|
|
|
- product.setGoodsSn(goodsEntity.getGoodsSn());
|
|
|
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
- product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
- product.setGoodsId(goodsEntity.getId());
|
|
|
- product.setGoodsNumber(goodsEntity.getGoodsNumber());
|
|
|
- product.setGoodsDefault(0);
|
|
|
- productDao.save(product);
|
|
|
- }else{
|
|
|
- product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
- productDao.update(product);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 批量导入不添加商品参数
|
|
|
- //新增库存操作记录
|
|
|
- StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
|
- storeMngChangeEntity.setChangeType(Dict.changeType.item_2.getItem());
|
|
|
- storeMngChangeEntity.setChangeReason("新增门店商品");
|
|
|
- storeMngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
|
|
|
- storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(store.getId())));
|
|
|
- storeMngChangeEntity.setMerchSn(store.getMerchSn());
|
|
|
- storeMngChangeEntity.setCreateTime(new Date());
|
|
|
- storeMngChangeEntity.setModTime(new Date());
|
|
|
- storeMngChangeEntity.setStoreChangeNum(Integer.parseInt(storeGoodsDto.getStockNum()));
|
|
|
- storeMngChangeEntity.setStoreOriginalNum(0);
|
|
|
- storeMngChangeEntity.setStoreValidNum(Integer.parseInt(storeGoodsDto.getStockNum()));
|
|
|
- storeMngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
- storeMngChangeEntity.setModerSn(user.getUsername());
|
|
|
- storeMngChangeEntity.setIsValid(0);
|
|
|
- storeMngChangeDao.save(storeMngChangeEntity);
|
|
|
-
|
|
|
- //更新门店商品是否有修改字段
|
|
|
- updateLoadGoodsByStoreId(storeId, user);
|
|
|
-
|
|
|
- storeRelaEntity.setProductId(product.getId());
|
|
|
-// storeRelaEntity.setGoodsBizType(goodsEntity.getGoodsBizType());
|
|
|
-// storeRelaEntity.setSku(goodsEntity.getSku());
|
|
|
- storeRelaEntity.setRetailPrice(BigDecimal.valueOf(Long.valueOf(storeGoodsDto.getRetailPrice())));
|
|
|
- storeRelaEntity.setMarketPrice(BigDecimal.valueOf(Long.valueOf(storeGoodsDto.getMarketPrice())));
|
|
|
- storeRelaEntity.setCreaterSn(user.getUserId().toString());
|
|
|
- storeRelaEntity.setCreateTime(new Date());
|
|
|
- storeRelaEntity.setModerSn(user.getUserId().toString());
|
|
|
- storeRelaEntity.setModTime(new Date());
|
|
|
- }
|
|
|
- }else{
|
|
|
- isFail = true;
|
|
|
- failHaveStoreNameList.add(storeGoodsDto.getStoreName());
|
|
|
- }
|
|
|
-
|
|
|
- if(!isFail){
|
|
|
- productStoreRelaDao.save(storeRelaEntity);
|
|
|
- }
|
|
|
|
|
|
- ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
|
|
|
- exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
|
|
|
- exportExceptionDataEntity.setUserId(user.getUserId().intValue());
|
|
|
- exportExceptionDataEntity.setCreateTime(new Date());
|
|
|
- exportExceptionDataEntity.setModTime(new Date());
|
|
|
- exportExceptionDataEntity.setMerchSn(merchSn);
|
|
|
- exportExceptionDataEntity.setStoreId(user.getStoreId());
|
|
|
- exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_3.getItem());
|
|
|
-
|
|
|
- if(failHaveStoreNameList != null && failHaveStoreNameList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("门店名称不存在,请检查门店名称【"+failHaveStoreNameList+"】的门店名称信息!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
- }
|
|
|
- if(failThirdMerchSnList != null && failThirdMerchSnList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("第三方商户代码不存在,请在商城配置》第三方商户管理中维护,请检查门店名称【"+failThirdMerchSnList+"】的第三方商户代码信息,请先维护再继续操作!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ storeRelaEntity.setStoreId(store.getId());
|
|
|
+ GoodsEntity goodsEntity = goodsDao.queryObjectBySn(storeGoodsDto.getGoodsSn());
|
|
|
+ if (goodsEntity != null) {
|
|
|
+ storeRelaEntity.setGoodsId(goodsEntity.getId());
|
|
|
+ }else{
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]未录入系统");
|
|
|
}
|
|
|
- if(failHaveNameList != null && failHaveNameList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("门店商品已存在!请检查门店名称【" + failHaveNameList + "】商品编码【" + failHaveGoodsSnList + "】的门店商品信息");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ CategoryEntity categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn());
|
|
|
+ if (categoryEntity != null) {
|
|
|
+ storeRelaEntity.setAttributeCategory(categoryEntity.getId());
|
|
|
+ }else{
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的二级类别输入有误");
|
|
|
}
|
|
|
- if(failGoodsSnList != null && failGoodsSnList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("商户编码不存在,请检查门店名称【"+failGoodsSnList+"】的商户编码信息,请先维护再继续操作!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ CategoryEntity parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn());
|
|
|
+ if (parentCategoryEntity != null && categoryEntity.getParentId().intValue()==parentCategoryEntity.getId().intValue()) {
|
|
|
+ storeRelaEntity.setCategoryId(parentCategoryEntity.getId());
|
|
|
+ }else{
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的一级类别输入有误");
|
|
|
}
|
|
|
- if(failParentCateList != null && failParentCateList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("一级分类不存在,请检查门店名称【"+failParentCateList+"】的一级分类信息,请先维护再继续操作!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ BrandEntity brandEntity = brandDao.queryObjectByName(storeGoodsDto.getBrandName(), store.getMerchSn());
|
|
|
+ if (brandEntity != null) {
|
|
|
+ storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
+ }else{
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的品牌输入有误");
|
|
|
}
|
|
|
- if(failCateList != null && failCateList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("二级分类不存在,请检查门店名称【"+failCateList+"】的二级分类信息,请先维护再继续操作!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ FreightEntity freightEntity = freightDao.queryFreightByFreightNameAndStoreId(storeGoodsDto.getFreightName(), store.getId());
|
|
|
+ if (freightEntity != null) {
|
|
|
+ storeRelaEntity.setFreightId(freightEntity.getId());
|
|
|
+ }else{
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的运费模板输入有误");
|
|
|
}
|
|
|
- if(failBrandList != null && failBrandList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("品牌不存在,请检查门店名称【"+failBrandList+"】的品牌信息,请先维护再继续操作!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ // 如果底线价大于零售价
|
|
|
+ if (new BigDecimal(storeGoodsDto.getBottomLinePrice()).compareTo(new BigDecimal(storeGoodsDto.getRetailPrice())) == 1) {
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的底线价不可以大于零售价");
|
|
|
}
|
|
|
- if(failFreightList != null && failFreightList.size() > 0){
|
|
|
- exportExceptionDataEntity.setExportExceptionData("运费模板不存在,请检查门店名称【"+failFreightList+"】的运费模板信息,请先维护再继续操作!");
|
|
|
- exportExceptionDataDao.save(exportExceptionDataEntity);
|
|
|
- throw new RRException("导入数据异常,异常信息请在商品管理》》导入异常数据中查看检查");
|
|
|
+ // 查询批次号是否存在
|
|
|
+ GoodsBatchEntity goodsBatchEntity = goodsBatchDao.queryByBatchSnAndSku(storeGoodsDto.getBatchSn(), goodsEntity.getSku());
|
|
|
+ if (goodsBatchEntity!=null){
|
|
|
+ storeRelaEntity.setBatchSn(goodsBatchEntity.getBatchSn());
|
|
|
+ Date batchExpireDate = goodsBatchEntity.getBatchExpireDate();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ storeRelaEntity.setBatchExpireDate(sdf.format(batchExpireDate));
|
|
|
+ }else{
|
|
|
+ throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的批次号不存在");
|
|
|
}
|
|
|
+ storeRelaEntity.setMarketPrice(new BigDecimal(storeGoodsDto.getMarketPrice()));
|
|
|
+ storeRelaEntity.setRetailPrice(new BigDecimal(storeGoodsDto.getRetailPrice()));
|
|
|
+ storeRelaEntity.setBottomLinePrice(storeGoodsDto.getBottomLinePrice());
|
|
|
+ storeRelaEntity.setStockNum(Integer.valueOf(storeGoodsDto.getStockNum()));
|
|
|
+ save(storeRelaEntity);
|
|
|
}
|
|
|
}else{
|
|
|
throw new RRException("导入数据为空,或者检查数据是否为空");
|
|
|
}
|
|
|
- throw new RRException("导入成功!");
|
|
|
-// return 1;
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<ProductStoreRelaEntity> queryExportList(Map<String, Object> params) {
|
|
|
- return productStoreRelaDao.queryExportList(params);
|
|
|
- }
|
|
|
+
|
|
|
}
|