店铺更新店铺信息,缓存未同步问题处理

This commit is contained in:
Chopper711 2023-01-13 10:07:57 +08:00
parent bdb62de868
commit cb3eca29d8

View File

@ -15,7 +15,10 @@ import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.search.utils.EsIndexUtil; import cn.lili.modules.search.utils.EsIndexUtil;
import cn.lili.modules.store.entity.dos.Store; import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.store.entity.dos.StoreDetail; import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.entity.dto.*; import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettingDTO;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO; import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO; import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO; import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO;
@ -25,7 +28,6 @@ import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.modules.store.service.StoreService; import cn.lili.modules.store.service.StoreService;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.GoodsTagsEnum; import cn.lili.rocketmq.tags.GoodsTagsEnum;
import cn.lili.rocketmq.tags.MemberTagsEnum;
import cn.lili.rocketmq.tags.StoreTagsEnum; import cn.lili.rocketmq.tags.StoreTagsEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -100,6 +102,7 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
boolean result = storeService.updateById(store); boolean result = storeService.updateById(store);
if (result) { if (result) {
this.updateStoreGoodsInfo(store); this.updateStoreGoodsInfo(store);
this.removeCache(store.getId());
} }
String destination = rocketmqCustomProperties.getStoreTopic() + ":" + StoreTagsEnum.EDIT_STORE_SETTING.name(); String destination = rocketmqCustomProperties.getStoreTopic() + ":" + StoreTagsEnum.EDIT_STORE_SETTING.name();
//发送订单变更mq消息 //发送订单变更mq消息
@ -125,6 +128,7 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
AuthUser tokenUser = Objects.requireNonNull(UserContext.getCurrentUser()); AuthUser tokenUser = Objects.requireNonNull(UserContext.getCurrentUser());
Store store = storeService.getById(tokenUser.getStoreId()); Store store = storeService.getById(tokenUser.getStoreId());
store.setMerchantEuid(merchantEuid); store.setMerchantEuid(merchantEuid);
this.removeCache(store.getId());
return storeService.updateById(store); return storeService.updateById(store);
} }
@ -164,6 +168,9 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorAddressPath, storeDeliverGoodsAddressDto.getSalesConsignorAddressPath()); lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorAddressPath, storeDeliverGoodsAddressDto.getSalesConsignorAddressPath());
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorDetail, storeDeliverGoodsAddressDto.getSalesConsignorDetail()); lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorDetail, storeDeliverGoodsAddressDto.getSalesConsignorDetail());
lambdaUpdateWrapper.eq(StoreDetail::getStoreId, storeId); lambdaUpdateWrapper.eq(StoreDetail::getStoreId, storeId);
this.removeCache(storeId);
return this.update(lambdaUpdateWrapper); return this.update(lambdaUpdateWrapper);
} }
@ -175,6 +182,7 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
*/ */
@Override @Override
public void updateSettlementDay(String storeId, DateTime dateTime) { public void updateSettlementDay(String storeId, DateTime dateTime) {
this.removeCache(storeId);
this.baseMapper.updateSettlementDay(storeId, dateTime); this.baseMapper.updateSettlementDay(storeId, dateTime);
} }
@ -209,6 +217,8 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
lambdaUpdateWrapper.set(StoreDetail::getSalesConsigneeDetail, storeAfterSaleAddressDTO.getSalesConsigneeDetail()); lambdaUpdateWrapper.set(StoreDetail::getSalesConsigneeDetail, storeAfterSaleAddressDTO.getSalesConsigneeDetail());
lambdaUpdateWrapper.set(StoreDetail::getSalesConsigneeMobile, storeAfterSaleAddressDTO.getSalesConsigneeMobile()); lambdaUpdateWrapper.set(StoreDetail::getSalesConsigneeMobile, storeAfterSaleAddressDTO.getSalesConsigneeMobile());
lambdaUpdateWrapper.eq(StoreDetail::getStoreId, storeId); lambdaUpdateWrapper.eq(StoreDetail::getStoreId, storeId);
this.removeCache(storeId);
return this.update(lambdaUpdateWrapper); return this.update(lambdaUpdateWrapper);
} }
@ -219,6 +229,7 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
LambdaUpdateWrapper<StoreDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate(); LambdaUpdateWrapper<StoreDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.set(StoreDetail::getStockWarning, stockWarning); lambdaUpdateWrapper.set(StoreDetail::getStockWarning, stockWarning);
lambdaUpdateWrapper.eq(StoreDetail::getStoreId, storeId); lambdaUpdateWrapper.eq(StoreDetail::getStoreId, storeId);
this.removeCache(storeId);
return this.update(lambdaUpdateWrapper); return this.update(lambdaUpdateWrapper);
} }
@ -249,4 +260,14 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
return this.baseMapper.getLicencePhoto(storeId); return this.baseMapper.getLicencePhoto(storeId);
} }
/**
* 删除缓存
*
* @param storeId 店铺id
*/
private void removeCache(String storeId) {
cache.get(CachePrefix.STORE.getPrefix() + storeId);
}
} }