Commit 6795121c authored by hezhen's avatar hezhen

112

parent 2b957d61
...@@ -92,14 +92,17 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -92,14 +92,17 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
if(amount <= 0) { if(amount <= 0) {
amount = 1; amount = 1;
} }
Integer type=orderPayVo.getType(); Integer type=orderPayVo.getType()==null?1:orderPayVo.getType();
String jsParam=""; String jsParam="";
String notify_url=weixinHost+"/api/universal/pay/app/unauth/notify"; String notify_url=weixinHost+"/api/universal/pay/app/unauth/notify";
log.info("报名费回调路径notify_url:"+notify_url); log.info("报名费回调路径notify_url:"+notify_url);
if(type!=null&&type==2){ Integer payWay=orderPayVo.getPayWay()==null?1:orderPayVo.getPayWay();
if(type==2&&payWay==1){
jsParam=WXPay.webPay( amount+"",orderPayVo.getBody(),notify_url,trade_no,orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount()); jsParam=WXPay.webPay( amount+"",orderPayVo.getBody(),notify_url,trade_no,orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount());
}else { }else if (type==1&&payWay==1){
jsParam = WXPay.apppay(amount+"",orderPayVo.getBody(),notify_url ,trade_no,orderPayVo.getBuyerIp(),0); jsParam = WXPay.apppay(amount+"",orderPayVo.getBody(),notify_url ,trade_no,orderPayVo.getBuyerIp(),0);
}else if (type==1&&payWay==2){
jsParam=generateAliPayment(orderPayVo);
} }
log.info("报名费回调路径jsParam:"+jsParam); log.info("报名费回调路径jsParam:"+jsParam);
if(!StringUtils.isBlank(jsParam)) if(!StringUtils.isBlank(jsParam))
...@@ -116,8 +119,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -116,8 +119,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
log.error("---下单---order_no====="+order_no+"----异常---msg==="+ e.getMessage()); log.error("---下单---order_no====="+order_no+"----异常---msg==="+ e.getMessage());
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常"); return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
} }
if (payWay==1){
JSONObject temp = JSON.parseObject(jsParam); JSONObject temp = JSON.parseObject(jsParam);
return JsonResultUtil.createSuccessResultWithObj(temp); return JsonResultUtil.createSuccessResultWithObj(temp);
}else {
return JsonResultUtil.createSuccessResultWithObj(jsParam);
}
}else{ }else{
return JsonResultUtil.createDefaultFail(); return JsonResultUtil.createDefaultFail();
} }
...@@ -258,7 +265,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -258,7 +265,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
* @return * @return
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private ObjectRestResponse generateAliPayment(OrderPayVo orderPayVo) { private String generateAliPayment(OrderPayVo orderPayVo) {
String notifyUrl = weixinHost + "/service/payment/notify/alipay"; String notifyUrl = weixinHost + "/service/payment/notify/alipay";
...@@ -275,7 +282,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -275,7 +282,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
e.printStackTrace(); e.printStackTrace();
} }
// //
return ObjectRestResponse.createDefaultFail(); return null;
} }
//支付宝APP支付方法 //支付宝APP支付方法
...@@ -309,7 +316,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -309,7 +316,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
//预授权冻结 //预授权冻结
public ObjectRestResponse fundAuthOrderAppFreeze(AlipayClient alipayClient, OrderPayVo orderPayVo) throws AlipayApiException { public String fundAuthOrderAppFreeze(AlipayClient alipayClient, OrderPayVo orderPayVo) throws AlipayApiException {
AlipayFundAuthOrderAppFreezeRequest request = new AlipayFundAuthOrderAppFreezeRequest(); AlipayFundAuthOrderAppFreezeRequest request = new AlipayFundAuthOrderAppFreezeRequest();
AlipayFundAuthOrderAppFreezeModel model = new AlipayFundAuthOrderAppFreezeModel(); AlipayFundAuthOrderAppFreezeModel model = new AlipayFundAuthOrderAppFreezeModel();
BigDecimal realAmount = new BigDecimal(orderPayVo.getAmount().toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP); BigDecimal realAmount = new BigDecimal(orderPayVo.getAmount().toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP);
...@@ -329,10 +336,10 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -329,10 +336,10 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
if(response.isSuccess()){ if(response.isSuccess()){
log.info("调用成功"); log.info("调用成功");
log.info("response: {}" + response.getBody());//签名后的参数,直接入参到 log.info("response: {}" + response.getBody());//签名后的参数,直接入参到
return ObjectRestResponse.succ(response.getBody()); return response.getBody();
} else { } else {
log.info("调用失败"); log.info("调用失败");
return ObjectRestResponse.createDefaultFail(); return null;
} }
} }
//解冻预授权 //解冻预授权
...@@ -410,23 +417,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> { ...@@ -410,23 +417,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
AlipayTradeRefundResponse response = alipayClient.execute(request); AlipayTradeRefundResponse response = alipayClient.execute(request);
log.info("response: {}"+response.getBody()); log.info("response: {}"+response.getBody());
} }
public Object generatePayment(OrderPayVo orderPayVo) {
switch (orderPayVo.getType()) {
case 1: //支付宝
ObjectRestResponse objectRestResponse = generateAliPayment(orderPayVo);
return objectRestResponse;
case 2: //微信
JSONObject jsonObject = preparepay(orderPayVo);
return jsonObject;
case 3: //银联
return null;
default:
log.info("不支持的付款类型,payType={}", orderPayVo.getType());
break;
}
return null;
}
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -36,6 +36,19 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> { ...@@ -36,6 +36,19 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> {
} }
/**
* APP支付
*
* @param orderPayVo
* @return
* @throws Exception
*/
@RequestMapping(value = "/app/unauth", method = RequestMethod.POST) //匹配的是href中的download请求
public JSONObject app(@RequestBody OrderPayVo orderPayVo) {
return baseBiz.preparepay(orderPayVo);
}
/** /**
* 支付回调 * 支付回调
* *
...@@ -88,10 +101,5 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> { ...@@ -88,10 +101,5 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> {
return baseBiz.alipayNotify(); return baseBiz.alipayNotify();
} }
@GetMapping(value = "/app/generate_payment")
public Object generatePayment(OrderPayVo orderPayVo) {
Object resp = baseBiz.generatePayment(orderPayVo);
return resp;
}
} }
\ No newline at end of file
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