Authored by LUOXC

refactor

... ... @@ -17,7 +17,7 @@ public interface TradeBillsMapper {
List<TradeBills> selectByConditionWithPage(@Param("billsTradeReq") TradeBillsReq req);
List<TradeBillsTransferOutTradeNo> selectTransferOutTradeNoByOrderCodes(@Param("orderCodes") List<Long> orderCodes);
List<TradeBillsTransferOutTradeNo> selectTransferOutTradeNoByIds(@Param("ids") List<Integer> ids);
List<TradeBills> selectByFailTradeBills(@Param("fromCreateTime") int fromCreateTime, @Param("fromTradeBillsId") int fromTradeBillsId, @Param("limit") int limit);
... ...
... ... @@ -2,8 +2,6 @@ package com.yoho.order.model;
import lombok.Data;
import java.math.BigDecimal;
/**
* 交易流水表
*/
... ... @@ -14,6 +12,4 @@ public class TradeBillsTransferOutTradeNo {
private String outTradeNo;
private Long orderCode;
}
... ...
... ... @@ -86,25 +86,19 @@
limit #{billsTradeReq.start},#{billsTradeReq.size}
</select>
<select id="selectTransferOutTradeNoByOrderCodes" resultType="com.yoho.order.model.TradeBillsTransferOutTradeNo">
<select id="selectTransferOutTradeNoByIds" resultType="com.yoho.order.model.TradeBillsTransferOutTradeNo">
SELECT tb.id,
CASE t.interface_type
WHEN 2 THEN concat(t.id, '_', IF(tb.deal_relate_id != 0,tb.deal_relate_id,tb.id))
WHEN 3 THEN '钱包'
END AS outTradeNo,
tb.order_code AS orderCode
END AS outTradeNo
FROM ufo_order.trade_bills tb
LEFT JOIN ufo_order.orders_pay_transfer t ON t.buyer_order_code = tb.order_code
WHERE tb.income_outcome = 1 AND tb.deal_status != 1
<!-- 转账单 -->
AND (
tb.trade_type = 3 <!-- 补偿款 -->
OR (tb.user_type =2 AND tb.trade_type = 2) <!-- 卖家货款 -->
OR (tb.user_type =2 AND tb.trade_type = 4) <!-- 卖家返利 -->
)
AND tb.order_code IN
<foreach collection="orderCodes" item="orderCode" open="(" close=")" separator=",">
#{orderCode}
<!-- 程序保障是转账单 id -->
AND tb.id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
... ...
... ... @@ -256,14 +256,14 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
}
private Map<Integer, String> getTransferOutTradeNoMap(List<TradeBills> tradeBillsList) {
List<Long> orderCodes = tradeBillsList.stream()
List<Integer> ids = tradeBillsList.stream()
.filter(item -> MoneyTypeEnum.from(item).map(MoneyTypeEnum::isTransfer).orElse(Boolean.FALSE))
.map(TradeBills::getOrderCode)
.map(TradeBills::getId)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(orderCodes)) {
if (CollectionUtils.isEmpty(ids)) {
return Maps.newHashMap();
}
return tradeBillsMapper.selectTransferOutTradeNoByOrderCodes(orderCodes)
return tradeBillsMapper.selectTransferOutTradeNoByIds(ids)
.stream()
.collect(Collectors.toMap(TradeBillsTransferOutTradeNo::getId, TradeBillsTransferOutTradeNo::getOutTradeNo));
}
... ...