Commit 36b822aa authored by 黎博's avatar 黎博

update

parent 03108c3f
......@@ -7,6 +7,7 @@ import cn.qg.qaplatform.mock.entity.Mock;
import cn.qg.qaplatform.mock.mapper.MockMapper;
import cn.qg.qaplatform.mock.utils.BankCardUtils;
import cn.qg.qaplatform.utils.JsonTransUtils;
import cn.qg.qaplatform.utils.RedisUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,6 +33,9 @@ public class YeebaoInterceptor implements HandlerInterceptor {
// @Value("${namespace}")
private String namespace = "pre";
@Autowired
RedisUtils redisUtils;
/**
* 将HttpServletRequest的parameterMap由Map<String, String[]>转换成Map<String, Object>
* @param parameterMap
......@@ -57,9 +61,9 @@ public class YeebaoInterceptor implements HandlerInterceptor {
Map<String, Object> map = new HashMap<>();
String bankCode = BankCardUtils.getCardCode(cardNo);
String bankName = BankCardUtils.getBankName(bankCode);
map.put("bankCode", bankCode);
map.put("bankName", bankName);
map.put("cardTop", cardNo.substring(0, 5));
map.put("bankcode", bankCode);
map.put("bankname", bankName);
map.put("cardtop", cardNo.substring(0, 5));
map.put("cardlast", cardNo.substring(cardNo.length()-4));
map.put("cardtype", "DEBIT");
map.put("errorcode", "");
......@@ -137,18 +141,23 @@ public class YeebaoInterceptor implements HandlerInterceptor {
String merchantno = requestMap.get("merchantno").toString();
responseMap = getBankcardCheckResponse(cardNo, merchantno);
modifyResponse(response, encryptConvertor.encrypt(JsonTransUtils.mapToJson(responseMap)));
return true;
}
if (uri.equals("/tzt-api/api/bindcard/confirm")) {
responseMap.put("bankcode", "ABC");
modifyResponse(response, encryptConvertor.encrypt(JsonTransUtils.mapToJson(responseMap)));
redisUtils.set(requestMap.get("requestno").toString(), responseMap);
log.info("保存redis值, key: {}, value: {}", requestMap.get("requestno"), responseMap);
return true;
}
// 判断返回是字符串还是json,1-json,2-字符串
if (mock.getType() == 1) {
responseMap = handleResponseMap(requestMap, responseMap);
if (uri.equals("/tzt-api/api/bindcard/request")) {
requestMap.put("yborderid", "TZAUba0c7b8" + requestMap.get("requestno") + "95c929ca802e");
responseMap.put("yborderid", "TZAUba0c7b8" + requestMap.get("requestno") + "95c929ca802e");
}
if (uri.equals("/tzt-api/api/bindcard/confirm")) {
Map bindcardCheckRedisValue = (Map) redisUtils.get(requestMap.get("requestno").toString());
responseMap.put("bankcode", bindcardCheckRedisValue.get("bankcode"));
responseMap.put("bankname", bindcardCheckRedisValue.get("bankname"));
responseMap.put("cardlast", bindcardCheckRedisValue.get("cardlast"));
responseMap.put("cardtop", bindcardCheckRedisValue.get("cardtop"));
}
modifyResponse(response, encryptConvertor.encrypt(JsonTransUtils.mapToJson(responseMap)), "application/json; charset=utf-8");
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment