|
@@ -58,6 +58,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
private MngChangeDao mngChangeDao;
|
|
private MngChangeDao mngChangeDao;
|
|
@Autowired
|
|
@Autowired
|
|
private MerchUserDao merchUserDao;
|
|
private MerchUserDao merchUserDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StoreMngChangeDao storeMngChangeDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public GoodsEntity queryObject(Integer id) {
|
|
public GoodsEntity queryObject(Integer id) {
|
|
@@ -407,29 +409,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
|
|
if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
|
|
for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
|
|
for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
|
|
//修改该商品的所属商户信息,如在该商户门店中有该上架的商品信息,则提示该商品不能修改
|
|
//修改该商品的所属商户信息,如在该商户门店中有该上架的商品信息,则提示该商品不能修改
|
|
- /*if(org.apache.commons.lang3.StringUtils.isNotEmpty(productStoreRela.getMerchSn()) && productStoreRela.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
|
|
|
|
- && goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_1.getItem())) {
|
|
|
|
- if (goods.getRetailPrice() != null) {
|
|
|
|
- productStoreRela.setRetailPrice(goods.getRetailPrice());
|
|
|
|
- }
|
|
|
|
- if (goods.getMarketPrice() != null) {
|
|
|
|
- productStoreRela.setMarketPrice(goods.getMarketPrice());
|
|
|
|
- }
|
|
|
|
- productStoreRelaDao.update(productStoreRela);
|
|
|
|
- }else {
|
|
|
|
- if (goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_0.getItem())) {
|
|
|
|
- if (goods.getRetailPrice() != null) {
|
|
|
|
- productStoreRela.setRetailPrice(goods.getRetailPrice());
|
|
|
|
- }
|
|
|
|
- if (goods.getMarketPrice() != null) {
|
|
|
|
- productStoreRela.setMarketPrice(goods.getMarketPrice());
|
|
|
|
- }
|
|
|
|
- productStoreRela.setMerchSn("");
|
|
|
|
- productStoreRelaDao.update(productStoreRela);
|
|
|
|
- } else {
|
|
|
|
- throw new RRException("商品编码为【" + goods.getGoodsSn() + "】的商品已上架在商户编号为【" + productStoreRela.getMerchSn() + "】的门店中,可先将该商品下架后再进行修改!");
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
|
|
ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
|
|
if(org.apache.commons.lang3.StringUtils.isNotEmpty(relaEntity.getMerchSn()) && relaEntity.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
|
|
if(org.apache.commons.lang3.StringUtils.isNotEmpty(relaEntity.getMerchSn()) && relaEntity.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
|
|
&& goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_1.getItem())) {
|
|
&& goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_1.getItem())) {
|
|
@@ -446,6 +425,40 @@ public class GoodsServiceImpl implements GoodsService {
|
|
if (goodsNumber < storeTotalGoodsNumber) {
|
|
if (goodsNumber < storeTotalGoodsNumber) {
|
|
throw new RRException("该商品已在各门店分配库存" + storeTotalGoodsNumber + ",当前商品总库存不能小于分配库存总额!请先修改门店库存!");
|
|
throw new RRException("该商品已在各门店分配库存" + storeTotalGoodsNumber + ",当前商品总库存不能小于分配库存总额!请先修改门店库存!");
|
|
}
|
|
}
|
|
|
|
+ }else{
|
|
|
|
+ //共享库存商品库存变化,修改该商品的所有库存信息
|
|
|
|
+ ProductStoreRelaEntity productStoreRelaEntity = new ProductStoreRelaEntity();
|
|
|
|
+ productStoreRelaEntity.setStockNum(goodsNumber);
|
|
|
|
+ productStoreRelaEntity.setGoodsId(goods.getId());
|
|
|
|
+ productStoreRelaDao.updateStockNumByGoodsId(productStoreRelaEntity);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
|
|
|
|
+ ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
|
|
|
|
+ //新增库存操作记录
|
|
|
|
+ StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
|
|
+ storeMngChangeEntity.setChangeReason("共享库存变更,更新门店商品库存");
|
|
|
|
+ storeMngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(relaEntity.getGoodsId())));
|
|
|
|
+ storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(relaEntity.getStoreId())));
|
|
|
|
+ storeMngChangeEntity.setMerchSn(goods.getMerchSn());
|
|
|
|
+ storeMngChangeEntity.setCreateTime(new Date());
|
|
|
|
+ storeMngChangeEntity.setModTime(new Date());
|
|
|
|
+ storeMngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
|
+ storeMngChangeEntity.setModerSn(user.getUsername());
|
|
|
|
+ storeMngChangeEntity.setIsValid(0);
|
|
|
|
+ Integer orginalNum = relaEntity.getStockNum()==null?0:relaEntity.getStockNum();//原有库存
|
|
|
|
+ if(goodsNumber != orginalNum) {
|
|
|
|
+ if (orginalNum > goodsNumber) {
|
|
|
|
+ storeMngChangeEntity.setChangeType(Dict.changeType.item_4.getItem());
|
|
|
|
+ storeMngChangeEntity.setStoreChangeNum(orginalNum - goodsNumber);//变化数
|
|
|
|
+ } else {
|
|
|
|
+ storeMngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
|
|
|
|
+ storeMngChangeEntity.setStoreChangeNum(goodsNumber - orginalNum);//变化数
|
|
|
|
+ }
|
|
|
|
+ storeMngChangeEntity.setStoreOriginalNum(orginalNum);//原库存数
|
|
|
|
+ storeMngChangeEntity.setStoreValidNum(goodsNumber);//可用数
|
|
|
|
+ storeMngChangeDao.save(storeMngChangeEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
Map cartMap = Maps.newHashMap();
|
|
Map cartMap = Maps.newHashMap();
|