generated from root/miduo_server
ohayoo,格式优化
parent
b6c554d36a
commit
fadc3a886e
|
@ -19,10 +19,11 @@ import java.util.TreeMap;
|
|||
public class OhayooGetExternalController {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OhayooGetExternalController.class);
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
@PostMapping(value = "/ohayooGetExternal")
|
||||
public String ohayooGetExternal(HttpServletRequest request) throws Exception {
|
||||
Gson gson = new Gson();
|
||||
TreeMap<String, Object> map = new TreeMap<>();
|
||||
|
||||
TreeMap<String, String> treeMap = new TreeMap<>();
|
||||
InputStreamReader insr = new InputStreamReader(request.getInputStream(),"utf-8");
|
||||
String result = "";
|
||||
int respInt = insr.read();
|
||||
|
@ -30,23 +31,43 @@ public class OhayooGetExternalController {
|
|||
result += (char) respInt;
|
||||
respInt = insr.read();
|
||||
}
|
||||
map = gson.fromJson(result, map.getClass());
|
||||
LOGGER.info("ohayoo获取前端参数:{}",map);
|
||||
if (map == null || map.isEmpty()) {
|
||||
treeMap = gson.fromJson(result, treeMap.getClass());
|
||||
LOGGER.info("ohayoo获取前端参数:{}",treeMap);
|
||||
if (treeMap == null || treeMap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
|
||||
builder.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||
}
|
||||
String externalOrder = builder.substring(0, builder.length() - 1);
|
||||
|
||||
String payKey = OhayooRechargeController.payKey;
|
||||
String sign = MD5Util.encrypByMd5(payKey + externalOrder + payKey);
|
||||
treeMap.put("sign",sign);
|
||||
|
||||
map.put("sign",sign);
|
||||
//格式转换
|
||||
result = formatConversion(treeMap);
|
||||
LOGGER.info("ohayoo返回前端参数:{}",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String formatConversion(Map<String,String> treeMap){
|
||||
TreeMap<String, Object> map = new TreeMap<>();
|
||||
|
||||
map.put("body",treeMap.get("body"));
|
||||
map.put("custom_callback_info",treeMap.get("custom_callback_info"));
|
||||
map.put("notify_url",treeMap.get("notify_url"));
|
||||
map.put("open_id",treeMap.get("open_id"));
|
||||
map.put("order_no",treeMap.get("order_no"));
|
||||
map.put("product_id",treeMap.get("product_id"));
|
||||
map.put("sign_type",treeMap.get("sign_type"));
|
||||
map.put("subject",treeMap.get("subject"));
|
||||
map.put("total_amount",Long.valueOf(treeMap.get("total_amount")));
|
||||
map.put("trade_time",Long.valueOf(treeMap.get("trade_time")));
|
||||
map.put("valid_time",Long.valueOf(treeMap.get("valid_time")));
|
||||
map.put("sign",treeMap.get("sign"));
|
||||
|
||||
LOGGER.info("ohayoo返回前端参数:{}",gson.toJson(map));
|
||||
return gson.toJson(map);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue