Authored by qinchao

交易流水查询支付宝账号

... ... @@ -32,6 +32,7 @@
<if test="billsTradeReq.uid != null">
and uid = #{billsTradeReq.uid}
</if>
and income_outcome=1
<if test="billsTradeReq.status != null ">
<choose>
<when test="billsTradeReq.status == 100 ">
... ...
... ... @@ -27,6 +27,10 @@
<artifactId>order-ufo-model</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>user-ufo-model</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.ufo</groupId>
<artifactId>ufo-platform-dal</artifactId>
</dependency>
... ... @@ -35,10 +39,6 @@
<artifactId>ufo-platform-common</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>order-ufo-model</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-client-simple</artifactId>
</dependency>
... ...
package com.yoho.ufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.order.dal.TradeBillsMapper;
... ... @@ -9,7 +11,9 @@ import com.yoho.ufo.order.constant.TradeStatusEnum;
import com.yoho.ufo.order.service.ITradeBillsService;
import com.yoho.ufo.service.impl.UserHelper;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.user.req.AuthorizeInfoReq;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
... ... @@ -23,6 +27,9 @@ import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
... ... @@ -43,6 +50,8 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
private static final String UIC_GETUSERPROFILE_URL = "/uic/profile/getUserProfile";
private Cache<Integer,String> localUidMobileCache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterAccess(1, TimeUnit.MINUTES).build();
private Cache<Integer,String> localUidAlipayAccountCache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterAccess(1, TimeUnit.MINUTES).build();
@Autowired
private TradeBillsMapper tradeBillsMapper;
... ... @@ -92,13 +101,14 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
TradeBillsResp resp=new TradeBillsResp();
resp.setId(item.getId());
resp.setUid(item.getUid());
resp.setMobile(getMobileByUid(item.getUid()));
resp.setMobile(getMobileByUidFromCache(item.getUid()));
resp.setAlipayAccount(getAlipayAccountByUidFromCache(item.getUid()));
resp.setOrderCode(item.getOrderCode());
resp.setAmount(item.getAmount());
resp.setIncomeOutcome(item.getIncomeOutcome());
resp.setCreateTimeStr(null == item.getCreateTime() ? "" : DateUtil.long2DateStr(item.getCreateTime().longValue()*1000, "yyyy-MM-dd HH:mm:ss"));
resp.setOperatorUid(item.getDealUid());
resp.setOperatorName(item.getDealUid()==0?"系统":item.getDealUserName());
resp.setOperatorName((item.getDealUid()==null||item.getDealUid()==0)?"系统":item.getDealUserName());
resp.setTradeStatus(item.getTradeStatus());
//打款失败原因
if(100!=item.getTradeStatus()){
... ... @@ -114,6 +124,50 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
return respList;
}
private String getAlipayAccountByUidFromCache(Integer uid){
try{
return localUidAlipayAccountCache.get(uid, new Callable<String>() {
@Override
public String call() throws Exception {
return asyncCallQueryAliAccount(uid);
}
});
}catch (ExecutionException e){
LOGGER.error("TradeBillsServiceImpl getAlipayAccountByUidFromCache error uid is{}", uid);
throw new RuntimeException(e);
}
}
private String asyncCallQueryAliAccount(Integer uid) {
AuthorizeInfoReq req=new AuthorizeInfoReq();
req.setUid(uid);
JSONObject jsonObject = serviceCaller.asyncCall("userRealNameAuthorize.getAliPayAccount", req, JSONObject.class).get(1);
LOGGER.info("call ufo-RealNameAuthorize4PlatformController userRealNameAuthorize.getAliPayAccount interface is {}, result is {}", jsonObject.toJSONString());
if(200==jsonObject.getIntValue("code")){
JSONObject data=jsonObject.getJSONObject("data");
if(data!=null&&data.get("alipayAccount")!=null){
return data.getString("alipayAccount");
}
}
return "";
}
private String getMobileByUidFromCache(Integer uid){
try{
return localUidMobileCache.get(uid, new Callable<String>() {
@Override
public String call() throws Exception {
return getMobileByUid(uid);
}
});
}catch (ExecutionException e){
LOGGER.error("TradeBillsServiceImpl getMobileByUidFromCache error uid is{}", uid);
throw new RuntimeException(e);
}
}
private String getMobileByUid(Integer uid) {
LOGGER.info("TradeBillsServiceImpl call getMobileByUid uid is{}", uid);
Map<String,Integer> request = Collections.singletonMap("uid", uid);
... ...