Commit 2fbb0ddfad64a946d474d4e7b0c565f8ac41c31b
1 parent
c49907f0
update:购物车冗余商品图片以及商品名称。
Showing
7 changed files
with
42 additions
and
13 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/api/ShopCartApi.java
... | ... | @@ -74,7 +74,7 @@ public class ShopCartApi { |
74 | 74 | throw new OrderException(OrderErrorCode.PARAM_ERROR,"重复提交"); |
75 | 75 | } |
76 | 76 | bucket.set(1, Duration.ofSeconds(1)); |
77 | - shopCartService.saveShopCart(shopCartDto,false); | |
77 | + shopCartService.saveShopCart(shopCartDto,true); | |
78 | 78 | return Message.success(); |
79 | 79 | }finally { |
80 | 80 | lock.unlock(); | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/domain/ShopCartMessageDto.java
... | ... | @@ -93,6 +93,9 @@ public class ShopCartMessageDto implements Serializable { |
93 | 93 | private Integer checkFlag; |
94 | 94 | /** 商品图片 */ |
95 | 95 | private String productUrl; |
96 | + | |
97 | + /** 商品图片 */ | |
98 | + private String url; | |
96 | 99 | /** 商品名称 */ |
97 | 100 | private String productName; |
98 | 101 | |
... | ... | @@ -230,4 +233,12 @@ public class ShopCartMessageDto implements Serializable { |
230 | 233 | public void setProductName(String productName) { |
231 | 234 | this.productName = productName; |
232 | 235 | } |
236 | + | |
237 | + public String getUrl() { | |
238 | + return url; | |
239 | + } | |
240 | + | |
241 | + public void setUrl(String url) { | |
242 | + this.url = url; | |
243 | + } | |
233 | 244 | } | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/IShopCartMessageService.java
... | ... | @@ -16,7 +16,7 @@ public interface IShopCartMessageService { |
16 | 16 | |
17 | 17 | void updateShopCartMessage(ShopCartMessageDto shopCartMessageDto); |
18 | 18 | |
19 | - void updateByOld(ShopCartMessage shopCartMessageOld,ShopCartMessageDto shopCartMessageDto,Boolean bo,boolean checkflag); | |
19 | + void updateByOld(ShopCartMessage shopCartMessageOld,ShopCartMessageDto shopCartMessageDto,Boolean bo); | |
20 | 20 | |
21 | 21 | List<ShopCartMessage> findList(ShopCartMessageDto shopCartMessageDto); |
22 | 22 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
... | ... | @@ -21,6 +21,7 @@ import com.diligrp.etrade.shop.domain.response.ProductPresetVo; |
21 | 21 | import com.diligrp.etrade.shop.domain.response.ShopVo; |
22 | 22 | import com.diligrp.etrade.shop.service.ProductService; |
23 | 23 | import com.diligrp.etrade.shop.service.ShopService; |
24 | +import org.apache.commons.lang3.StringUtils; | |
24 | 25 | import org.springframework.beans.BeanUtils; |
25 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
26 | 27 | import org.springframework.stereotype.Service; |
... | ... | @@ -130,8 +131,6 @@ public class ShopCartImpl implements IShopCartService { |
130 | 131 | // AssertUtils.notNull(productPresetVo, |
131 | 132 | // "未找到商品按件卖的预售价格,productId:"+shopCartMessageVo.getProductId()+"SaleUnitType:"+SaleUnitType.PIECE.getCode()); |
132 | 133 | if(productPresetVo == null){ |
133 | - shopCartMessageVo.setPrePrice(0L); | |
134 | - shopCartMessageVo.setPieceWeight(0L); | |
135 | 134 | shopCartMessageVo.setProductState(ShopCartMessageProductState.TYPE_CHANGE.getCodeInteger()); |
136 | 135 | }else{ |
137 | 136 | shopCartMessageVo.setProductState(ShopCartMessageProductState.NORMAL.getCodeInteger()); |
... | ... | @@ -139,9 +138,12 @@ public class ShopCartImpl implements IShopCartService { |
139 | 138 | shopCartMessageVo.setSaleUnit(productPresetVo.getSaleUnit()); |
140 | 139 | //预设价格分 |
141 | 140 | shopCartMessageVo.setPrePrice(productPresetVo.getPrePrice() == null ? 0L : productPresetVo.getPrePrice()); |
141 | + shopCartMessageVo.setUnitAmount(productPresetVo.getPrePrice() == null ? 0L : productPresetVo.getPrePrice()); | |
142 | 142 | //预设件重克 |
143 | 143 | shopCartMessageVo.setPieceWeight(productPresetVo.getPieceWeight()); |
144 | 144 | } |
145 | + }else{ | |
146 | + shopCartMessageVo.setProductState(ShopCartMessageProductState.NONE.getCodeInteger()); | |
145 | 147 | } |
146 | 148 | }); |
147 | 149 | //对购物车商品信息集合按修改时间倒序排序 |
... | ... | @@ -189,10 +191,12 @@ public class ShopCartImpl implements IShopCartService { |
189 | 191 | int in = shopCartMapper.insertSelective(shopCart); |
190 | 192 | Assert.isTrue(in > 0, "购物车添加失败"); |
191 | 193 | shopCartMessageDto.setShopCartId(shopCart.getId()); |
192 | - shopCartMessageDto.setCheckFlag(ShopCartMessageCheckFlag.CHECK.getCodeInteger()); | |
193 | 194 | shopCartMessageService.saveShopCartMessage(shopCartMessageDto); |
194 | 195 | return; |
195 | 196 | } |
197 | + if(checkflag){ | |
198 | + shopCartMessageDto.setCheckFlag(ShopCartMessageCheckFlag.CHECK.getCodeInteger()); | |
199 | + } | |
196 | 200 | //店铺信息存在,判断商品信息是否存在 |
197 | 201 | ShopCart shopCartQuery = shopCarts.get(0); |
198 | 202 | shopCart.setVersion(shopCartQuery.getVersion()); |
... | ... | @@ -220,7 +224,7 @@ public class ShopCartImpl implements IShopCartService { |
220 | 224 | } |
221 | 225 | //存在相同商品信息,对商品信息进行更新操作 |
222 | 226 | ShopCartMessage shopCartMessageOld = shopCartMessages.get(0); |
223 | - shopCartMessageService.updateByOld(shopCartMessageOld, shopCartDto.getShopCartMessageDto(),shopCartDto.getBo(),checkflag); | |
227 | + shopCartMessageService.updateByOld(shopCartMessageOld, shopCartDto.getShopCartMessageDto(),shopCartDto.getBo()); | |
224 | 228 | } |
225 | 229 | |
226 | 230 | |
... | ... | @@ -234,10 +238,13 @@ public class ShopCartImpl implements IShopCartService { |
234 | 238 | ShopCartDto shopCartDto = new ShopCartDto(); |
235 | 239 | BeanUtils.copyProperties(shopCartCacheDto, shopCartDto); |
236 | 240 | shopCartMessageDto.setMarketId(shopCartCacheDto.getMarketId()); |
241 | + if(StringUtils.isBlank(shopCartMessageDto.getProductUrl())){ | |
242 | + shopCartMessageDto.setProductUrl(shopCartMessageDto.getUrl()); | |
243 | + } | |
237 | 244 | shopCartDto.setShopCartMessageDto(shopCartMessageDto); |
238 | 245 | return shopCartDto; |
239 | 246 | }).toList(); |
240 | - shopCartDtos.forEach(item ->saveShopCart(item,true)); | |
247 | + shopCartDtos.forEach(item ->saveShopCart(item,false)); | |
241 | 248 | } |
242 | 249 | }); |
243 | 250 | } | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartMessageServiceImpl.java
... | ... | @@ -130,16 +130,14 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
130 | 130 | */ |
131 | 131 | @Transactional |
132 | 132 | @Override |
133 | - public void updateByOld(ShopCartMessage shopCartMessageOld, ShopCartMessageDto shopCartMessageDto, Boolean bo,boolean checkflag) { | |
133 | + public void updateByOld(ShopCartMessage shopCartMessageOld, ShopCartMessageDto shopCartMessageDto, Boolean bo) { | |
134 | 134 | AssertUtils.notNull(shopCartMessageOld, "历史购物车商品信息不为空"); |
135 | 135 | AssertUtils.notNull(shopCartMessageDto, "新增购物车商品信息不为空"); |
136 | 136 | //获取历史购物车商品 |
137 | - AssertUtils.isTrue(shopCartMessageOld.getType().equals(shopCartMessageDto.getType()), "历史购物车商品信息与新增购物车商品信息卖货方式不同"); | |
137 | + //AssertUtils.isTrue(shopCartMessageOld.getType().equals(shopCartMessageDto.getType()), "历史购物车商品信息与新增购物车商品信息卖货方式不同"); | |
138 | 138 | shopCartMessageDto.setId(shopCartMessageOld.getId()); |
139 | 139 | shopCartMessageDto.setVersion(shopCartMessageOld.getVersion()); |
140 | - if(checkflag){ | |
141 | - shopCartMessageDto.setCheckFlag(shopCartMessageDto.getCheckFlag()); | |
142 | - } | |
140 | + | |
143 | 141 | //如果是处理离线缓存数据,bo=true,总重量做覆盖,不是处理离线数据,总重量做增量 |
144 | 142 | if (bo) { |
145 | 143 | //如果缓存时间在更新之前之前,说明缓存数据不是最新数据,则不进行更新操作 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/util/ShopCartCheckOut.java
... | ... | @@ -3,6 +3,7 @@ package com.diligrp.etrade.order.util; |
3 | 3 | import com.diligrp.etrade.core.util.AssertUtils; |
4 | 4 | import com.diligrp.etrade.order.domain.ShopCartDto; |
5 | 5 | import com.diligrp.etrade.order.domain.ShopCartMessageDto; |
6 | +import org.apache.commons.lang3.StringUtils; | |
6 | 7 | import org.springframework.util.Assert; |
7 | 8 | import org.springframework.util.CollectionUtils; |
8 | 9 | |
... | ... | @@ -52,6 +53,10 @@ public class ShopCartCheckOut { |
52 | 53 | AssertUtils.notNull(shopCartMessageDto.getType(), "新增购物车入参:卖货方式不为空"); |
53 | 54 | checkOutAmount(shopCartMessageDto.getUnitAmount()); |
54 | 55 | checkOutWeight(shopCartMessageDto.getWeight()); |
56 | + //参数转换 | |
57 | + if(StringUtils.isBlank(shopCartMessageDto.getProductUrl())){ | |
58 | + shopCartMessageDto.setProductUrl(shopCartMessageDto.getUrl()); | |
59 | + } | |
55 | 60 | } |
56 | 61 | /** |
57 | 62 | *更新购物车入参校验 | ... | ... |
etrade-order/src/main/resources/com/diligrp/etrade/dao/mapper/shopCart/ShopCartMapper.xml
... | ... | @@ -30,6 +30,10 @@ |
30 | 30 | <result column="type" jdbcType="TINYINT" property="type"/> |
31 | 31 | <result column="scm_modified_time" jdbcType="TIMESTAMP" property="modifiedTime"/> |
32 | 32 | <result column="check_flag" jdbcType="TINYINT" property="checkFlag"/> |
33 | + <result column="alias" jdbcType="VARCHAR" property="alias"/> | |
34 | + <result column="product_name" jdbcType="VARCHAR" property="productName"/> | |
35 | + <result column="product_name" jdbcType="VARCHAR" property="productName"/> | |
36 | + <result column="prePrice" jdbcType="BIGINT" property="prePrice"/> | |
33 | 37 | </collection> |
34 | 38 | </resultMap> |
35 | 39 | |
... | ... | @@ -56,12 +60,16 @@ |
56 | 60 | scm.product_id, |
57 | 61 | scm.number, |
58 | 62 | scm.unit_amount, |
63 | + scm.unit_amount as prePrice, | |
59 | 64 | scm.unit_weight, |
60 | 65 | scm.weight, |
61 | 66 | scm.amount, |
62 | 67 | scm.type, |
63 | 68 | scm.modified_time as scm_modified_time, |
64 | - scm.check_flag as check_flag | |
69 | + scm.check_flag as check_flag, | |
70 | + scm.product_url as url, | |
71 | + scm.product_name as product_name, | |
72 | + scm.product_name as alias | |
65 | 73 | from shop_cart s |
66 | 74 | left join shop_cart_message scm |
67 | 75 | on s.id = scm.shop_cart_id | ... | ... |