...
|
...
|
@@ -76,16 +76,32 @@ public class PromotionProductMqListener extends AbstractMqListener implements Ch |
|
|
public void updateData(final Map data, final String key) throws Exception {
|
|
|
long begin = System.currentTimeMillis();
|
|
|
PromotionProduct promotionProduct = (PromotionProduct) ConvertUtils.transMap2Bean(PromotionProduct.class, data);
|
|
|
if (promotionProduct == null || promotionProduct.getPromotionId()== null|| promotionProduct.getPromotionId()== null) {
|
|
|
if (promotionProduct == null || promotionProduct.getPromotionId()== null|| promotionProduct.getProductSkn()== null) {
|
|
|
return;
|
|
|
}
|
|
|
// 1、保存至数据库
|
|
|
boolean sknIsChange=false;
|
|
|
Integer oldSkn=null;
|
|
|
// 1、获取数据库原数据
|
|
|
if(promotionProduct.getId()!=null){
|
|
|
PromotionProduct promotionProductOld = promotionProductService.selectById(promotionProduct.getId());
|
|
|
if(!(promotionProductOld.getProductSkn().equals(promotionProduct.getProductSkn()))){
|
|
|
//修改了skn,需要改原skn的promotionIds
|
|
|
sknIsChange=true;
|
|
|
oldSkn=promotionProductOld.getProductSkn();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 2、保存至数据库
|
|
|
promotionProductService.saveOrUpdate(promotionProduct);
|
|
|
logger.info("[func=updateData][step=saveToBb][key={}][cost={}ms]", key, System.currentTimeMillis() - begin);
|
|
|
|
|
|
// 2、更新ProductIndex
|
|
|
// 3、更新ProductIndex
|
|
|
this.updateProductIndex(promotionProduct.getProductSkn(), System.currentTimeMillis(), key);
|
|
|
logger.info("[func=updateData][step=updateProductIndex][productSkn={}][cost={}ms]", promotionProduct.getProductSkn(), System.currentTimeMillis() - begin);
|
|
|
if(sknIsChange){
|
|
|
this.updateProductIndex(oldSkn, System.currentTimeMillis(), key);
|
|
|
logger.info("[func=updateData][step=updateProductIndex][productSkn={}][cost={}ms]", oldSkn, System.currentTimeMillis() - begin);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|