...
|
...
|
@@ -11,9 +11,9 @@ import com.yoho.order.dal.*; |
|
|
import com.yoho.order.model.*;
|
|
|
import com.yoho.ufo.constants.SellerTypeEnum;
|
|
|
import com.yoho.ufo.order.constant.MoneyTypeEnum;
|
|
|
import com.yoho.ufo.order.constant.TradeStatusEnum;
|
|
|
import com.yoho.ufo.order.response.StoredSellerRespVo;
|
|
|
import com.yoho.ufo.order.service.ITradeBillsService;
|
|
|
import com.yoho.ufo.order.service.impl.builder.TradeBillsListBuilder;
|
|
|
import com.yoho.ufo.order.util.ServiceExceptions;
|
|
|
import com.yoho.ufo.service.IQNDownloadService;
|
|
|
import com.yoho.ufo.service.impl.UserHelper;
|
...
|
...
|
@@ -21,12 +21,10 @@ import com.yoho.ufo.service.model.PageResponseBO; |
|
|
import com.yoho.ufo.util.CollectionUtil;
|
|
|
import com.yoho.ufo.util.KeyWordHiddenUtil;
|
|
|
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
|
|
|
import com.yohobuy.ufo.model.order.common.AlipayBatchTransferErrorEnum;
|
|
|
import com.yohobuy.ufo.model.order.resp.TradeBillsResp;
|
|
|
import com.yohobuy.ufo.model.user.req.AuthorizeInfoReq;
|
|
|
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.common.collect.Lists;
|
|
|
import org.elasticsearch.common.collect.Maps;
|
...
|
...
|
@@ -192,7 +190,7 @@ public class TradeBillsServiceImpl implements ITradeBillsService { |
|
|
|
|
|
public PageResponseBO<TradeBillsResp> queryTradeBillsList(TradeBillsReq req) {
|
|
|
if (req.getMoneyType() != null) {
|
|
|
MoneyTypeEnum moneyTypeClass = MoneyTypeEnum.getMoneyTypeByCode(req.getMoneyType());
|
|
|
MoneyTypeEnum moneyTypeClass = MoneyTypeEnum.codeOf(req.getMoneyType());
|
|
|
if (moneyTypeClass != null) {
|
|
|
req.setUserType(moneyTypeClass.getUserType());
|
|
|
req.setTradeType(moneyTypeClass.getTradeType());
|
...
|
...
|
@@ -246,10 +244,10 @@ public class TradeBillsServiceImpl implements ITradeBillsService { |
|
|
if (CollectionUtils.isEmpty(tradeBillsList)) {
|
|
|
return null;
|
|
|
}
|
|
|
Map<Integer, String> outTradeNoMap = getTransferOutTradeNoMap(tradeBillsList);
|
|
|
Map<Integer, String> transferOutTradeNoMap = getTransferOutTradeNoMap(tradeBillsList);
|
|
|
|
|
|
PageResponseBO<TradeBillsResp> result = new PageResponseBO<>();
|
|
|
result.setList(convertToResp(tradeBillsList, outTradeNoMap));
|
|
|
result.setList(new TradeBillsListBuilder(tradeBillsList).transferOutTradeNoMap(transferOutTradeNoMap).build());
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
result.setTotal(total);
|
...
|
...
|
@@ -259,7 +257,7 @@ public class TradeBillsServiceImpl implements ITradeBillsService { |
|
|
|
|
|
private Map<Integer, String> getTransferOutTradeNoMap(List<TradeBills> tradeBillsList) {
|
|
|
List<Long> orderCodes = tradeBillsList.stream()
|
|
|
.filter(item -> isTransferTrade(item))
|
|
|
.filter(item -> MoneyTypeEnum.from(item).map(MoneyTypeEnum::isTransfer).orElse(Boolean.FALSE))
|
|
|
.map(TradeBills::getOrderCode)
|
|
|
.collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(orderCodes)) {
|
...
|
...
|
@@ -270,14 +268,6 @@ public class TradeBillsServiceImpl implements ITradeBillsService { |
|
|
.collect(Collectors.toMap(TradeBillsTransferOutTradeNo::getId, TradeBillsTransferOutTradeNo::getOutTradeNo));
|
|
|
}
|
|
|
|
|
|
private boolean isTransferTrade(TradeBills tradeBills) {
|
|
|
MoneyTypeEnum moneyTypeEnum = MoneyTypeEnum.getMoneyTypeByUserTypeAndTradeType(tradeBills.getUserType(), tradeBills.getTradeType());
|
|
|
return moneyTypeEnum == MoneyTypeEnum.deposit_rebate
|
|
|
|| moneyTypeEnum == MoneyTypeEnum.buyer_compensatoryPayment
|
|
|
|| moneyTypeEnum == MoneyTypeEnum.seller_goodsPayment
|
|
|
|| moneyTypeEnum == MoneyTypeEnum.seller_compensatoryPayment;
|
|
|
}
|
|
|
|
|
|
public AuthorizeResultRespVO queryAuthorizeInfoByUid(Integer uid) {
|
|
|
if (uid == null || uid <= 0) {
|
|
|
return null;
|
...
|
...
|
@@ -315,73 +305,6 @@ public class TradeBillsServiceImpl implements ITradeBillsService { |
|
|
localUidAlipayAccountCache.invalidate(uid);
|
|
|
}
|
|
|
|
|
|
|
|
|
private List<TradeBillsResp> convertToResp(List<TradeBills> tradeBillsList, Map<Integer, String> outTradeNoMap) {
|
|
|
|
|
|
return tradeBillsList.stream()
|
|
|
.map(item -> {
|
|
|
TradeBillsResp resp = new TradeBillsResp();
|
|
|
resp.setId(item.getId());
|
|
|
resp.setUid(item.getUid());
|
|
|
resp.setMobile(StringUtils.EMPTY);
|
|
|
resp.setAlipayAccount(StringUtils.EMPTY);
|
|
|
resp.setOrderCode(item.getOrderCode());
|
|
|
resp.setPaidOrderCode(buildPaidOrderCode(item, outTradeNoMap));
|
|
|
resp.setAmount(item.getAmount());
|
|
|
resp.setIncomeOutcome(item.getIncomeOutcome());
|
|
|
resp.setCreateTimeStr(buildPaidTime(item));
|
|
|
resp.setOperatorUid(item.getDealUid());
|
|
|
resp.setOperatorName((item.getDealUid() == null || item.getDealUid() == 0) ? "系统" : item.getDealUserName());
|
|
|
resp.setTradeStatus(item.getTradeStatus());
|
|
|
|
|
|
//金额类型
|
|
|
MoneyTypeEnum moneyTypeClass = MoneyTypeEnum.getMoneyTypeByUserTypeAndTradeType(item.getUserType(), item.getTradeType());
|
|
|
if (moneyTypeClass != null) {
|
|
|
resp.setMoneyType(moneyTypeClass.getCode());
|
|
|
resp.setMoneyTypeDesc(moneyTypeClass.getDesc());
|
|
|
resp.setMoneyFlow(moneyTypeClass.getMoneyFlow());
|
|
|
}
|
|
|
//打款失败原因
|
|
|
TradeStatusEnum.codeOf(item.getTradeStatus())
|
|
|
.filter(e -> e.isFail())
|
|
|
.ifPresent(e -> {
|
|
|
String failReason;
|
|
|
if (Objects.nonNull(item.getPayErrorCode())) {
|
|
|
String payErrorCode = item.getPayErrorCode();
|
|
|
AlipayBatchTransferErrorEnum error = AlipayBatchTransferErrorEnum.getByCode(payErrorCode);
|
|
|
failReason = Objects.nonNull(error) ? error.getDesc() : payErrorCode;
|
|
|
} else {
|
|
|
failReason = e.getDesc();
|
|
|
}
|
|
|
resp.setTradeStatusDesc(failReason);
|
|
|
});
|
|
|
return resp;
|
|
|
})
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
private String buildPaidOrderCode(TradeBills item, Map<Integer, String> outTradeNoMap) {
|
|
|
return Optional.ofNullable(item.getPaidOrderCode())
|
|
|
.filter(e -> e > 0)
|
|
|
.map(Object::toString)
|
|
|
.orElseGet(() -> {
|
|
|
String defaultValue = "-";
|
|
|
if (isTransferTrade(item)) {
|
|
|
return outTradeNoMap.getOrDefault(item.getId(), outTradeNoMap.getOrDefault(item.getDealRelateId(), defaultValue));
|
|
|
} else {
|
|
|
return defaultValue;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private String buildPaidTime(TradeBills item) {
|
|
|
long dealTime = ObjectUtils.defaultIfNull(item.getDealTime(), 0);
|
|
|
if (dealTime == 0) {
|
|
|
dealTime = item.getCreateTime();
|
|
|
}
|
|
|
return DateUtil.long2DateStr(dealTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
}
|
|
|
|
|
|
private JSONObject asyncCallQueryAliAccountJsonObject(Integer uid) {
|
|
|
AuthorizeInfoReq req = new AuthorizeInfoReq();
|
|
|
req.setUid(uid);
|
...
|
...
|
|