|
|
@ -149,14 +149,15 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
cereShopProduct.setIfNew(param.getIfNew()); |
|
|
|
cereShopProduct.setIfFirst(param.getIfFirst()); |
|
|
|
cereShopProduct.setIfLowPrice(param.getIfLowPrice()); |
|
|
|
cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); |
|
|
|
|
|
|
|
|
|
|
|
if(IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))){ |
|
|
|
//如果是已上架,修改状态为审核中 |
|
|
|
cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
if(IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getPlatShelveState())) && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))){ |
|
|
|
//如果是平台已上架,修改状态为平台上架审核中。需要满足商品上架状态为上架状态下 |
|
|
|
cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
}else { |
|
|
|
//已下架 |
|
|
|
cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); |
|
|
|
cereShopProduct.setPlatShelveState(Integer.parseInt(param.getPlatShelveState())); |
|
|
|
} |
|
|
|
cereShopProduct.setCreateTime(time); |
|
|
|
cereShopProduct.setUpdateTime(time); |
|
|
@ -296,6 +297,7 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
cereShopProduct.setIfNew(param.getIfNew()); |
|
|
|
cereShopProduct.setIfFirst(param.getIfFirst()); |
|
|
|
cereShopProduct.setIfLowPrice(param.getIfLowPrice()); |
|
|
|
cereShopProduct.setShelveState(param.getShelveState()); |
|
|
|
|
|
|
|
boolean isNeedReExam = false; |
|
|
|
if(!StringUtils.equals(cereShopProduct.getProductName(), dbCereShopProduct.getProductName())){ |
|
|
@ -317,7 +319,7 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
isNeedReExam = true; |
|
|
|
} |
|
|
|
|
|
|
|
if(!isNeedReExam && !Objects.equals(cereShopProduct.getShelveState(), dbCereShopProduct.getShelveState())){ |
|
|
|
if(!isNeedReExam && !Objects.equals(param.getPlatShelveState(), dbCereShopProduct.getPlatShelveState())){ |
|
|
|
isNeedReExam = true; |
|
|
|
} |
|
|
|
|
|
|
@ -330,16 +332,21 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (isNeedReExam && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getShelveState())) { |
|
|
|
//如果是已上架,修改状态为审核中 |
|
|
|
cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
if (isNeedReExam && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getPlatShelveState()) && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getShelveState())) { |
|
|
|
//如果是已上架,修改状态为审核中。需满足商品上架状态为上架情况下 |
|
|
|
cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
} else { |
|
|
|
//已下架 |
|
|
|
cereShopProduct.setShelveState(param.getShelveState()); |
|
|
|
cereShopProduct.setPlatShelveState(param.getPlatShelveState()); |
|
|
|
} |
|
|
|
|
|
|
|
//不管是审核中,还是已下架,sku实时信息都要改成下架 |
|
|
|
projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); |
|
|
|
|
|
|
|
if (param.getShelveState() == 0){ |
|
|
|
//若为商品下架,sku实时信息都要改成下架。平台端也强制下架 |
|
|
|
cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_SHELVSTATE_FORCED.getCode()); |
|
|
|
projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); |
|
|
|
} |
|
|
|
|
|
|
|
cereShopProduct.setUpdateTime(time); |
|
|
|
cereShopProduct.setShopId(param.getShopId()); |
|
|
@ -587,14 +594,40 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
String describe=""; |
|
|
|
if(IntegerEnum.YES.getCode().equals(param.getShelveState())){ |
|
|
|
describe="上架商品"; |
|
|
|
cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_YES.getCode()); |
|
|
|
//更新商品库存缓存 |
|
|
|
updateProductStock(cereShopProduct.getProductId()); |
|
|
|
//刷新实时信息 |
|
|
|
projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), RefreshSkuRealInfoSourceEnum.PUT_ON_SHELVE); |
|
|
|
}else { |
|
|
|
describe="下架商品"; |
|
|
|
cereShopProduct.setPlatShelveState(param.getShelveState()); |
|
|
|
projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); |
|
|
|
} |
|
|
|
cereShopProductDAO.updateByPrimaryKeySelective(cereShopProduct); |
|
|
|
//清空缓存 |
|
|
|
triggerCacheUpdate(param.getProductId()); |
|
|
|
//triggerCacheUpdate(param.getProductId()); |
|
|
|
//新增日志 |
|
|
|
cerePlatformLogService.addLog(user,"商品管理","商户端操作",describe,cereShopProduct.getProductId(),time); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void platStart(ProductUpDownParam param, CerePlatformBusinessUser user) throws CoBusinessException { |
|
|
|
String time=TimeUtils.yyMMddHHmmss(); |
|
|
|
CereShopProduct cereShopProduct=new CereShopProduct(); |
|
|
|
cereShopProduct.setProductId(param.getProductId()); |
|
|
|
cereShopProduct.setPlatShelveState(param.getShelveState()); |
|
|
|
String describe=""; |
|
|
|
if(IntegerEnum.YES.getCode().equals(param.getShelveState())){ |
|
|
|
describe="平台上架商品"; |
|
|
|
cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
}else { |
|
|
|
describe="平台下架商品"; |
|
|
|
//projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); |
|
|
|
} |
|
|
|
cereShopProductDAO.updateByPrimaryKeySelective(cereShopProduct); |
|
|
|
//清空缓存 |
|
|
|
//triggerCacheUpdate(param.getProductId()); |
|
|
|
//新增日志 |
|
|
|
cerePlatformLogService.addLog(user,"商品管理","商户端操作",describe,cereShopProduct.getProductId(),time); |
|
|
|
} |
|
|
@ -765,7 +798,8 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
cereShopProduct.setIfOversold(Integer.parseInt(param.getIfOversold())); |
|
|
|
if (IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))) { |
|
|
|
//如果是已上架,修改状态为审核中 |
|
|
|
cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
//cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); |
|
|
|
cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_YES.getCode()); |
|
|
|
} else { |
|
|
|
//已下架 |
|
|
|
cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); |
|
|
@ -1306,4 +1340,19 @@ public class CereShopProductServiceImpl implements CereShopProductService { |
|
|
|
cereShopSeckillDetailService.updateBatchSeckillPrice(details); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新商品库存 |
|
|
|
* @param productId |
|
|
|
*/ |
|
|
|
private void updateProductStock(Long productId) { |
|
|
|
List<Sku> skuList = cereProductSkuService.findByProductId(productId); |
|
|
|
for (Sku sku:skuList) { |
|
|
|
String skuStockKey = CacheKeyConstants.SKU_STOCK_PREFIX + sku.getSkuId(); |
|
|
|
stringRedisService.set(skuStockKey, sku.getStockNumber()); |
|
|
|
|
|
|
|
String skuTotalStockKey = CacheKeyConstants.SKU_TOTAL_STOCK_PREFIX + sku.getSkuId(); |
|
|
|
stringRedisService.set(skuTotalStockKey, sku.getTotal()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |