Commit d3937f021f5fd15414d73c842e19a56f0c4b2774
1 parent
2816a4b2
update:多店铺运费只分配第一家
Showing
7 changed files
with
42 additions
and
17 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/api/OrderController.java
... | ... | @@ -100,7 +100,7 @@ public class OrderController { |
100 | 100 | token.delete(); |
101 | 101 | return Message.failure(OrderErrorCode.ORDER_CREATE_FINISH,"订单已创建成功"); |
102 | 102 | } |
103 | - order = orderService.createOrder(buyerOrderDto, OrderOrderType.BUYER_ORDER.getCodeInteger()); | |
103 | + order = orderService.createOrder(buyerOrderDto, OrderOrderType.BUYER_ORDER.getCodeInteger(),true); | |
104 | 104 | token.set(OrderState.WAIT_PAY.getCodeInteger(), Duration.ofSeconds(OrderConstant.TokenOutTimeSecond)); |
105 | 105 | }finally { |
106 | 106 | lock.unlock(); | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/domain/MultipleOrderDto.java
1 | 1 | package com.diligrp.etrade.order.domain; |
2 | 2 | |
3 | +import com.diligrp.etrade.order.util.NumberTransform; | |
3 | 4 | import com.diligrp.etrade.shop.domain.response.ShopVo; |
4 | 5 | import jakarta.validation.Valid; |
5 | 6 | import jakarta.validation.constraints.Min; |
... | ... | @@ -116,6 +117,9 @@ public class MultipleOrderDto { |
116 | 117 | @Valid |
117 | 118 | private OrderDeliveryDto delivery; |
118 | 119 | |
120 | + /** 配送费用 */ | |
121 | + private BigDecimal transportFee = NumberTransform.ZERO; | |
122 | + | |
119 | 123 | public Integer getAchieveType() { |
120 | 124 | return achieveType; |
121 | 125 | } |
... | ... | @@ -349,4 +353,12 @@ public class MultipleOrderDto { |
349 | 353 | public void setDelivery(OrderDeliveryDto delivery) { |
350 | 354 | this.delivery = delivery; |
351 | 355 | } |
356 | + | |
357 | + public BigDecimal getTransportFee() { | |
358 | + return transportFee; | |
359 | + } | |
360 | + | |
361 | + public void setTransportFee(BigDecimal transportFee) { | |
362 | + this.transportFee = transportFee; | |
363 | + } | |
352 | 364 | } | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/domain/OrderCreateDto.java
... | ... | @@ -304,7 +304,7 @@ public class OrderCreateDto{ |
304 | 304 | } |
305 | 305 | |
306 | 306 | public void setTotlePayAmount(BigDecimal totlePayAmount) { |
307 | - this.totlePayAmount = totlePayAmount!=null?totlePayAmount.setScale(2, RoundingMode.HALF_UP):null; | |
307 | + this.totlePayAmount = totlePayAmount!=null?totlePayAmount.setScale(2, RoundingMode.HALF_UP):BigDecimal.ZERO; | |
308 | 308 | } |
309 | 309 | |
310 | 310 | public BigDecimal getTotleDiscount() { |
... | ... | @@ -312,7 +312,7 @@ public class OrderCreateDto{ |
312 | 312 | } |
313 | 313 | |
314 | 314 | public void setTotleDiscount(BigDecimal totleDiscount) { |
315 | - this.totleDiscount = totleDiscount!=null?totleDiscount.setScale(2, RoundingMode.HALF_UP):null; | |
315 | + this.totleDiscount = totleDiscount!=null?totleDiscount.setScale(2, RoundingMode.HALF_UP):BigDecimal.ZERO; | |
316 | 316 | } |
317 | 317 | |
318 | 318 | public BigDecimal getTotleWeight() { |
... | ... | @@ -320,7 +320,7 @@ public class OrderCreateDto{ |
320 | 320 | } |
321 | 321 | |
322 | 322 | public void setTotleWeight(BigDecimal totleWeight) { |
323 | - this.totleWeight = totleWeight!=null?totleWeight.setScale(2, RoundingMode.HALF_UP):null; | |
323 | + this.totleWeight = totleWeight!=null?totleWeight.setScale(2, RoundingMode.HALF_UP):BigDecimal.ZERO; | |
324 | 324 | } |
325 | 325 | |
326 | 326 | public Long getCreaterId() { |
... | ... | @@ -448,6 +448,6 @@ public class OrderCreateDto{ |
448 | 448 | } |
449 | 449 | |
450 | 450 | public void setTransportFee(BigDecimal transportFee) { |
451 | - this.transportFee = transportFee; | |
451 | + this.transportFee = transportFee!=null?transportFee.setScale(2, RoundingMode.HALF_UP):BigDecimal.ZERO; | |
452 | 452 | } |
453 | 453 | } | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/OrderGoodsService.java
... | ... | @@ -27,7 +27,7 @@ public interface OrderGoodsService { |
27 | 27 | * @param buyerOrderDto 入参 |
28 | 28 | * @param orderType 入口类型 |
29 | 29 | */ |
30 | - void checkBuyerOrderDto(OrderCreateDto buyerOrderDto, Integer orderType); | |
30 | + void checkBuyerOrderDto(OrderCreateDto buyerOrderDto, Integer orderType,Boolean transportFeeFlag); | |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * 修改时禁用已经生成的订单商品 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/OrderService.java
... | ... | @@ -19,7 +19,7 @@ public interface OrderService { |
19 | 19 | * @param orderBuyerDto |
20 | 20 | * @param orderType 身份类型 |
21 | 21 | */ |
22 | - Order createOrder(OrderCreateDto orderBuyerDto, Integer orderType); | |
22 | + Order createOrder(OrderCreateDto orderBuyerDto, Integer orderType,Boolean transportFeeFlag); | |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * 创建或更新订单 | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderGoodsServiceImpl.java
... | ... | @@ -102,7 +102,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { |
102 | 102 | } |
103 | 103 | |
104 | 104 | @Override |
105 | - public void checkBuyerOrderDto(OrderCreateDto buyerOrderDto, Integer orderType) { | |
105 | + public void checkBuyerOrderDto(OrderCreateDto buyerOrderDto, Integer orderType,Boolean transportFeeFlag) { | |
106 | 106 | BigDecimal allmount = new BigDecimal(0).setScale(2, RoundingMode.HALF_UP); |
107 | 107 | BigDecimal allWeight = new BigDecimal(0).setScale(2,RoundingMode.HALF_UP); |
108 | 108 | BigDecimal waitCouponAmount = new BigDecimal(0).add(buyerOrderDto.getTotleDiscount()); |
... | ... | @@ -162,12 +162,12 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { |
162 | 162 | } |
163 | 163 | } |
164 | 164 | //配送情况增加计算运费 |
165 | - if(buyerOrderDto.getAchieveType().equals(OrderAchieveType.SELLER_DELIVERY.getCodeInteger())){ | |
165 | + if(buyerOrderDto.getAchieveType().equals(OrderAchieveType.SELLER_DELIVERY.getCodeInteger())&&transportFeeFlag){ | |
166 | 166 | ConfigQueryDto query = new ConfigQueryDto(); |
167 | 167 | query.setName("甄选运费"); |
168 | 168 | query.setMarketId(buyerOrderDto.getMarketId()); |
169 | 169 | BaseOutput<List<ConfigDto>> listBaseOutput = basicDataConfigRpc.queryAll(query); |
170 | - Long transportFee = buyerOrderDto.getTransportFee().longValue()*100; | |
170 | + Long transportFee = buyerOrderDto.getTransportFee().multiply(NumberTransform.ONE_HUNDERD).longValue(); | |
171 | 171 | Long transportFeeConfig = 0L; |
172 | 172 | if("200".equals(listBaseOutput.getCode())){ |
173 | 173 | List<ConfigDto> configDtos = listBaseOutput.getData(); | ... | ... |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderServiceImpl.java
... | ... | @@ -25,7 +25,9 @@ import com.diligrp.etrade.order.util.NumberTransform; |
25 | 25 | import com.diligrp.etrade.rpc.CustomerRpc; |
26 | 26 | import com.diligrp.etrade.rpc.UapRpc; |
27 | 27 | import com.diligrp.etrade.rpc.UidRpc; |
28 | +import com.diligrp.etrade.rpc.basicdata.BasicDataConfigRpc; | |
28 | 29 | import com.diligrp.etrade.rpc.dto.*; |
30 | +import com.diligrp.etrade.rpc.dto.request.ConfigQueryDto; | |
29 | 31 | import com.diligrp.etrade.rpc.dto.response.*; |
30 | 32 | import com.diligrp.etrade.rpc.resolver.PayRpcResolver; |
31 | 33 | import com.diligrp.etrade.rpc.dto.response.BalanceResponseDto; |
... | ... | @@ -118,9 +120,12 @@ public class OrderServiceImpl implements OrderService { |
118 | 120 | @Resource |
119 | 121 | private OrderDeliveryService orderDeliveryService; |
120 | 122 | |
123 | + @Resource | |
124 | + private BasicDataConfigRpc basicDataConfigRpc; | |
125 | + | |
121 | 126 | @Transactional |
122 | 127 | @Override |
123 | - public Order createOrder(OrderCreateDto orderCreateDto, Integer orderType) { | |
128 | + public Order createOrder(OrderCreateDto orderCreateDto, Integer orderType,Boolean transportFeeFlag) { | |
124 | 129 | //效验店铺状态 |
125 | 130 | ShopVo shop = orderGoodsService.checkShop(orderCreateDto.getShopId()); |
126 | 131 | //效验买方状态 |
... | ... | @@ -133,7 +138,7 @@ public class OrderServiceImpl implements OrderService { |
133 | 138 | orderCreateDto.setShopName(shop.getName()); |
134 | 139 | orderCreateDto.setShopCustomerName(shop.getCustomerName()); |
135 | 140 | //验证订单商品总重量与订单商品总价格 |
136 | - orderGoodsService.checkBuyerOrderDto(orderCreateDto,orderType); | |
141 | + orderGoodsService.checkBuyerOrderDto(orderCreateDto,orderType,transportFeeFlag); | |
137 | 142 | //创建订单 |
138 | 143 | Order order = new Order(); |
139 | 144 | orderCreateDto.setShop(shop); |
... | ... | @@ -177,7 +182,7 @@ public class OrderServiceImpl implements OrderService { |
177 | 182 | orderCreateDto.setShopName(shop.getName()); |
178 | 183 | orderCreateDto.setShopCustomerName(shop.getCustomerName()); |
179 | 184 | //验证订单商品总重量与订单商品总价格 |
180 | - orderGoodsService.checkBuyerOrderDto(orderCreateDto,identityType); | |
185 | + orderGoodsService.checkBuyerOrderDto(orderCreateDto,identityType,true); | |
181 | 186 | //创建订单 |
182 | 187 | Order order = new Order(); |
183 | 188 | orderCreateDto.setShop(shop); |
... | ... | @@ -410,7 +415,7 @@ public class OrderServiceImpl implements OrderService { |
410 | 415 | @Override |
411 | 416 | public void updateOrder(OrderCreateDto buyerOrderDto, Integer orderType) { |
412 | 417 | //验证订单商品总重量与订单商品总价格 |
413 | - orderGoodsService.checkBuyerOrderDto(buyerOrderDto,orderType); | |
418 | + orderGoodsService.checkBuyerOrderDto(buyerOrderDto,orderType,true); | |
414 | 419 | //获取原始订单 |
415 | 420 | Order order = getOrderAndCheckState(null, buyerOrderDto.getCode(), buyerOrderDto.getMarketId(),OrderOrderState.SELLER_FIX,buyerOrderDto); |
416 | 421 | //判断修改人 |
... | ... | @@ -442,7 +447,7 @@ public class OrderServiceImpl implements OrderService { |
442 | 447 | //获取订单并效验状态 |
443 | 448 | Order order = getOrderAndCheckState(null, buyerOrderDto.getCode(), buyerOrderDto.getMarketId(),OrderOrderState.SELLER_FIX,buyerOrderDto); |
444 | 449 | //验证订单商品总重量与订单商品总价格 |
445 | - orderGoodsService.checkBuyerOrderDto(buyerOrderDto,orderType); | |
450 | + orderGoodsService.checkBuyerOrderDto(buyerOrderDto,orderType,true); | |
446 | 451 | //判断卖方修改人是否有权限修改订单 |
447 | 452 | if(buyerOrderDto.getModifierId() == null || StrUtil.isEmpty(buyerOrderDto.getModifier())){ |
448 | 453 | throw new OrderException(OrderErrorCode.PARAM_ERROR,"订单修改人信息未传"); |
... | ... | @@ -1381,9 +1386,17 @@ public class OrderServiceImpl implements OrderService { |
1381 | 1386 | public List<Order> createMultipleOrder(MultipleOrderDto multipleOrderDto, Integer codeInteger) { |
1382 | 1387 | List<Order> orders = new ArrayList<>(); |
1383 | 1388 | Map<Long,OrderCreateDto> orderCreateDtos = buildOrdersDto(multipleOrderDto); |
1389 | + boolean first = true; | |
1384 | 1390 | for(Long shopId :orderCreateDtos.keySet()){ |
1385 | - Order order = this.createOrder(orderCreateDtos.get(shopId), OrderOrderType.BUYER_ORDER.getCodeInteger()); | |
1386 | - orders.add(order); | |
1391 | + if(first){ | |
1392 | + first = false; | |
1393 | + orderCreateDtos.get(shopId).setTransportFee(multipleOrderDto.getTransportFee()); | |
1394 | + Order order = this.createOrder(orderCreateDtos.get(shopId), OrderOrderType.BUYER_ORDER.getCodeInteger(),true); | |
1395 | + orders.add(order); | |
1396 | + }else{ | |
1397 | + Order order = this.createOrder(orderCreateDtos.get(shopId), OrderOrderType.BUYER_ORDER.getCodeInteger(),false); | |
1398 | + orders.add(order); | |
1399 | + } | |
1387 | 1400 | } |
1388 | 1401 | return orders; |
1389 | 1402 | } | ... | ... |