Commit 2fbb0ddfad64a946d474d4e7b0c565f8ac41c31b

Authored by fengliang
1 parent c49907f0

update:购物车冗余商品图片以及商品名称。

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