Commit d3937f021f5fd15414d73c842e19a56f0c4b2774

Authored by fengliang
1 parent 2816a4b2

update:多店铺运费只分配第一家

etrade-order/src/main/java/com/diligrp/etrade/order/api/OrderController.java
@@ -100,7 +100,7 @@ public class OrderController { @@ -100,7 +100,7 @@ public class OrderController {
100 token.delete(); 100 token.delete();
101 return Message.failure(OrderErrorCode.ORDER_CREATE_FINISH,"订单已创建成功"); 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 token.set(OrderState.WAIT_PAY.getCodeInteger(), Duration.ofSeconds(OrderConstant.TokenOutTimeSecond)); 104 token.set(OrderState.WAIT_PAY.getCodeInteger(), Duration.ofSeconds(OrderConstant.TokenOutTimeSecond));
105 }finally { 105 }finally {
106 lock.unlock(); 106 lock.unlock();
etrade-order/src/main/java/com/diligrp/etrade/order/domain/MultipleOrderDto.java
1 package com.diligrp.etrade.order.domain; 1 package com.diligrp.etrade.order.domain;
2 2
  3 +import com.diligrp.etrade.order.util.NumberTransform;
3 import com.diligrp.etrade.shop.domain.response.ShopVo; 4 import com.diligrp.etrade.shop.domain.response.ShopVo;
4 import jakarta.validation.Valid; 5 import jakarta.validation.Valid;
5 import jakarta.validation.constraints.Min; 6 import jakarta.validation.constraints.Min;
@@ -116,6 +117,9 @@ public class MultipleOrderDto { @@ -116,6 +117,9 @@ public class MultipleOrderDto {
116 @Valid 117 @Valid
117 private OrderDeliveryDto delivery; 118 private OrderDeliveryDto delivery;
118 119
  120 + /** 配送费用 */
  121 + private BigDecimal transportFee = NumberTransform.ZERO;
  122 +
119 public Integer getAchieveType() { 123 public Integer getAchieveType() {
120 return achieveType; 124 return achieveType;
121 } 125 }
@@ -349,4 +353,12 @@ public class MultipleOrderDto { @@ -349,4 +353,12 @@ public class MultipleOrderDto {
349 public void setDelivery(OrderDeliveryDto delivery) { 353 public void setDelivery(OrderDeliveryDto delivery) {
350 this.delivery = delivery; 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,7 +304,7 @@ public class OrderCreateDto{
304 } 304 }
305 305
306 public void setTotlePayAmount(BigDecimal totlePayAmount) { 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 public BigDecimal getTotleDiscount() { 310 public BigDecimal getTotleDiscount() {
@@ -312,7 +312,7 @@ public class OrderCreateDto{ @@ -312,7 +312,7 @@ public class OrderCreateDto{
312 } 312 }
313 313
314 public void setTotleDiscount(BigDecimal totleDiscount) { 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 public BigDecimal getTotleWeight() { 318 public BigDecimal getTotleWeight() {
@@ -320,7 +320,7 @@ public class OrderCreateDto{ @@ -320,7 +320,7 @@ public class OrderCreateDto{
320 } 320 }
321 321
322 public void setTotleWeight(BigDecimal totleWeight) { 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 public Long getCreaterId() { 326 public Long getCreaterId() {
@@ -448,6 +448,6 @@ public class OrderCreateDto{ @@ -448,6 +448,6 @@ public class OrderCreateDto{
448 } 448 }
449 449
450 public void setTransportFee(BigDecimal transportFee) { 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,7 +27,7 @@ public interface OrderGoodsService {
27 * @param buyerOrderDto 入参 27 * @param buyerOrderDto 入参
28 * @param orderType 入口类型 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,7 +19,7 @@ public interface OrderService {
19 * @param orderBuyerDto 19 * @param orderBuyerDto
20 * @param orderType 身份类型 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,7 +102,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
102 } 102 }
103 103
104 @Override 104 @Override
105 - public void checkBuyerOrderDto(OrderCreateDto buyerOrderDto, Integer orderType) { 105 + public void checkBuyerOrderDto(OrderCreateDto buyerOrderDto, Integer orderType,Boolean transportFeeFlag) {
106 BigDecimal allmount = new BigDecimal(0).setScale(2, RoundingMode.HALF_UP); 106 BigDecimal allmount = new BigDecimal(0).setScale(2, RoundingMode.HALF_UP);
107 BigDecimal allWeight = new BigDecimal(0).setScale(2,RoundingMode.HALF_UP); 107 BigDecimal allWeight = new BigDecimal(0).setScale(2,RoundingMode.HALF_UP);
108 BigDecimal waitCouponAmount = new BigDecimal(0).add(buyerOrderDto.getTotleDiscount()); 108 BigDecimal waitCouponAmount = new BigDecimal(0).add(buyerOrderDto.getTotleDiscount());
@@ -162,12 +162,12 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { @@ -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 ConfigQueryDto query = new ConfigQueryDto(); 166 ConfigQueryDto query = new ConfigQueryDto();
167 query.setName("甄选运费"); 167 query.setName("甄选运费");
168 query.setMarketId(buyerOrderDto.getMarketId()); 168 query.setMarketId(buyerOrderDto.getMarketId());
169 BaseOutput<List<ConfigDto>> listBaseOutput = basicDataConfigRpc.queryAll(query); 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 Long transportFeeConfig = 0L; 171 Long transportFeeConfig = 0L;
172 if("200".equals(listBaseOutput.getCode())){ 172 if("200".equals(listBaseOutput.getCode())){
173 List<ConfigDto> configDtos = listBaseOutput.getData(); 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,7 +25,9 @@ import com.diligrp.etrade.order.util.NumberTransform;
25 import com.diligrp.etrade.rpc.CustomerRpc; 25 import com.diligrp.etrade.rpc.CustomerRpc;
26 import com.diligrp.etrade.rpc.UapRpc; 26 import com.diligrp.etrade.rpc.UapRpc;
27 import com.diligrp.etrade.rpc.UidRpc; 27 import com.diligrp.etrade.rpc.UidRpc;
  28 +import com.diligrp.etrade.rpc.basicdata.BasicDataConfigRpc;
28 import com.diligrp.etrade.rpc.dto.*; 29 import com.diligrp.etrade.rpc.dto.*;
  30 +import com.diligrp.etrade.rpc.dto.request.ConfigQueryDto;
29 import com.diligrp.etrade.rpc.dto.response.*; 31 import com.diligrp.etrade.rpc.dto.response.*;
30 import com.diligrp.etrade.rpc.resolver.PayRpcResolver; 32 import com.diligrp.etrade.rpc.resolver.PayRpcResolver;
31 import com.diligrp.etrade.rpc.dto.response.BalanceResponseDto; 33 import com.diligrp.etrade.rpc.dto.response.BalanceResponseDto;
@@ -118,9 +120,12 @@ public class OrderServiceImpl implements OrderService { @@ -118,9 +120,12 @@ public class OrderServiceImpl implements OrderService {
118 @Resource 120 @Resource
119 private OrderDeliveryService orderDeliveryService; 121 private OrderDeliveryService orderDeliveryService;
120 122
  123 + @Resource
  124 + private BasicDataConfigRpc basicDataConfigRpc;
  125 +
121 @Transactional 126 @Transactional
122 @Override 127 @Override
123 - public Order createOrder(OrderCreateDto orderCreateDto, Integer orderType) { 128 + public Order createOrder(OrderCreateDto orderCreateDto, Integer orderType,Boolean transportFeeFlag) {
124 //效验店铺状态 129 //效验店铺状态
125 ShopVo shop = orderGoodsService.checkShop(orderCreateDto.getShopId()); 130 ShopVo shop = orderGoodsService.checkShop(orderCreateDto.getShopId());
126 //效验买方状态 131 //效验买方状态
@@ -133,7 +138,7 @@ public class OrderServiceImpl implements OrderService { @@ -133,7 +138,7 @@ public class OrderServiceImpl implements OrderService {
133 orderCreateDto.setShopName(shop.getName()); 138 orderCreateDto.setShopName(shop.getName());
134 orderCreateDto.setShopCustomerName(shop.getCustomerName()); 139 orderCreateDto.setShopCustomerName(shop.getCustomerName());
135 //验证订单商品总重量与订单商品总价格 140 //验证订单商品总重量与订单商品总价格
136 - orderGoodsService.checkBuyerOrderDto(orderCreateDto,orderType); 141 + orderGoodsService.checkBuyerOrderDto(orderCreateDto,orderType,transportFeeFlag);
137 //创建订单 142 //创建订单
138 Order order = new Order(); 143 Order order = new Order();
139 orderCreateDto.setShop(shop); 144 orderCreateDto.setShop(shop);
@@ -177,7 +182,7 @@ public class OrderServiceImpl implements OrderService { @@ -177,7 +182,7 @@ public class OrderServiceImpl implements OrderService {
177 orderCreateDto.setShopName(shop.getName()); 182 orderCreateDto.setShopName(shop.getName());
178 orderCreateDto.setShopCustomerName(shop.getCustomerName()); 183 orderCreateDto.setShopCustomerName(shop.getCustomerName());
179 //验证订单商品总重量与订单商品总价格 184 //验证订单商品总重量与订单商品总价格
180 - orderGoodsService.checkBuyerOrderDto(orderCreateDto,identityType); 185 + orderGoodsService.checkBuyerOrderDto(orderCreateDto,identityType,true);
181 //创建订单 186 //创建订单
182 Order order = new Order(); 187 Order order = new Order();
183 orderCreateDto.setShop(shop); 188 orderCreateDto.setShop(shop);
@@ -410,7 +415,7 @@ public class OrderServiceImpl implements OrderService { @@ -410,7 +415,7 @@ public class OrderServiceImpl implements OrderService {
410 @Override 415 @Override
411 public void updateOrder(OrderCreateDto buyerOrderDto, Integer orderType) { 416 public void updateOrder(OrderCreateDto buyerOrderDto, Integer orderType) {
412 //验证订单商品总重量与订单商品总价格 417 //验证订单商品总重量与订单商品总价格
413 - orderGoodsService.checkBuyerOrderDto(buyerOrderDto,orderType); 418 + orderGoodsService.checkBuyerOrderDto(buyerOrderDto,orderType,true);
414 //获取原始订单 419 //获取原始订单
415 Order order = getOrderAndCheckState(null, buyerOrderDto.getCode(), buyerOrderDto.getMarketId(),OrderOrderState.SELLER_FIX,buyerOrderDto); 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,7 +447,7 @@ public class OrderServiceImpl implements OrderService {
442 //获取订单并效验状态 447 //获取订单并效验状态
443 Order order = getOrderAndCheckState(null, buyerOrderDto.getCode(), buyerOrderDto.getMarketId(),OrderOrderState.SELLER_FIX,buyerOrderDto); 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 if(buyerOrderDto.getModifierId() == null || StrUtil.isEmpty(buyerOrderDto.getModifier())){ 452 if(buyerOrderDto.getModifierId() == null || StrUtil.isEmpty(buyerOrderDto.getModifier())){
448 throw new OrderException(OrderErrorCode.PARAM_ERROR,"订单修改人信息未传"); 453 throw new OrderException(OrderErrorCode.PARAM_ERROR,"订单修改人信息未传");
@@ -1381,9 +1386,17 @@ public class OrderServiceImpl implements OrderService { @@ -1381,9 +1386,17 @@ public class OrderServiceImpl implements OrderService {
1381 public List<Order> createMultipleOrder(MultipleOrderDto multipleOrderDto, Integer codeInteger) { 1386 public List<Order> createMultipleOrder(MultipleOrderDto multipleOrderDto, Integer codeInteger) {
1382 List<Order> orders = new ArrayList<>(); 1387 List<Order> orders = new ArrayList<>();
1383 Map<Long,OrderCreateDto> orderCreateDtos = buildOrdersDto(multipleOrderDto); 1388 Map<Long,OrderCreateDto> orderCreateDtos = buildOrdersDto(multipleOrderDto);
  1389 + boolean first = true;
1384 for(Long shopId :orderCreateDtos.keySet()){ 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 return orders; 1401 return orders;
1389 } 1402 }