"...src/main/git@ustchcs.com:gujinli1118/eladmin.git" did not exist on "921c462b1268a342583eac8e1275a3ad7ae8d20d"
Unverified Commit 708aa64b authored by dingzhiwei's avatar dingzhiwei Committed by GitHub
Browse files

Merge pull request #8 from cbwleft/feature/application_json

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