Commit 5756ad891afb12ee8a4dae01457eed96437ff2e3
1 parent
d1873f62
update:购物车显示商品图片
Showing
7 changed files
with
26 additions
and
6 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/domain/ShopCartMessageDto.java
... | ... | @@ -99,6 +99,8 @@ public class ShopCartMessageDto implements Serializable { |
99 | 99 | /** 商品名称 */ |
100 | 100 | private String productName; |
101 | 101 | |
102 | + private LocalDateTime modifiedTime; | |
103 | + | |
102 | 104 | public LocalDateTime getCacheTime() { |
103 | 105 | return cacheTime; |
104 | 106 | } |
... | ... | @@ -241,4 +243,12 @@ public class ShopCartMessageDto implements Serializable { |
241 | 243 | public void setUrl(String url) { |
242 | 244 | this.url = url; |
243 | 245 | } |
246 | + | |
247 | + public LocalDateTime getModifiedTime() { | |
248 | + return modifiedTime; | |
249 | + } | |
250 | + | |
251 | + public void setModifiedTime(LocalDateTime modifiedTime) { | |
252 | + this.modifiedTime = modifiedTime; | |
253 | + } | |
244 | 254 | } | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/IShopCartMessageService.java
... | ... | @@ -4,6 +4,7 @@ import com.diligrp.etrade.order.domain.ShopCartDto; |
4 | 4 | import com.diligrp.etrade.order.domain.ShopCartMessageDto; |
5 | 5 | import com.diligrp.etrade.order.model.ShopCartMessage; |
6 | 6 | |
7 | +import java.time.LocalDateTime; | |
7 | 8 | import java.util.List; |
8 | 9 | |
9 | 10 | public interface IShopCartMessageService { |
... | ... | @@ -16,7 +17,7 @@ public interface IShopCartMessageService { |
16 | 17 | |
17 | 18 | void updateShopCartMessage(ShopCartMessageDto shopCartMessageDto); |
18 | 19 | |
19 | - void updateByOld(ShopCartMessage shopCartMessageOld,ShopCartMessageDto shopCartMessageDto,Boolean bo); | |
20 | + void updateByOld(ShopCartMessage shopCartMessageOld, ShopCartMessageDto shopCartMessageDto, Boolean bo); | |
20 | 21 | |
21 | 22 | List<ShopCartMessage> findList(ShopCartMessageDto shopCartMessageDto); |
22 | 23 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/IShopCartService.java
... | ... | @@ -2,6 +2,7 @@ package com.diligrp.etrade.order.service; |
2 | 2 | |
3 | 3 | import com.diligrp.etrade.order.domain.*; |
4 | 4 | |
5 | +import java.time.LocalDateTime; | |
5 | 6 | import java.util.List; |
6 | 7 | |
7 | 8 | public interface IShopCartService { |
... | ... | @@ -10,7 +11,7 @@ public interface IShopCartService { |
10 | 11 | List<ShopCartVo> listShopCart(ShopCartDto shopCartDto); |
11 | 12 | |
12 | 13 | |
13 | - void saveShopCart(ShopCartDto shopCartDto,boolean flag); | |
14 | + void saveShopCart(ShopCartDto shopCartDto, boolean flag); | |
14 | 15 | |
15 | 16 | void updateShopcartList(List<ShopCartCacheDto> shopCartCacheDtoList); |
16 | 17 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
... | ... | @@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; |
31 | 31 | import org.springframework.util.Assert; |
32 | 32 | import org.springframework.util.CollectionUtils; |
33 | 33 | |
34 | +import java.time.LocalDateTime; | |
34 | 35 | import java.util.*; |
35 | 36 | import java.util.stream.Collectors; |
36 | 37 | |
... | ... | @@ -241,6 +242,7 @@ public class ShopCartImpl implements IShopCartService { |
241 | 242 | @Transactional(rollbackFor = Exception.class) |
242 | 243 | @Override |
243 | 244 | public void updateShopcartList(List<ShopCartCacheDto> shopCartCacheDtoList) { |
245 | + LocalDateTime now = LocalDateTime.now(); | |
244 | 246 | shopCartCacheDtoList.forEach(shopCartCacheDto -> { |
245 | 247 | List<ShopCartMessageDto> shopCartMessageDtos = shopCartCacheDto.getShopCartMessageDtos(); |
246 | 248 | if (!CollectionUtils.isEmpty(shopCartMessageDtos)){ |
... | ... | @@ -251,6 +253,7 @@ public class ShopCartImpl implements IShopCartService { |
251 | 253 | if(StringUtils.isBlank(shopCartMessageDto.getProductUrl())){ |
252 | 254 | shopCartMessageDto.setProductUrl(shopCartMessageDto.getUrl()); |
253 | 255 | } |
256 | + shopCartMessageDto.setModifiedTime(now); | |
254 | 257 | shopCartDto.setShopCartMessageDto(shopCartMessageDto); |
255 | 258 | return shopCartDto; |
256 | 259 | }).toList(); | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartMessageServiceImpl.java
... | ... | @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; |
13 | 13 | import org.springframework.transaction.annotation.Transactional; |
14 | 14 | import org.springframework.util.CollectionUtils; |
15 | 15 | |
16 | +import java.time.LocalDateTime; | |
16 | 17 | import java.util.List; |
17 | 18 | |
18 | 19 | /** |
... | ... | @@ -141,7 +142,7 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
141 | 142 | //如果是处理离线缓存数据,bo=true,总重量做覆盖,不是处理离线数据,总重量做增量 |
142 | 143 | if (bo) { |
143 | 144 | //如果缓存时间在更新之前之前,说明缓存数据不是最新数据,则不进行更新操作 |
144 | - if (shopCartMessageDto.getCacheTime().isBefore(shopCartMessageOld.getModifiedTime())) { | |
145 | + if (!shopCartMessageDto.getCacheTime().isAfter(shopCartMessageOld.getModifiedTime())) { | |
145 | 146 | return; |
146 | 147 | } |
147 | 148 | }else { | ... | ... |
etrade-order/src/main/resources/com/diligrp/etrade/dao/mapper/shopCart/ShopCartMapper.xml
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | <result column="weight" jdbcType="BIGINT" property="weight"/> |
29 | 29 | <result column="amount" jdbcType="BIGINT" property="amount"/> |
30 | 30 | <result column="type" jdbcType="TINYINT" property="type"/> |
31 | + <result column="url" jdbcType="VARCHAR" property="url"/> | |
31 | 32 | <result column="scm_modified_time" jdbcType="TIMESTAMP" property="modifiedTime"/> |
32 | 33 | <result column="check_flag" jdbcType="TINYINT" property="checkFlag"/> |
33 | 34 | <result column="alias" jdbcType="VARCHAR" property="alias"/> | ... | ... |
etrade-order/src/main/resources/com/diligrp/etrade/dao/mapper/shopCart/ShopCartMessageMapper.xml
... | ... | @@ -253,9 +253,12 @@ |
253 | 253 | <if test="shopCartId != null"> |
254 | 254 | shop_cart_id = #{shopCartId,jdbcType=BIGINT}, |
255 | 255 | </if> |
256 | - | |
257 | - modified_time = NOW(), | |
258 | - | |
256 | + <if test="modifiedTime != null"> | |
257 | + modified_time = #{modifiedTime,jdbcType=TIMESTAMP}, | |
258 | + </if> | |
259 | + <if test="modifiedTime == null"> | |
260 | + modified_time = NOW(), | |
261 | + </if> | |
259 | 262 | <if test="marketId != null"> |
260 | 263 | market_id = #{marketId,jdbcType=BIGINT}, |
261 | 264 | </if> | ... | ... |