Commit 6de38ca7e33c9eee53e3d8550666ec0349acc3ad
1 parent
efbc08cb
update:修改购物车商品添加的类型
Showing
3 changed files
with
15 additions
and
76 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
... | ... | @@ -14,7 +14,6 @@ import com.diligrp.etrade.order.model.ShopCart; |
14 | 14 | import com.diligrp.etrade.order.model.ShopCartMessage; |
15 | 15 | import com.diligrp.etrade.order.service.IShopCartMessageService; |
16 | 16 | import com.diligrp.etrade.order.service.IShopCartService; |
17 | -import com.diligrp.etrade.order.type.ProductTradeType; | |
18 | 17 | import com.diligrp.etrade.order.type.ShopCartMessageProductState; |
19 | 18 | import com.diligrp.etrade.shop.domain.response.ProductListVo; |
20 | 19 | import com.diligrp.etrade.shop.domain.response.ProductPresetVo; |
... | ... | @@ -174,17 +173,10 @@ public class ShopCartImpl implements IShopCartService { |
174 | 173 | //构建商品信息 |
175 | 174 | shopCartMessageDto.setCreater(shopCartDto.getCustomerName()); |
176 | 175 | Long unitAmount = shopCartMessageDto.getUnitAmount(); |
177 | - //按件卖,计算合计 单价*(件数的100倍/100) | |
178 | - if (ProductTradeType.PIECES_TYPE.getCodeInteger().equals(shopCartMessageDto.getType())) { | |
179 | - Long number = shopCartMessageDto.getNumber(); | |
180 | - Long amount = MoneyUtil.getAmountByNumber(unitAmount, number); | |
181 | - shopCartMessageDto.setAmount(amount); | |
182 | - } else { | |
183 | - //按斤卖 小计=单价(分/斤)*重量(克)/500 | |
184 | - Long weight = shopCartMessageDto.getWeight(); | |
185 | - Long amount = MoneyUtil.getAmountByWeight(unitAmount, weight); | |
186 | - shopCartMessageDto.setAmount(amount); | |
187 | - } | |
176 | + //按单位卖 小计=单价(分/斤)*重量(克)/500 | |
177 | + Long weight = shopCartMessageDto.getWeight(); | |
178 | + Long amount = MoneyUtil.getAmountByWeight(unitAmount, weight); | |
179 | + shopCartMessageDto.setAmount(amount); | |
188 | 180 | |
189 | 181 | //没有店铺信息,则对购物车与购物车商品信息进行新增操作 |
190 | 182 | if (CollectionUtils.isEmpty(shopCarts)) { | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartMessageServiceImpl.java
... | ... | @@ -7,7 +7,6 @@ import com.diligrp.etrade.order.domain.ShopCartDto; |
7 | 7 | import com.diligrp.etrade.order.domain.ShopCartMessageDto; |
8 | 8 | import com.diligrp.etrade.order.model.ShopCartMessage; |
9 | 9 | import com.diligrp.etrade.order.service.IShopCartMessageService; |
10 | -import com.diligrp.etrade.order.type.ProductTradeType; | |
11 | 10 | import jakarta.annotation.Resource; |
12 | 11 | import org.springframework.beans.BeanUtils; |
13 | 12 | import org.springframework.stereotype.Service; |
... | ... | @@ -60,17 +59,8 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
60 | 59 | AssertUtils.notNull(shopCartMessageDto, "购物车商品不为空"); |
61 | 60 | ShopCartMessage shopCartMessage = new ShopCartMessage(); |
62 | 61 | BeanUtils.copyProperties(shopCartMessageDto, shopCartMessage); |
63 | - //组装小计 | |
64 | - //按件卖时,小计=单价*件重100倍/100 | |
65 | - if (ProductTradeType.PIECES_TYPE.getCodeInteger().equals(shopCartMessage.getType())) { | |
66 | - Long amount = MoneyUtil.getAmountByNumber(shopCartMessage.getUnitAmount(), shopCartMessage.getNumber()); | |
67 | - shopCartMessage.setAmount(amount); | |
68 | - } | |
69 | - //按斤卖时,小计=单价*总重(克)/500 | |
70 | - if (ProductTradeType.WEIGHT_TYPE.getCodeInteger().equals(shopCartMessage.getType())) { | |
71 | - Long amount = MoneyUtil.getAmountByWeight(shopCartMessage.getUnitAmount(), shopCartMessage.getWeight()); | |
72 | - shopCartMessage.setAmount(amount); | |
73 | - } | |
62 | + Long amount = MoneyUtil.getAmountByWeight(shopCartMessage.getUnitAmount(), shopCartMessage.getWeight()); | |
63 | + shopCartMessage.setAmount(amount); | |
74 | 64 | int i = shopCartMessageMapper.insertSelective(shopCartMessage); |
75 | 65 | AssertUtils.isTrue(i > 0, "商品信息存储失败"); |
76 | 66 | } |
... | ... | @@ -108,23 +98,11 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
108 | 98 | ShopCartMessage shopCartMessage = shopCartMessageList.get(0); |
109 | 99 | ShopCartMessageDto shopCartMessageDtoNew = new ShopCartMessageDto(); |
110 | 100 | BeanUtils.copyProperties(shopCartMessage, shopCartMessageDtoNew); |
111 | - //按件卖 | |
112 | - if (ProductTradeType.PIECES_TYPE.getCodeInteger().equals(shopCartMessageDto.getType())) { | |
113 | - Long number = shopCartMessageDto.getNumber() + shopCartMessage.getNumber(); | |
114 | - Long amount = MoneyUtil.getAmountByNumber(shopCartMessageDto.getUnitAmount(), number); | |
115 | - shopCartMessageDtoNew.setAmount(amount); | |
116 | - shopCartMessageDtoNew.setUnitAmount(shopCartMessageDto.getUnitAmount()); | |
117 | - shopCartMessageDtoNew.setNumber(number); | |
118 | - shopCartMessageDtoNew.setUnitWeight(shopCartMessageDto.getUnitWeight()); | |
119 | - } | |
120 | - //按斤卖时,小计(分/斤)=单价(分/斤)*总重(克)/500 | |
121 | - if (ProductTradeType.WEIGHT_TYPE.getCodeInteger().equals(shopCartMessageDto.getType())) { | |
122 | - Long weight = shopCartMessageDto.getWeight() + shopCartMessage.getWeight(); | |
123 | - Long amount = MoneyUtil.getAmountByWeight(shopCartMessageDto.getUnitAmount(), weight); | |
124 | - shopCartMessageDtoNew.setAmount(amount); | |
125 | - shopCartMessageDtoNew.setWeight(weight); | |
126 | - shopCartMessageDtoNew.setUnitAmount(shopCartMessageDto.getUnitAmount()); | |
127 | - } | |
101 | + Long weight = shopCartMessageDto.getWeight() + shopCartMessage.getWeight(); | |
102 | + Long amount = MoneyUtil.getAmountByWeight(shopCartMessageDto.getUnitAmount(), weight); | |
103 | + shopCartMessageDtoNew.setAmount(amount); | |
104 | + shopCartMessageDtoNew.setWeight(weight); | |
105 | + shopCartMessageDtoNew.setUnitAmount(shopCartMessageDto.getUnitAmount()); | |
128 | 106 | int i = shopCartMessageMapper.updateByPrimaryKeySelective(shopCartMessageDtoNew); |
129 | 107 | int j = shopCartMessageMapper.deleteByPrimaryKey(shopCartMessageQuery.getId()); |
130 | 108 | AssertUtils.isTrue(i > 0 && j > 0, "商品信息更新失败"); |
... | ... | @@ -136,19 +114,10 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
136 | 114 | * @author wujunrui |
137 | 115 | */ |
138 | 116 | public void updateShopCartMessageOne(ShopCartMessageDto shopCartMessageDto) { |
139 | - //按件卖时,小计(分/件)=单价(分/件)*件数(100倍件数)/100 | |
140 | - if (ProductTradeType.PIECES_TYPE.getCodeInteger().equals(shopCartMessageDto.getType())) { | |
141 | - Long amount = MoneyUtil.getAmountByNumber(shopCartMessageDto.getUnitAmount(), shopCartMessageDto.getNumber()); | |
142 | - shopCartMessageDto.setAmount(amount); | |
143 | - shopCartMessageDto.setWeight(0L); | |
144 | - } | |
145 | - //按斤卖时,小计(分/斤)=单价(分/斤)*总重(克)/500 | |
146 | - if (ProductTradeType.WEIGHT_TYPE.getCodeInteger().equals(shopCartMessageDto.getType())) { | |
147 | - Long amount = MoneyUtil.getAmountByWeight(shopCartMessageDto.getUnitAmount(), shopCartMessageDto.getWeight()); | |
148 | - shopCartMessageDto.setAmount(amount); | |
149 | - shopCartMessageDto.setUnitWeight(0L); | |
150 | - shopCartMessageDto.setNumber(0L); | |
151 | - } | |
117 | + Long amount = MoneyUtil.getAmountByWeight(shopCartMessageDto.getUnitAmount(), shopCartMessageDto.getWeight()); | |
118 | + shopCartMessageDto.setAmount(amount); | |
119 | + shopCartMessageDto.setUnitWeight(0L); | |
120 | + shopCartMessageDto.setNumber(0L); | |
152 | 121 | int i = shopCartMessageMapper.updateByPrimaryKeySelective(shopCartMessageDto); |
153 | 122 | AssertUtils.isTrue(i > 0, "商品信息更新失败"); |
154 | 123 | } |
... | ... | @@ -168,27 +137,6 @@ public class ShopCartMessageServiceImpl implements IShopCartMessageService { |
168 | 137 | AssertUtils.isTrue(shopCartMessageOld.getType().equals(shopCartMessageDto.getType()), "历史购物车商品信息与新增购物车商品信息卖货方式不同"); |
169 | 138 | shopCartMessageDto.setId(shopCartMessageOld.getId()); |
170 | 139 | shopCartMessageDto.setVersion(shopCartMessageOld.getVersion()); |
171 | - //按件卖 | |
172 | - if (ProductTradeType.PIECES_TYPE.getCodeInteger().equals(shopCartMessageOld.getType())) { | |
173 | - //如果是处理离线缓存数据,bo=true,件数做覆盖,如果不是处理离线数据,件数做增量 | |
174 | - | |
175 | - if (bo) { | |
176 | - //如果缓存时间在更新之前之前,说明缓存数据不是最新数据,则不进行更新操作 | |
177 | - if (shopCartMessageDto.getCacheTime().isBefore(shopCartMessageOld.getModifiedTime())) { | |
178 | - return; | |
179 | - } | |
180 | - }else { | |
181 | - //件数做增量 | |
182 | - shopCartMessageDto.setNumber(shopCartMessageDto.getNumber() + shopCartMessageOld.getNumber()); | |
183 | - } | |
184 | - //小计(因件数扩大了100倍,金额需/100) | |
185 | - Long amount = MoneyUtil.getAmountByNumber(shopCartMessageDto.getUnitAmount(), shopCartMessageDto.getNumber()); | |
186 | - shopCartMessageDto.setAmount(amount); | |
187 | - int i = shopCartMessageMapper.updateByPrimaryKeySelective(shopCartMessageDto); | |
188 | - AssertUtils.isTrue(i > 0, "更新购物车商品信息失败"); | |
189 | - return; | |
190 | - } | |
191 | - //按重量卖 | |
192 | 140 | //如果是处理离线缓存数据,bo=true,总重量做覆盖,不是处理离线数据,总重量做增量 |
193 | 141 | if (bo) { |
194 | 142 | //如果缓存时间在更新之前之前,说明缓存数据不是最新数据,则不进行更新操作 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/util/ShopCartCheckOut.java
... | ... | @@ -3,7 +3,6 @@ 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 com.diligrp.etrade.order.type.ProductTradeType; | |
7 | 6 | import org.springframework.util.Assert; |
8 | 7 | import org.springframework.util.CollectionUtils; |
9 | 8 | ... | ... |