Commit 9ba2ec7d552e75c6ff782fa99d91216f7717f551

Authored by fengliang
1 parent 25c981b7

update:修正微信订单重复扣费问题

etrade-order/src/main/java/com/diligrp/etrade/order/domain/OrderQueryDto.java
... ... @@ -72,6 +72,10 @@ public class OrderQueryDto extends BasePageQuery {
72 72  
73 73 /** 订单配送状态 (1待配送 2配送中 3已配送) */
74 74 private Integer achieveState;
  75 + /**
  76 + * 配送方式
  77 + */
  78 + private Integer wayType;
75 79  
76 80 public Integer getVerifyState() {
77 81 return verifyState;
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/domain/OrderStateNumberDto.java
... ... @@ -3,8 +3,15 @@ package com.diligrp.etrade.order.domain;
3 3 public class OrderStateNumberDto {
4 4  
5 5 private Integer state;
  6 +
  7 + private Integer verifyState;
  8 +
  9 + private Integer achieveState;
  10 +
6 11 private Integer number;
7 12  
  13 + private Integer code;
  14 +
8 15 public Integer getState() {
9 16 return state;
10 17 }
... ... @@ -20,4 +27,28 @@ public class OrderStateNumberDto {
20 27 public void setNumber(Integer number) {
21 28 this.number = number;
22 29 }
  30 +
  31 + public Integer getVerifyState() {
  32 + return verifyState;
  33 + }
  34 +
  35 + public void setVerifyState(Integer verifyState) {
  36 + this.verifyState = verifyState;
  37 + }
  38 +
  39 + public Integer getAchieveState() {
  40 + return achieveState;
  41 + }
  42 +
  43 + public void setAchieveState(Integer achieveState) {
  44 + this.achieveState = achieveState;
  45 + }
  46 +
  47 + public Integer getCode() {
  48 + return code;
  49 + }
  50 +
  51 + public void setCode(Integer code) {
  52 + this.code = code;
  53 + }
23 54 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/domain/OrderStateNumbers.java
... ... @@ -18,6 +18,15 @@ public class OrderStateNumbers {
18 18 */
19 19 private Integer finished = 0;
20 20  
  21 + /** 待核销 */
  22 + private Integer waitMapping = 0;
  23 +
  24 + /** 待配送 */
  25 + private Integer waitSend = 0;
  26 +
  27 + /** 待收货 */
  28 + private Integer waitReceive = 0;
  29 +
21 30 /**
22 31 * 已取消
23 32 */
... ... @@ -67,4 +76,28 @@ public class OrderStateNumbers {
67 76 public void setAll(Integer all) {
68 77 this.all = all;
69 78 }
  79 +
  80 + public Integer getWaitMapping() {
  81 + return waitMapping;
  82 + }
  83 +
  84 + public void setWaitMapping(Integer waitMapping) {
  85 + this.waitMapping = waitMapping;
  86 + }
  87 +
  88 + public Integer getWaitSend() {
  89 + return waitSend;
  90 + }
  91 +
  92 + public void setWaitSend(Integer waitSend) {
  93 + this.waitSend = waitSend;
  94 + }
  95 +
  96 + public Integer getWaitReceive() {
  97 + return waitReceive;
  98 + }
  99 +
  100 + public void setWaitReceive(Integer waitReceive) {
  101 + this.waitReceive = waitReceive;
  102 + }
70 103 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/model/Order.java
... ... @@ -278,6 +278,8 @@ public class Order {
278 278  
279 279 /** 订单配送状态 */
280 280 private Integer achieveState;
  281 + /** 扣减库存状态(1未扣减,2已扣减) */
  282 + private Integer stockDeductionState;
281 283  
282 284 public Integer getAchieveType() {
283 285 return achieveType;
... ... @@ -734,4 +736,12 @@ public class Order {
734 736 public void setRelationId(Long relationId) {
735 737 this.relationId = relationId;
736 738 }
  739 +
  740 + public Integer getStockDeductionState() {
  741 + return stockDeductionState;
  742 + }
  743 +
  744 + public void setStockDeductionState(Integer stockDeductionState) {
  745 + this.stockDeductionState = stockDeductionState;
  746 + }
737 747 }
738 748 \ No newline at end of file
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderGoodsServiceImpl.java
... ... @@ -237,6 +237,10 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
237 237 @Transactional
238 238 @Override
239 239 public void deduct(Order order,Long operateId,String operateName) {
  240 + //检测是否扣减过,已扣减则不再继续扣减
  241 + if(order.getStockDeductionState()!=null&&order.getStockDeductionState().equals(OrderDeductionState.DEDUCT_FINISH.getCodeInteger())){
  242 + return ;
  243 + }
240 244 List<ProductDto> realgoods = getProductDtoByOrderId(order.getId(),order.getMarketId(),OrderGoodState.NORMAL.getCodeInteger());
241 245 Map<Long,ProductDto> deductGoods = new HashMap<>();
242 246 for(ProductDto productDto :realgoods){
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderQueryServiceImpl.java
... ... @@ -39,6 +39,9 @@ public class OrderQueryServiceImpl implements OrderQueryService {
39 39 @Resource
40 40 private OrderPaymentService orderPaymentService;
41 41  
  42 + @Resource
  43 + private OrderDeliveryService orderDeliveryService;
  44 +
42 45 @Override
43 46 public List<OrderStateNumberDto> queryOrderStateNumber(OrderQueryDto orderQueryDto) {
44 47 return orderQueryMapper.queryOrderStateNumber(orderQueryDto);
... ... @@ -104,6 +107,9 @@ public class OrderQueryServiceImpl implements OrderQueryService {
104 107 //获取交易单
105 108 orderDetail.setOrderPaymentDto(orderPaymentService.getPaymenDtoByOrderId(orderDetail.getOrder().getId(),orderDetail.getOrder().getMarketId(),OrderPaymentState.FINISH_PAY.getCodeInteger()));
106 109 }
  110 + if(orderDetail.getOrder().getAchieveType().equals(OrderAchieveType.SELLER_DELIVERY.getCodeInteger())){
  111 + orderDetail.setOrderDelivery(orderDeliveryService.selectOrderDeliveryByOrderCode(orderDetail.getOrder().getCode()));
  112 + }
107 113 return orderDetail;
108 114 }
109 115  
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderServiceImpl.java
... ... @@ -60,6 +60,7 @@ import java.math.RoundingMode;
60 60 import java.time.Duration;
61 61 import java.time.LocalDateTime;
62 62 import java.util.*;
  63 +import java.util.stream.Collectors;
63 64  
64 65 /**
65 66 * 订单主单服务实现
... ... @@ -769,7 +770,6 @@ public class OrderServiceImpl implements OrderService {
769 770 }
770 771 }
771 772  
772   - List<OrderPayment> orderPaymentList = new ArrayList<>();
773 773 WeChatPayTradeDto weChatPayTradeDto = new WeChatPayTradeDto();
774 774 //效验店铺
775 775 ShopVo shop = orderGoodsService.checkShop(orderWeChatPayBatch.getShopId());
... ... @@ -810,8 +810,7 @@ public class OrderServiceImpl implements OrderService {
810 810 ,orderWeChatPayBatch.getPayerStoreCustomerId(),orderWeChatPayBatch.getPayerCustomerName(),orderWeChatPayBatch.getPayerPhone()
811 811 ,null,null,null,null,orderWeChatPayBatch.getOperateId(),orderWeChatPayBatch.getOperateName()
812 812 ,null,null,null,orderWeChatPayBatch.getCustomerAbbr(),weChatPayTradeBackDto.getPaymentId());
813   - OrderPayVo payVo = orderPaymentService.createOrderPayment(order, orderPayDto, identityType,shop);
814   - orderPaymentList.add(payVo.getOrderPayment());
  813 + orderPaymentService.createOrderPayment(order, orderPayDto, identityType,shop);
815 814 }catch (PlatformServiceException pe){
816 815 LOGGER.info("微信支付异常,支付订单号:{},异常信息{}",orderWeChatPayBatch.getCodes(),pe.getMessage());
817 816 wxChatPayCloseOnly(weChatPayTradeBackDto.getPaymentId(),orderWeChatPayBatch.getMarketId(),null);
... ... @@ -826,9 +825,8 @@ public class OrderServiceImpl implements OrderService {
826 825 }
827 826 //扣减库存T
828 827 orderGoodsService.deductBatch(orderList,orderWeChatPayBatch.getPayerCustomerId(),orderWeChatPayBatch.getPayerCustomerName());
829   -
830   - //保存待支付单
831   - //orderPaymentService.saveBatch(orderPaymentList);
  828 + //更新扣减库存状态
  829 + orderMapper.updateDeductState(orderList.stream().map(Order::getId).collect(Collectors.toList()));
832 830 //返回数据,由小程序发起微信支付。
833 831 return Message.success(weChatPayTradeBackDto);
834 832 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/type/OrderDeductionState.java 0 → 100644
  1 +package com.diligrp.etrade.order.type;
  2 +
  3 +import com.diligrp.etrade.core.type.IEnumType;
  4 +
  5 +/**
  6 + * 操作类型
  7 + */
  8 +public enum OrderDeductionState implements IEnumType {
  9 + UN_DEDUCT("未扣减", 1),
  10 + DEDUCT_FINISH("已扣减", 2)
  11 + ;
  12 +
  13 + private String name;
  14 + private Integer code;
  15 +
  16 + private OrderDeductionState(String name, Integer code) {
  17 + this.name = name;
  18 + this.code = code;
  19 + }
  20 +
  21 + public static OrderDeductionState getByCode(Integer code) {
  22 + for (OrderDeductionState temp : OrderDeductionState.values()) {
  23 + if (temp.getCodeInteger().equals(code)) {
  24 + return temp;
  25 + }
  26 + }
  27 + return null;
  28 + }
  29 +
  30 + public static String getNameByCode(Integer code) {
  31 + for (OrderDeductionState temp : OrderDeductionState.values()) {
  32 + if (temp.getCodeInteger().equals(code)) {
  33 + return temp.getName();
  34 + }
  35 + }
  36 + return null;
  37 + }
  38 +
  39 + public Integer getCodeInteger() {
  40 + return this.code;
  41 + }
  42 +
  43 + public String getName() {
  44 + return this.name;
  45 + }
  46 +
  47 + public int getCode() {
  48 + return this.code;
  49 + }
  50 +
  51 + public String toString() {
  52 + return this.name;
  53 + }
  54 +}
0 55 \ No newline at end of file
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/type/OrderState.java
... ... @@ -9,7 +9,10 @@ public enum OrderState implements IEnumType {
9 9 FINISH("已完成", 3),
10 10 CANCEL("已取消", 4),
11 11 INVALID("已作废", 5),
12   - PAY_FINISH("已支付", 6);
  12 + PAY_FINISH("已支付", 6),
  13 + WAIT_MAPPING("待核销", 601),
  14 + WAIT_SEND("待配送", 611),
  15 + WAIT_GET("待收货", 612);
13 16  
14 17 private String name;
15 18 private Integer code;
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/util/ParameterDetection.java
... ... @@ -22,7 +22,7 @@ public class ParameterDetection {
22 22 }
23 23  
24 24 public static String sqlLikeParam(String param){
25   - if(StrUtil.isEmpty(param)){
  25 + if(StrUtil.isBlank(param)){
26 26 return null;
27 27 }else{
28 28 return "%"+param+"%";
... ... @@ -30,7 +30,7 @@ public class ParameterDetection {
30 30 }
31 31  
32 32 public static String sqlEnterParam(String param){
33   - if(StrUtil.isEmpty(param)){
  33 + if(StrUtil.isBlank(param)){
34 34 return null;
35 35 }else{
36 36 return param;
... ...
etrade-order/src/main/resources/com/diligrp/etrade/dao/mapper/order/OrderQueryMapper.xml
... ... @@ -210,9 +210,11 @@
210 210 opa.pay_channel as pay_channel,
211 211 ord.achieve_type as achieve_type,
212 212 ord.achieve_state as achieve_state,
  213 + ody.way_type as wayType,
213 214 (CASE WHEN opa.payee_seller_name IS NULL OR opa.payee_seller_name = '' THEN ord.shop_customer_name ELSE opa.payee_seller_name END) AS payee_seller_name
214 215 from `order` ord
215 216 left join order_payment opa on opa.order_id = ord.id and opa.`state` = 2
  217 + left join order_delivery ody on ord.id = ody.order_id
216 218 <where>
217 219 (ord.`state` != 0 or ord.`state` is null) and ord.market_id = #{marketId}
218 220 <if test="orderState != null">
... ...