Authored by LUOXC

Merge branch 'hotfix-20200305' into test6.9.22

1 package com.yohoufo.dal.order.model; 1 package com.yohoufo.dal.order.model;
2 2
3 -import lombok.Getter;  
4 -import lombok.Setter; 3 +import lombok.Data;
5 4
6 import java.math.BigDecimal; 5 import java.math.BigDecimal;
7 -import java.util.Objects;  
8 6
9 /** 7 /**
10 * 交易流水表 8 * 交易流水表
11 */ 9 */
12 -@Getter  
13 -@Setter 10 +@Data
14 public class TradeBills { 11 public class TradeBills {
15 12
16 /** 13 /**
@@ -41,7 +38,7 @@ public class TradeBills { @@ -41,7 +38,7 @@ public class TradeBills {
41 private Integer tradeType; 38 private Integer tradeType;
42 39
43 //1:用户收入; 2:用户支出 40 //1:用户收入; 2:用户支出
44 - private Integer incomeOutcome; 41 + private Integer incomeOutcome;
45 42
46 private BigDecimal amount; 43 private BigDecimal amount;
47 44
@@ -69,39 +66,22 @@ public class TradeBills { @@ -69,39 +66,22 @@ public class TradeBills {
69 //支付阶段,0:普通,1:定金 66 //支付阶段,0:普通,1:定金
70 private int payLevel = 0; 67 private int payLevel = 0;
71 68
72 - @Override  
73 - public boolean equals(Object o) {  
74 - if (this == o) return true;  
75 - if (o == null || getClass() != o.getClass()) return false;  
76 - TradeBills that = (TradeBills) o;  
77 - return Objects.equals(uid, that.uid) &&  
78 - Objects.equals(orderCode, that.orderCode) &&  
79 - Objects.equals(userType, that.userType) &&  
80 - Objects.equals(tradeType, that.tradeType) &&  
81 - Objects.equals(incomeOutcome, that.incomeOutcome);  
82 - }  
83 -  
84 - @Override  
85 - public int hashCode() {  
86 - return Objects.hash(uid, orderCode, userType, tradeType, incomeOutcome);  
87 - }  
88 - 69 + /**
  70 + * suggest use new enum, define class as blow
  71 + * {@link com.yohoufo.order.common.BillTradeStatus}
  72 + */
89 @Deprecated 73 @Deprecated
90 public enum Status { 74 public enum Status {
91 -  
92 - Null(0);  
93 -  
94 - Status(int code) {  
95 - this.code = code;  
96 - }  
97 -  
98 - private int code;  
99 -  
100 - public int getCode() {  
101 - return code;  
102 - }  
103 - 75 +
  76 + Null(0);
  77 +
  78 + Status(int code) {
  79 + this.code = code;
  80 + }
  81 + private int code;
  82 + public int getCode() {
  83 + return code;
  84 + }
  85 +
104 } 86 }
105 -  
106 -  
107 } 87 }
@@ -2,14 +2,10 @@ package com.yohoufo.order.repository; @@ -2,14 +2,10 @@ package com.yohoufo.order.repository;
2 2
3 import com.yohoufo.dal.order.model.TradeBills; 3 import com.yohoufo.dal.order.model.TradeBills;
4 4
5 -import java.util.List;  
6 -  
7 public interface TradeBillsRepository { 5 public interface TradeBillsRepository {
8 6
9 int save(TradeBills record); 7 int save(TradeBills record);
10 8
11 - List<TradeBills> findByOrderCode(Long orderCode);  
12 -  
13 int lock(Integer id); 9 int lock(Integer id);
14 10
15 int unlock(Integer id); 11 int unlock(Integer id);
1 package com.yohoufo.order.repository; 1 package com.yohoufo.order.repository;
2 2
3 -import com.google.common.collect.Lists;  
4 import com.yohoufo.common.alarm.EventBusPublisher; 3 import com.yohoufo.common.alarm.EventBusPublisher;
5 import com.yohoufo.dal.order.TradeBillsMapper; 4 import com.yohoufo.dal.order.TradeBillsMapper;
6 import com.yohoufo.dal.order.model.TradeBills; 5 import com.yohoufo.dal.order.model.TradeBills;
@@ -8,7 +7,6 @@ import com.yohoufo.order.event.TradeBillsChangeEvent; @@ -8,7 +7,6 @@ import com.yohoufo.order.event.TradeBillsChangeEvent;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Repository; 8 import org.springframework.stereotype.Repository;
10 9
11 -import java.util.List;  
12 import java.util.Objects; 10 import java.util.Objects;
13 11
14 @Repository 12 @Repository
@@ -29,11 +27,6 @@ public class TradeBillsRepositoryImpl implements TradeBillsRepository { @@ -29,11 +27,6 @@ public class TradeBillsRepositoryImpl implements TradeBillsRepository {
29 } 27 }
30 28
31 @Override 29 @Override
32 - public List<TradeBills> findByOrderCode(Long orderCode) {  
33 - return tradeBillsMapper.selectByOrderCodeList(Lists.newArrayList(orderCode));  
34 - }  
35 -  
36 - @Override  
37 public int lock(Integer id) { 30 public int lock(Integer id) {
38 return tradeBillsMapper.updateLock(id); 31 return tradeBillsMapper.updateLock(id);
39 } 32 }
@@ -28,7 +28,6 @@ import org.springframework.transaction.annotation.Transactional; @@ -28,7 +28,6 @@ import org.springframework.transaction.annotation.Transactional;
28 import javax.annotation.Resource; 28 import javax.annotation.Resource;
29 import java.math.BigDecimal; 29 import java.math.BigDecimal;
30 import java.util.Arrays; 30 import java.util.Arrays;
31 -import java.util.List;  
32 import java.util.Objects; 31 import java.util.Objects;
33 import java.util.Optional; 32 import java.util.Optional;
34 33
@@ -85,12 +84,9 @@ public class TransferManager { @@ -85,12 +84,9 @@ public class TransferManager {
85 @Transactional(propagation = Propagation.REQUIRES_NEW) 84 @Transactional(propagation = Propagation.REQUIRES_NEW)
86 @Database(ForceMaster = true, DataSource = "ufo_order") 85 @Database(ForceMaster = true, DataSource = "ufo_order")
87 public ServiceException save(TransferBill transferBill) { 86 public ServiceException save(TransferBill transferBill) {
88 - TradeBills tradeBills = transferBill.getTradeBills();  
89 - if (Objects.isNull(tradeBills.getId())) { 87 + if (Objects.isNull(transferBill.getTradeBills().getId())) {
90 ServiceException serviceException = transferBill.resetTradeStatus(); 88 ServiceException serviceException = transferBill.resetTradeStatus();
91 - List<TradeBills> histories = tradeBillsRepository.findByOrderCode(tradeBills.getOrderCode());  
92 - throwServiceExceptionIf(histories.contains(tradeBills), 500, "转账单已存在");  
93 - tradeBillsRepository.save(tradeBills); 89 + tradeBillsRepository.save(transferBill.getTradeBills());
94 ordersPayTransferMapper.insert(transferBill.getTransfer()); 90 ordersPayTransferMapper.insert(transferBill.getTransfer());
95 publishEvent(transferBill); 91 publishEvent(transferBill);
96 return serviceException; 92 return serviceException;