From 088c6faae1eda5c0a86c4f39e84b32728228757c Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Jul 2022 15:15:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E5=A4=9A=E6=AC=A1=E5=85=A5?= =?UTF-8?q?=E9=A9=BB=E5=BA=97=E9=93=BA=E6=97=A0=E6=B3=95=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/serviceimpl/StoreServiceImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index 90db9136..e90563fd 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -220,7 +220,7 @@ public class StoreServiceImpl extends ServiceImpl implements //获取当前操作的店铺 Store store = getStoreByMember(); //如果没有申请过店铺,新增店铺 - if (!Optional.ofNullable(store).isPresent()) { + if (store != null) { AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser()); Member member = memberService.getById(authUser.getId()); store = new Store(member); @@ -231,12 +231,20 @@ public class StoreServiceImpl extends ServiceImpl implements BeanUtil.copyProperties(storeCompanyDTO, storeDetail); return storeDetailService.save(storeDetail); } else { + store = new Store(); BeanUtil.copyProperties(storeCompanyDTO, store); this.updateById(store); //判断是否存在店铺详情,如果没有则进行新建,如果存在则进行修改 StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId()); - BeanUtil.copyProperties(storeCompanyDTO, storeDetail); - return storeDetailService.updateById(storeDetail); + //如果店铺详情为空,则new ,否则复制对象,然后保存即可。 + if (storeDetail == null) { + storeDetail = new StoreDetail(); + BeanUtil.copyProperties(storeCompanyDTO, storeDetail); + return storeDetailService.save(storeDetail); + } else { + BeanUtil.copyProperties(storeCompanyDTO, storeDetail); + return storeDetailService.updateById(storeDetail); + } } } From d5aadf6926d548d3339bf3c1a8765cdb0c47cc5d Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Jul 2022 18:38:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E5=88=86=E6=89=B9=E4=BF=9D=E5=AD=98=E5=8F=AF=E8=83=BD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=97=A0=E6=B3=95=E5=85=A5=E4=BD=8F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index e90563fd..9710abda 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -239,6 +239,7 @@ public class StoreServiceImpl extends ServiceImpl implements //如果店铺详情为空,则new ,否则复制对象,然后保存即可。 if (storeDetail == null) { storeDetail = new StoreDetail(); + storeDetail.setStoreId(store.getId()); BeanUtil.copyProperties(storeCompanyDTO, storeDetail); return storeDetailService.save(storeDetail); } else { From 5576ae73056a13faf1050f7096c01bc6d8148d5b Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Jul 2022 18:45:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20lilishop4.2.4=E4=B8=AD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=BA=8F=E5=88=97=E5=8C=96=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=EF=BC=8C=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF=E4=BC=9A?= =?UTF-8?q?=E5=9C=A8=E5=BA=8F=E5=88=97=E5=8C=96=E5=90=8E=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/redis/FastJsonRedisSerializer.java | 10 ++++-- .../order/cart/service/CartService.java | 7 ---- .../order/cart/service/CartServiceImpl.java | 36 +++++-------------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java b/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java index d59e29cf..f0071468 100644 --- a/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java +++ b/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java @@ -6,6 +6,7 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * 要实现对象的缓存,定义自己的序列化和反序列化器。使用阿里的fastjson来实现的比较多 @@ -13,8 +14,8 @@ import java.nio.charset.Charset; * @author Bulbasaur */ public class FastJsonRedisSerializer implements RedisSerializer { - private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); - private Class clazz; + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + private final Class clazz; public FastJsonRedisSerializer(Class clazz) { super(); @@ -26,7 +27,10 @@ public class FastJsonRedisSerializer implements RedisSerializer { if (null == t) { return new byte[0]; } - return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); + return JSON.toJSONString(t, + SerializerFeature.WriteClassName, + SerializerFeature.DisableCircularReferenceDetect) + .getBytes(DEFAULT_CHARSET); } @Override diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java index 01b3866d..d11d8aa8 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java @@ -95,13 +95,6 @@ public interface CartService { */ void clean(); - /** - * 清空购物车无效数据 - * - * @param way 购物车类型 - */ - void cleanChecked(CartTypeEnum way); - /** * 重新写入 * diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index f64769be..3fafa5be 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -16,7 +16,6 @@ import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; -import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.goods.service.WholesaleService; import cn.lili.modules.member.entity.dos.Member; @@ -46,7 +45,6 @@ import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.modules.promotion.service.PointsGoodsService; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; -import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -98,16 +96,6 @@ public class CartServiceImpl implements CartService { */ @Autowired private EsGoodsSearchService esGoodsSearchService; - /** - * 商品索引 - */ - @Autowired - private EsGoodsIndexService goodsIndexService; - /** - * ES商品 - */ - @Autowired - private GoodsService goodsService; /** * 砍价 */ @@ -161,7 +149,7 @@ public class CartServiceImpl implements CartService { int newNum = oldNum + num; this.checkSetGoodsQuantity(cartSkuVO, skuId, newNum); } - + cartSkuVO.setPromotionMap(promotionMap); //计算购物车小计 cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); } else { @@ -254,7 +242,8 @@ public class CartServiceImpl implements CartService { cartSkuVO.setChecked(checked); } } - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + + this.resetTradeDTO(tradeDTO); } @Override @@ -269,7 +258,8 @@ public class CartServiceImpl implements CartService { cartSkuVO.setChecked(checked); } } - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + + resetTradeDTO(tradeDTO); } @Override @@ -282,7 +272,7 @@ public class CartServiceImpl implements CartService { for (CartSkuVO cartSkuVO : cartSkuVOS) { cartSkuVO.setChecked(checked); } - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + resetTradeDTO(tradeDTO); } /** @@ -296,7 +286,6 @@ public class CartServiceImpl implements CartService { } @Override - @Transactional(rollbackFor = Exception.class) public void delete(String[] skuIds) { TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); List cartSkuVOS = tradeDTO.getSkuList(); @@ -309,7 +298,7 @@ public class CartServiceImpl implements CartService { } } cartSkuVOS.removeAll(deleteVos); - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + resetTradeDTO(tradeDTO); } @Override @@ -331,17 +320,8 @@ public class CartServiceImpl implements CartService { tradeDTO.setStoreCoupons(null); //清除添加过的备注 tradeDTO.setStoreRemark(null); - cache.put(this.getOriginKey(tradeDTO.getCartTypeEnum()), tradeDTO); - } - @Override - public void cleanChecked(CartTypeEnum way) { - if (way.equals(CartTypeEnum.CART)) { - TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); - this.cleanChecked(tradeDTO); - } else { - cache.remove(this.getOriginKey(way)); - } + resetTradeDTO(tradeDTO); } @Override