Commit c2ba63b1 authored by jmdhappy's avatar jmdhappy
Browse files

优化boot版本代码结构

parent 032d9db0
...@@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.xxpay.boot.web.NotifyPayService; import org.xxpay.boot.service.INotifyPayService;
import org.xxpay.common.constant.PayConstant; import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.util.MyLog; import org.xxpay.common.util.MyLog;
...@@ -28,7 +28,7 @@ public class Notify4AliPayController { ...@@ -28,7 +28,7 @@ public class Notify4AliPayController {
private static final MyLog _log = MyLog.getLog(Notify4AliPayController.class); private static final MyLog _log = MyLog.getLog(Notify4AliPayController.class);
@Autowired @Autowired
private NotifyPayService notifyPayService; private INotifyPayService notifyPayService;
/** /**
* 支付宝移动支付后台通知响应 * 支付宝移动支付后台通知响应
...@@ -69,7 +69,7 @@ public class Notify4AliPayController { ...@@ -69,7 +69,7 @@ public class Notify4AliPayController {
_log.error("{}请求参数为空", logPrefix); _log.error("{}请求参数为空", logPrefix);
return PayConstant.RETURN_ALIPAY_VALUE_FAIL; return PayConstant.RETURN_ALIPAY_VALUE_FAIL;
} }
return notifyPayService.doAliPayNotify(params); return notifyPayService.handleAliPayNotify(params);
} }
} }
...@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.xxpay.boot.web.NotifyPayService; import org.xxpay.boot.service.INotifyPayService;
import org.xxpay.common.util.MyLog; import org.xxpay.common.util.MyLog;
import javax.servlet.ServletException; import javax.servlet.ServletException;
...@@ -25,7 +25,7 @@ public class Notify4WxPayController { ...@@ -25,7 +25,7 @@ public class Notify4WxPayController {
private static final MyLog _log = MyLog.getLog(Notify4WxPayController.class); private static final MyLog _log = MyLog.getLog(Notify4WxPayController.class);
@Autowired @Autowired
private NotifyPayService notifyPayService; private INotifyPayService notifyPayService;
/** /**
* 微信支付(统一下单接口)后台通知响应 * 微信支付(统一下单接口)后台通知响应
...@@ -48,7 +48,7 @@ public class Notify4WxPayController { ...@@ -48,7 +48,7 @@ public class Notify4WxPayController {
String logPrefix = "【微信支付回调通知】"; String logPrefix = "【微信支付回调通知】";
String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding()); String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
_log.info("{}通知请求数据:reqStr={}", logPrefix, xmlResult); _log.info("{}通知请求数据:reqStr={}", logPrefix, xmlResult);
return notifyPayService.doWxPayNotify(xmlResult); return notifyPayService.handleWxPayNotify(xmlResult);
} }
} }
...@@ -8,9 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -8,9 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
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;
import org.xxpay.boot.web.MchInfoService; import org.xxpay.boot.service.IMchInfoService;
import org.xxpay.boot.web.PayChannelService; import org.xxpay.boot.service.IPayChannelService;
import org.xxpay.boot.web.PayOrderService; import org.xxpay.boot.service.IPayOrderService;
import org.xxpay.common.constant.PayConstant; import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.util.MyLog; import org.xxpay.common.util.MyLog;
import org.xxpay.common.util.MySeq; import org.xxpay.common.util.MySeq;
...@@ -29,13 +29,13 @@ public class PayOrderController { ...@@ -29,13 +29,13 @@ public class PayOrderController {
private final MyLog _log = MyLog.getLog(PayOrderController.class); private final MyLog _log = MyLog.getLog(PayOrderController.class);
@Autowired @Autowired
private PayOrderService payOrderService; private IPayOrderService payOrderService;
@Autowired @Autowired
private PayChannelService payChannelService; private IPayChannelService payChannelService;
@Autowired @Autowired
private MchInfoService mchInfoService; private IMchInfoService mchInfoService;
/** /**
* 统一下单接口: * 统一下单接口:
......
...@@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
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;
import org.xxpay.boot.web.MchInfoService; import org.xxpay.boot.service.IMchInfoService;
import org.xxpay.boot.web.PayOrderService; import org.xxpay.boot.service.IPayOrderService;
import org.xxpay.common.constant.PayConstant; import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.util.MyLog; import org.xxpay.common.util.MyLog;
import org.xxpay.common.util.XXPayUtil; import org.xxpay.common.util.XXPayUtil;
...@@ -27,10 +27,10 @@ public class QueryPayOrderController { ...@@ -27,10 +27,10 @@ public class QueryPayOrderController {
private final MyLog _log = MyLog.getLog(QueryPayOrderController.class); private final MyLog _log = MyLog.getLog(QueryPayOrderController.class);
@Autowired @Autowired
private PayOrderService payOrderService; private IPayOrderService payOrderService;
@Autowired @Autowired
private MchInfoService mchInfoService; private IMchInfoService mchInfoService;
/** /**
* 查询支付订单接口: * 查询支付订单接口:
......
package org.xxpay.boot.service; package org.xxpay.boot.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map; import java.util.Map;
/** /**
...@@ -11,4 +13,6 @@ public interface IMchInfoService { ...@@ -11,4 +13,6 @@ public interface IMchInfoService {
Map selectMchInfo(String jsonParam); Map selectMchInfo(String jsonParam);
JSONObject getByMchId(String mchId);
} }
...@@ -14,4 +14,8 @@ public interface INotifyPayService { ...@@ -14,4 +14,8 @@ public interface INotifyPayService {
Map doWxPayNotify(String jsonParam); Map doWxPayNotify(String jsonParam);
Map sendBizPayNotify(String jsonParam); Map sendBizPayNotify(String jsonParam);
String handleAliPayNotify(Map params);
String handleWxPayNotify(String xmlResult);
} }
package org.xxpay.boot.service; package org.xxpay.boot.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map; import java.util.Map;
/** /**
...@@ -11,4 +13,5 @@ public interface IPayChannelService { ...@@ -11,4 +13,5 @@ public interface IPayChannelService {
Map selectPayChannel(String jsonParam); Map selectPayChannel(String jsonParam);
JSONObject getByMchIdAndChannelId(String mchId, String channelId);
} }
package org.xxpay.boot.service; package org.xxpay.boot.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map; import java.util.Map;
/** /**
...@@ -25,4 +27,12 @@ public interface IPayOrderService { ...@@ -25,4 +27,12 @@ public interface IPayOrderService {
Map updateNotify(String jsonParam); Map updateNotify(String jsonParam);
int createPayOrder(JSONObject payOrder);
JSONObject queryPayOrder(String mchId, String payOrderId, String mchOrderNo, String executeNotify);
String doWxPayReq(String tradeType, JSONObject payOrder, String resKey);
String doAliPayReq(String channelId, JSONObject payOrder, String resKey);
} }
package org.xxpay.boot.service.impl; package org.xxpay.boot.service.impl;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.xxpay.boot.service.BaseService; import org.xxpay.boot.service.BaseService;
import org.xxpay.boot.service.IMchInfoService; import org.xxpay.boot.service.IMchInfoService;
...@@ -11,6 +12,7 @@ import org.xxpay.common.util.ObjectValidUtil; ...@@ -11,6 +12,7 @@ import org.xxpay.common.util.ObjectValidUtil;
import org.xxpay.common.util.RpcUtil; import org.xxpay.common.util.RpcUtil;
import org.xxpay.dal.dao.model.MchInfo; import org.xxpay.dal.dao.model.MchInfo;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -41,4 +43,14 @@ public class MchInfoServiceImpl extends BaseService implements IMchInfoService { ...@@ -41,4 +43,14 @@ public class MchInfoServiceImpl extends BaseService implements IMchInfoService {
String jsonResult = JsonUtil.object2Json(mchInfo); String jsonResult = JsonUtil.object2Json(mchInfo);
return RpcUtil.createBizResult(baseParam, jsonResult); return RpcUtil.createBizResult(baseParam, jsonResult);
} }
public JSONObject getByMchId(String mchId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("mchId", mchId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = selectMchInfo(jsonParam);
String s = RpcUtil.mkRet(result);
if(s==null) return null;
return JSONObject.parseObject(s);
}
} }
...@@ -290,5 +290,26 @@ public class NotifyPayServiceImpl extends Notify4BasePay implements INotifyPaySe ...@@ -290,5 +290,26 @@ public class NotifyPayServiceImpl extends Notify4BasePay implements INotifyPaySe
return true; return true;
} }
public String handleAliPayNotify(Map params) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("params", params);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = doAliPayNotify(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) {
return PayConstant.RETURN_ALIPAY_VALUE_FAIL;
}
return s;
}
public String handleWxPayNotify(String xmlResult) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("xmlResult", xmlResult);
String jsonParam = RpcUtil.createBaseParam(paramMap);
// 返回给微信的数据格式已经有service处理(包括正确与错误),肯定会返回result
Map<String, Object> result = doWxPayNotify(jsonParam);
return RpcUtil.mkRet(result);
}
} }
package org.xxpay.boot.service.impl; package org.xxpay.boot.service.impl;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.xxpay.boot.service.BaseService; import org.xxpay.boot.service.BaseService;
import org.xxpay.boot.service.IPayChannelService; import org.xxpay.boot.service.IPayChannelService;
...@@ -11,6 +12,7 @@ import org.xxpay.common.util.ObjectValidUtil; ...@@ -11,6 +12,7 @@ import org.xxpay.common.util.ObjectValidUtil;
import org.xxpay.common.util.RpcUtil; import org.xxpay.common.util.RpcUtil;
import org.xxpay.dal.dao.model.PayChannel; import org.xxpay.dal.dao.model.PayChannel;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -42,4 +44,15 @@ public class PayChannelServiceImpl extends BaseService implements IPayChannelSer ...@@ -42,4 +44,15 @@ public class PayChannelServiceImpl extends BaseService implements IPayChannelSer
String jsonResult = JsonUtil.object2Json(payChannel); String jsonResult = JsonUtil.object2Json(payChannel);
return RpcUtil.createBizResult(baseParam, jsonResult); return RpcUtil.createBizResult(baseParam, jsonResult);
} }
public JSONObject getByMchIdAndChannelId(String mchId, String channelId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("mchId", mchId);
paramMap.put("channelId", channelId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = selectPayChannel(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) return null;
return JSONObject.parseObject(s);
}
} }
package org.xxpay.boot.service.impl; package org.xxpay.boot.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.xxpay.boot.service.BaseService; import org.xxpay.boot.service.*;
import org.xxpay.boot.service.IPayOrderService; import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.domain.BaseParam; import org.xxpay.common.domain.BaseParam;
import org.xxpay.common.enumm.RetEnum; import org.xxpay.common.enumm.RetEnum;
import org.xxpay.common.util.*; import org.xxpay.common.util.*;
import org.xxpay.dal.dao.model.PayOrder; import org.xxpay.dal.dao.model.PayOrder;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -21,6 +24,100 @@ public class PayOrderServiceImpl extends BaseService implements IPayOrderService ...@@ -21,6 +24,100 @@ public class PayOrderServiceImpl extends BaseService implements IPayOrderService
private static final MyLog _log = MyLog.getLog(PayOrderServiceImpl.class); private static final MyLog _log = MyLog.getLog(PayOrderServiceImpl.class);
@Autowired
private INotifyPayService notifyPayService;
@Autowired
private IPayChannel4WxService payChannel4WxService;
@Autowired
private IPayChannel4AliService payChannel4AliService;
public int createPayOrder(JSONObject payOrder) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("payOrder", payOrder);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = createPayOrder(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) return 0;
return Integer.parseInt(s);
}
public JSONObject queryPayOrder(String mchId, String payOrderId, String mchOrderNo, String executeNotify) {
Map<String,Object> paramMap = new HashMap<>();
Map<String, Object> result;
if(StringUtils.isNotBlank(payOrderId)) {
paramMap.put("mchId", mchId);
paramMap.put("payOrderId", payOrderId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
result = selectPayOrderByMchIdAndPayOrderId(jsonParam);
}else {
paramMap.put("mchId", mchId);
paramMap.put("mchOrderNo", mchOrderNo);
String jsonParam = RpcUtil.createBaseParam(paramMap);
result = selectPayOrderByMchIdAndMchOrderNo(jsonParam);
}
String s = RpcUtil.mkRet(result);
if(s == null) return null;
boolean isNotify = Boolean.parseBoolean(executeNotify);
JSONObject payOrder = JSONObject.parseObject(s);
if(isNotify) {
paramMap = new HashMap<>();
paramMap.put("payOrderId", payOrderId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
result = notifyPayService.sendBizPayNotify(jsonParam);
s = RpcUtil.mkRet(result);
_log.info("业务查单完成,并再次发送业务支付通知.发送结果:{}", s);
}
return payOrder;
}
public String doWxPayReq(String tradeType, JSONObject payOrder, String resKey) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("tradeType", tradeType);
paramMap.put("payOrder", payOrder);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = payChannel4WxService.doWxPayReq(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) {
return XXPayUtil.makeRetData(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_FAIL, "0111", "调用微信支付失败"), resKey);
}
Map<String, Object> map = XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_SUCCESS, null);
map.putAll((Map) result.get("bizResult"));
return XXPayUtil.makeRetData(map, resKey);
}
public String doAliPayReq(String channelId, JSONObject payOrder, String resKey) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("payOrder", payOrder);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result;
switch (channelId) {
case PayConstant.PAY_CHANNEL_ALIPAY_MOBILE :
result = payChannel4AliService.doAliPayMobileReq(jsonParam);
break;
case PayConstant.PAY_CHANNEL_ALIPAY_PC :
result = payChannel4AliService.doAliPayPcReq(jsonParam);
break;
case PayConstant.PAY_CHANNEL_ALIPAY_WAP :
result = payChannel4AliService.doAliPayWapReq(jsonParam);
break;
case PayConstant.PAY_CHANNEL_ALIPAY_QR :
result = payChannel4AliService.doAliPayQrReq(jsonParam);
break;
default:
result = null;
break;
}
String s = RpcUtil.mkRet(result);
if(s == null) {
return XXPayUtil.makeRetData(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_FAIL, "0111", "调用支付宝支付失败"), resKey);
}
Map<String, Object> map = XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_SUCCESS, null);
map.putAll((Map) result.get("bizResult"));
return XXPayUtil.makeRetData(map, resKey);
}
@Override @Override
public Map createPayOrder(String jsonParam) { public Map createPayOrder(String jsonParam) {
BaseParam baseParam = JsonUtil.getObjectFromJson(jsonParam, BaseParam.class); BaseParam baseParam = JsonUtil.getObjectFromJson(jsonParam, BaseParam.class);
......
package org.xxpay.boot.web;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xxpay.common.util.RpcUtil;
import java.util.HashMap;
import java.util.Map;
/**
* @author: dingzhiwei
* @date: 17/9/9
* @description:
*/
@Service
public class MchInfoService {
@Autowired
private RpcCommonService rpcCommonService;
public JSONObject getByMchId(String mchId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("mchId", mchId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = rpcCommonService.rpcMchInfoService.selectMchInfo(jsonParam);
String s = RpcUtil.mkRet(result);
if(s==null) return null;
return JSONObject.parseObject(s);
}
}
package org.xxpay.boot.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.util.RpcUtil;
import java.util.HashMap;
import java.util.Map;
/**
* @author: dingzhiwei
* @date: 17/9/10
* @description:
*/
@Service
public class NotifyPayService {
@Autowired
private RpcCommonService rpcCommonService;
public String doAliPayNotify(Map params) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("params", params);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = rpcCommonService.rpcNotifyPayService.doAliPayNotify(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) {
return PayConstant.RETURN_ALIPAY_VALUE_FAIL;
}
return s;
}
public String doWxPayNotify(String xmlResult) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("xmlResult", xmlResult);
String jsonParam = RpcUtil.createBaseParam(paramMap);
// 返回给微信的数据格式已经有service处理(包括正确与错误),肯定会返回result
Map<String, Object> result = rpcCommonService.rpcNotifyPayService.doWxPayNotify(jsonParam);
return RpcUtil.mkRet(result);
}
}
package org.xxpay.boot.web;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xxpay.common.util.RpcUtil;
import java.util.HashMap;
import java.util.Map;
/**
* @author: dingzhiwei
* @date: 17/9/9
* @description:
*/
@Service
public class PayChannelService {
@Autowired
private RpcCommonService rpcCommonService;
public JSONObject getByMchIdAndChannelId(String mchId, String channelId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("mchId", mchId);
paramMap.put("channelId", channelId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = rpcCommonService.rpcPayChannelService.selectPayChannel(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) return null;
return JSONObject.parseObject(s);
}
}
package org.xxpay.boot.web;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.util.MyLog;
import org.xxpay.common.util.RpcUtil;
import org.xxpay.common.util.XXPayUtil;
import java.util.HashMap;
import java.util.Map;
/**
* @author: dingzhiwei
* @date: 17/9/9
* @description:
*/
@Service
public class PayOrderService {
private static final MyLog _log = MyLog.getLog(PayOrderService.class);
@Autowired
private RpcCommonService rpcCommonService;
public int createPayOrder(JSONObject payOrder) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("payOrder", payOrder);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = rpcCommonService.rpcPayOrderService.createPayOrder(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) return 0;
return Integer.parseInt(s);
}
public JSONObject queryPayOrder(String mchId, String payOrderId, String mchOrderNo, String executeNotify) {
Map<String,Object> paramMap = new HashMap<>();
Map<String, Object> result;
if(StringUtils.isNotBlank(payOrderId)) {
paramMap.put("mchId", mchId);
paramMap.put("payOrderId", payOrderId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
result = rpcCommonService.rpcPayOrderService.selectPayOrderByMchIdAndPayOrderId(jsonParam);
}else {
paramMap.put("mchId", mchId);
paramMap.put("mchOrderNo", mchOrderNo);
String jsonParam = RpcUtil.createBaseParam(paramMap);
result = rpcCommonService.rpcPayOrderService.selectPayOrderByMchIdAndMchOrderNo(jsonParam);
}
String s = RpcUtil.mkRet(result);
if(s == null) return null;
boolean isNotify = Boolean.parseBoolean(executeNotify);
JSONObject payOrder = JSONObject.parseObject(s);
if(isNotify) {
paramMap = new HashMap<>();
paramMap.put("payOrderId", payOrderId);
String jsonParam = RpcUtil.createBaseParam(paramMap);
result = rpcCommonService.rpcNotifyPayService.sendBizPayNotify(jsonParam);
s = RpcUtil.mkRet(result);
_log.info("业务查单完成,并再次发送业务支付通知.发送结果:{}", s);
}
return payOrder;
}
public String doWxPayReq(String tradeType, JSONObject payOrder, String resKey) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("tradeType", tradeType);
paramMap.put("payOrder", payOrder);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result = rpcCommonService.rpcPayChannel4WxService.doWxPayReq(jsonParam);
String s = RpcUtil.mkRet(result);
if(s == null) {
return XXPayUtil.makeRetData(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_FAIL, "0111", "调用微信支付失败"), resKey);
}
Map<String, Object> map = XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_SUCCESS, null);
map.putAll((Map) result.get("bizResult"));
return XXPayUtil.makeRetData(map, resKey);
}
public String doAliPayReq(String channelId, JSONObject payOrder, String resKey) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("payOrder", payOrder);
String jsonParam = RpcUtil.createBaseParam(paramMap);
Map<String, Object> result;
switch (channelId) {
case PayConstant.PAY_CHANNEL_ALIPAY_MOBILE :
result = rpcCommonService.rpcPayChannel4AliService.doAliPayMobileReq(jsonParam);
break;
case PayConstant.PAY_CHANNEL_ALIPAY_PC :
result = rpcCommonService.rpcPayChannel4AliService.doAliPayPcReq(jsonParam);
break;
case PayConstant.PAY_CHANNEL_ALIPAY_WAP :
result = rpcCommonService.rpcPayChannel4AliService.doAliPayWapReq(jsonParam);
break;
case PayConstant.PAY_CHANNEL_ALIPAY_QR :
result = rpcCommonService.rpcPayChannel4AliService.doAliPayQrReq(jsonParam);
break;
default:
result = null;
break;
}
String s = RpcUtil.mkRet(result);
if(s == null) {
return XXPayUtil.makeRetData(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_FAIL, "0111", "调用支付宝支付失败"), resKey);
}
Map<String, Object> map = XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_SUCCESS, null);
map.putAll((Map) result.get("bizResult"));
return XXPayUtil.makeRetData(map, resKey);
}
}
package org.xxpay.boot.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xxpay.boot.service.*;
/**
* @author: dingzhiwei
* @date: 17/9/10
* @description:
*/
@Service
public class RpcCommonService {
@Autowired
public IMchInfoService rpcMchInfoService;
@Autowired
public IPayChannelService rpcPayChannelService;
@Autowired
public IPayOrderService rpcPayOrderService;
@Autowired
public IPayChannel4WxService rpcPayChannel4WxService;
@Autowired
public IPayChannel4AliService rpcPayChannel4AliService;
@Autowired
public INotifyPayService rpcNotifyPayService;
}
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