Commit 8be8c6920fc06bed7a46ba6a8fd1ef57c5169600
1 parent
202ff18f
update:购物车时间修正
Showing
3 changed files
with
17 additions
and
0 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/domain/ShopCartVo.java
... | ... | @@ -72,6 +72,11 @@ public class ShopCartVo implements Serializable { |
72 | 72 | */ |
73 | 73 | private String location; |
74 | 74 | |
75 | + /** | |
76 | + * 系统时间 | |
77 | + */ | |
78 | + private LocalDateTime systemTime; | |
79 | + | |
75 | 80 | private List<ShopCartMessageVo> shopCartMessageVoList; |
76 | 81 | |
77 | 82 | public String getShopName() { |
... | ... | @@ -184,6 +189,7 @@ public class ShopCartVo implements Serializable { |
184 | 189 | ", customerName='" + customerName + '\'' + |
185 | 190 | ", version=" + version + |
186 | 191 | ", location=" + location + |
192 | + ", systemTime=" + systemTime + | |
187 | 193 | ", shopCartMessageVoList=" + shopCartMessageVoList + |
188 | 194 | '}'; |
189 | 195 | } |
... | ... | @@ -195,4 +201,12 @@ public class ShopCartVo implements Serializable { |
195 | 201 | public void setLocation(String location) { |
196 | 202 | this.location = location; |
197 | 203 | } |
204 | + | |
205 | + public LocalDateTime getSystemTime() { | |
206 | + return systemTime; | |
207 | + } | |
208 | + | |
209 | + public void setSystemTime(LocalDateTime systemTime) { | |
210 | + this.systemTime = systemTime; | |
211 | + } | |
198 | 212 | } | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
... | ... | @@ -152,6 +152,7 @@ public class ShopCartImpl implements IShopCartService { |
152 | 152 | //对购物车商品信息集合按修改时间倒序排序 |
153 | 153 | List<ShopCartMessageVo> shopCartMessageVos = shopCartMessageVoList.stream().sorted(Comparator.comparing(ShopCartMessageVo::getModifiedTime, Comparator.reverseOrder())).collect(Collectors.toList()); |
154 | 154 | shopCartVo.setShopCartMessageVoList(shopCartMessageVos); |
155 | + shopCartVo.setSystemTime(LocalDateTime.now()); | |
155 | 156 | }); |
156 | 157 | //对购物车集合按修改时间倒序排序 |
157 | 158 | return shopCartVos.stream().sorted(Comparator.comparing(ShopCartVo::getModifiedTime, Comparator.reverseOrder())).collect(Collectors.toList()); | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartMessageServiceImpl.java
... | ... | @@ -145,7 +145,9 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
145 | 145 | if (!shopCartMessageDto.getCacheTime().isAfter(shopCartMessageOld.getModifiedTime())) { |
146 | 146 | return; |
147 | 147 | } |
148 | + shopCartMessageDto.setModifiedTime(shopCartMessageDto.getCacheTime()==null?LocalDateTime.now():shopCartMessageDto.getCacheTime()); | |
148 | 149 | }else { |
150 | + shopCartMessageDto.setModifiedTime(LocalDateTime.now()); | |
149 | 151 | shopCartMessageDto.setWeight(shopCartMessageDto.getWeight() + shopCartMessageOld.getWeight()); |
150 | 152 | } |
151 | 153 | //小计(分/斤)=单价(分/斤)*重量(克)/500 | ... | ... |