未验证 提交 708aa64b 编写于 作者: D dingzhiwei 提交者: GitHub

Merge pull request #8 from cbwleft/feature/application_json

Feature/application json
/.idea/
*.iml
/log/
target/
\ No newline at end of file
target/
*.project
......@@ -142,7 +142,7 @@ public class PayDigestUtil {
Field[] fields = cls.getDeclaredFields();
for (Field f : fields) {
f.setAccessible(true);
if (f.get(o) != null && f.get(o) != "") {
if (f.get(o) != null && !"".equals(f.get(o))) {
list.add(f.getName() + "=" + f.get(o) + "&");
}
}
......@@ -164,7 +164,7 @@ public class PayDigestUtil {
public static String getSign(Map<String,Object> map, String key){
ArrayList<String> list = new ArrayList<String>();
for(Map.Entry<String,Object> entry:map.entrySet()){
if(!"".equals(entry.getValue())){
if(!"".equals(entry.getValue()) && null != entry.getValue()){
list.add(entry.getKey() + "=" + entry.getValue() + "&");
}
}
......
......@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -48,14 +50,19 @@ public class PayOrderController {
*/
@RequestMapping(value = "/api/pay/create_order")
public String payOrder(@RequestParam String params) {
_log.info("###### 开始接收商户统一下单请求 ######");
JSONObject po = JSONObject.parseObject(params);
return payOrder(po);
}
@RequestMapping(value = "/api/pay/create_order", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public String payOrder(@RequestBody JSONObject params) {
_log.info("###### 开始接收商户统一下单请求 ######");
String logPrefix = "【商户统一下单】";
try {
JSONObject po = JSONObject.parseObject(params);
JSONObject payContext = new JSONObject();
JSONObject payOrder = null;
// 验证参数有效性
Object object = validateParams(po, payContext);
Object object = validateParams(params, payContext);
if (object instanceof String) {
_log.info("{}参数校验不通过:{}", logPrefix, object);
return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, object.toString(), null, null));
......
......@@ -3,6 +3,8 @@ package org.xxpay.boot.ctrl;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -42,22 +44,27 @@ public class QueryPayOrderController {
*/
@RequestMapping(value = "/api/pay/query_order")
public String queryPayOrder(@RequestParam String params) {
JSONObject po = JSONObject.parseObject(params);
return queryPayOrder(po);
}
@RequestMapping(value = "/api/pay/query_order", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public String queryPayOrder(@RequestBody JSONObject params) {
_log.info("###### 开始接收商户查询支付订单请求 ######");
String logPrefix = "【商户支付订单查询】";
try {
JSONObject po = JSONObject.parseObject(params);
JSONObject payContext = new JSONObject();
// 验证参数有效性
String errorMessage = validateParams(po, payContext);
String errorMessage = validateParams(params, payContext);
if (!"success".equalsIgnoreCase(errorMessage)) {
_log.warn(errorMessage);
return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, errorMessage, null, null));
}
_log.debug("请求参数及签名校验通过");
String mchId = po.getString("mchId"); // 商户ID
String mchOrderNo = po.getString("mchOrderNo"); // 商户订单号
String payOrderId = po.getString("payOrderId"); // 支付订单号
String executeNotify = po.getString("executeNotify"); // 是否执行回调
String mchId = params.getString("mchId"); // 商户ID
String mchOrderNo = params.getString("mchOrderNo"); // 商户订单号
String payOrderId = params.getString("payOrderId"); // 支付订单号
String executeNotify = params.getString("executeNotify"); // 是否执行回调
JSONObject payOrder = payOrderService.queryPayOrder(mchId, payOrderId, mchOrderNo, executeNotify);
_log.info("{}查询支付订单,结果:{}", logPrefix, payOrder);
if (payOrder == null) {
......
......@@ -97,12 +97,12 @@ public class PayChannel4WxServiceImpl extends BaseService implements IPayChannel
configMap.put("appid", appId);
// 此map用于客户端与微信服务器交互
payInfo.put("sign", SignUtils.createSign(configMap, wxPayConfig.getMchKey(), null));
payInfo.put("prepayId", wxPayUnifiedOrderResult.getPrepayId());
payInfo.put("partnerId", partnerId);
payInfo.put("appId", appId);
payInfo.put("packageValue", packageValue);
payInfo.put("timeStamp", timestamp);
payInfo.put("nonceStr", nonceStr);
payInfo.put("prepayid", wxPayUnifiedOrderResult.getPrepayId());
payInfo.put("partnerid", partnerId);
payInfo.put("appid", appId);
payInfo.put("package", packageValue);
payInfo.put("timestamp", timestamp);
payInfo.put("noncestr", nonceStr);
map.put("payParams", payInfo);
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册