Authored by LUOXC

Merge branch 'hotfix-20200305' into test6.9.22

package com.yohoufo.dal.order.model;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Objects;
/**
* 交易流水表
*/
@Getter
@Setter
@Data
public class TradeBills {
/**
... ... @@ -41,7 +38,7 @@ public class TradeBills {
private Integer tradeType;
//1:用户收入; 2:用户支出
private Integer incomeOutcome;
private Integer incomeOutcome;
private BigDecimal amount;
... ... @@ -69,39 +66,22 @@ public class TradeBills {
//支付阶段,0:普通,1:定金
private int payLevel = 0;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TradeBills that = (TradeBills) o;
return Objects.equals(uid, that.uid) &&
Objects.equals(orderCode, that.orderCode) &&
Objects.equals(userType, that.userType) &&
Objects.equals(tradeType, that.tradeType) &&
Objects.equals(incomeOutcome, that.incomeOutcome);
}
@Override
public int hashCode() {
return Objects.hash(uid, orderCode, userType, tradeType, incomeOutcome);
}
/**
* suggest use new enum, define class as blow
* {@link com.yohoufo.order.common.BillTradeStatus}
*/
@Deprecated
public enum Status {
Null(0);
Status(int code) {
this.code = code;
}
private int code;
public int getCode() {
return code;
}
Null(0);
Status(int code) {
this.code = code;
}
private int code;
public int getCode() {
return code;
}
}
}
... ...
... ... @@ -2,14 +2,10 @@ package com.yohoufo.order.repository;
import com.yohoufo.dal.order.model.TradeBills;
import java.util.List;
public interface TradeBillsRepository {
int save(TradeBills record);
List<TradeBills> findByOrderCode(Long orderCode);
int lock(Integer id);
int unlock(Integer id);
... ...
package com.yohoufo.order.repository;
import com.google.common.collect.Lists;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.dal.order.TradeBillsMapper;
import com.yohoufo.dal.order.model.TradeBills;
... ... @@ -8,7 +7,6 @@ import com.yohoufo.order.event.TradeBillsChangeEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Objects;
@Repository
... ... @@ -29,11 +27,6 @@ public class TradeBillsRepositoryImpl implements TradeBillsRepository {
}
@Override
public List<TradeBills> findByOrderCode(Long orderCode) {
return tradeBillsMapper.selectByOrderCodeList(Lists.newArrayList(orderCode));
}
@Override
public int lock(Integer id) {
return tradeBillsMapper.updateLock(id);
}
... ...
... ... @@ -28,7 +28,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
... ... @@ -85,12 +84,9 @@ public class TransferManager {
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Database(ForceMaster = true, DataSource = "ufo_order")
public ServiceException save(TransferBill transferBill) {
TradeBills tradeBills = transferBill.getTradeBills();
if (Objects.isNull(tradeBills.getId())) {
if (Objects.isNull(transferBill.getTradeBills().getId())) {
ServiceException serviceException = transferBill.resetTradeStatus();
List<TradeBills> histories = tradeBillsRepository.findByOrderCode(tradeBills.getOrderCode());
throwServiceExceptionIf(histories.contains(tradeBills), 500, "转账单已存在");
tradeBillsRepository.save(tradeBills);
tradeBillsRepository.save(transferBill.getTradeBills());
ordersPayTransferMapper.insert(transferBill.getTransfer());
publishEvent(transferBill);
return serviceException;
... ...