|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.api.controller.v1; |
|
|
|
package com.api.controller.v1; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.hfkj.channel.lakala.LaKaLaTradeMergeService; |
|
|
|
|
|
|
|
import com.hfkj.channel.lakala.LaKaLaTradeService; |
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
@ -63,6 +65,60 @@ public class TestController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BsMerService merService; |
|
|
|
private BsMerService merService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/preorder",method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "合单支付") |
|
|
|
|
|
|
|
public Object preorder(@RequestParam(value = "transType" , required = true) String transType, |
|
|
|
|
|
|
|
@RequestParam(value = "payMode" , required = true) String payMode) { |
|
|
|
|
|
|
|
log.info("========= Start 分账发起接口 Start ==========="); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Map<String,Object> reqBody = new HashMap<>(); |
|
|
|
|
|
|
|
reqBody.put("merchantNo", "2023041916292112804"); |
|
|
|
|
|
|
|
reqBody.put("outTradeNo", DateUtil.date2String(new Date(),DateUtil.YMDHMS)+ IDGenerator.nextId(2)); |
|
|
|
|
|
|
|
reqBody.put("totalAmount", "1.5"); |
|
|
|
|
|
|
|
reqBody.put("subject", "测试交易"); |
|
|
|
|
|
|
|
reqBody.put("notifyUrl", "https://gratia-pay.dctpay.com/openApi/v1/payNotify/test"); |
|
|
|
|
|
|
|
reqBody.put("transType", transType);//"NATIVE" "JSAP I"
|
|
|
|
|
|
|
|
reqBody.put("payMode", payMode); // WECHAT ALIPAY UQRCODEPAY
|
|
|
|
|
|
|
|
reqBody.put("profitSharing", 0); |
|
|
|
|
|
|
|
if (payMode.equals("ALIPAY")) { |
|
|
|
|
|
|
|
reqBody.put("userId", "2088612673845396"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
reqBody.put("subAppid", "wxa075e8509802f826"); |
|
|
|
|
|
|
|
reqBody.put("userId", "od8qG06bHnTsDWklsB2VsssLZYcQ"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
reqBody.put("attach", "测试附加域"); |
|
|
|
|
|
|
|
reqBody.put("specialField", "测试特殊字段"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* List<Map<String,Object>> outSplitInfoList = new ArrayList<>(); |
|
|
|
|
|
|
|
Map<String,Object> outSplitInfo1 = new HashMap<>(); |
|
|
|
|
|
|
|
outSplitInfo1.put("outSubTradeNo", MapUtils.getString(reqBody,"outTradeNo")+"_1"); |
|
|
|
|
|
|
|
outSplitInfo1.put("merchantNo", "2023041916292112804"); |
|
|
|
|
|
|
|
outSplitInfo1.put("amount", "1"); |
|
|
|
|
|
|
|
outSplitInfoList.add(outSplitInfo1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> outSplitInfo2 = new HashMap<>(); |
|
|
|
|
|
|
|
outSplitInfo2.put("outSubTradeNo", MapUtils.getString(reqBody,"outTradeNo")+"_2"); |
|
|
|
|
|
|
|
outSplitInfo2.put("merchantNo", "2024061217292423201"); |
|
|
|
|
|
|
|
outSplitInfo2.put("amount", "0.5"); |
|
|
|
|
|
|
|
outSplitInfoList.add(outSplitInfo2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reqBody.put("outSplitInfo", outSplitInfoList);*/ |
|
|
|
|
|
|
|
reqBody.put("sign", SignatureUtil.createSign(reqBody,merKeyService.getKeyByMerNo(MapUtils.getString(reqBody,"merchantNo")))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject object = HttpsUtils.doPost("http://localhost:9605/openApi/v1/trade/preorder", JSONObject.parseObject(JSONObject.toJSONString(reqBody))); |
|
|
|
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(object)); |
|
|
|
|
|
|
|
return object; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
log.info("========= END 分账发起接口 END ==========="); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/mergePreorder",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/mergePreorder",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "合单支付") |
|
|
|
@ApiOperation(value = "合单支付") |
|
|
@ -71,12 +127,12 @@ public class TestController { |
|
|
|
log.info("========= Start 分账发起接口 Start ==========="); |
|
|
|
log.info("========= Start 分账发起接口 Start ==========="); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Map<String,Object> reqBody = new HashMap<>(); |
|
|
|
Map<String,Object> reqBody = new HashMap<>(); |
|
|
|
reqBody.put("merchantNo", "2023090616352962600"); |
|
|
|
reqBody.put("merchantNo", "2023041916292112804"); |
|
|
|
reqBody.put("outTradeNo", DateUtil.date2String(new Date(),DateUtil.YMDHMS)+ IDGenerator.nextId(2)); |
|
|
|
reqBody.put("outTradeNo", DateUtil.date2String(new Date(),DateUtil.YMDHMS)+ IDGenerator.nextId(2)); |
|
|
|
reqBody.put("totalAmount", "1"); |
|
|
|
reqBody.put("totalAmount", "1.5"); |
|
|
|
reqBody.put("subject", "测试交易"); |
|
|
|
reqBody.put("subject", "测试交易"); |
|
|
|
reqBody.put("notifyUrl", "https://gratia-pay.dctpay.com/openApi/v1/payNotify/test"); |
|
|
|
reqBody.put("notifyUrl", "https://gratia-pay.dctpay.com/openApi/v1/payNotify/test"); |
|
|
|
reqBody.put("transType", transType);//"NATIVE" "JSAPI"
|
|
|
|
reqBody.put("transType", transType);//"NATIVE" "JSAP I"
|
|
|
|
reqBody.put("payMode", payMode); // WECHAT ALIPAY UQRCODEPAY
|
|
|
|
reqBody.put("payMode", payMode); // WECHAT ALIPAY UQRCODEPAY
|
|
|
|
if (payMode.equals("ALIPAY")) { |
|
|
|
if (payMode.equals("ALIPAY")) { |
|
|
|
reqBody.put("userId", "2088612673845396"); |
|
|
|
reqBody.put("userId", "2088612673845396"); |
|
|
@ -90,13 +146,13 @@ public class TestController { |
|
|
|
List<Map<String,Object>> outSplitInfoList = new ArrayList<>(); |
|
|
|
List<Map<String,Object>> outSplitInfoList = new ArrayList<>(); |
|
|
|
Map<String,Object> outSplitInfo1 = new HashMap<>(); |
|
|
|
Map<String,Object> outSplitInfo1 = new HashMap<>(); |
|
|
|
outSplitInfo1.put("outSubTradeNo", MapUtils.getString(reqBody,"outTradeNo")+"_1"); |
|
|
|
outSplitInfo1.put("outSubTradeNo", MapUtils.getString(reqBody,"outTradeNo")+"_1"); |
|
|
|
outSplitInfo1.put("merchantNo", "2023090616352962600"); |
|
|
|
outSplitInfo1.put("merchantNo", "2023041916292112804"); |
|
|
|
outSplitInfo1.put("amount", "0.5"); |
|
|
|
outSplitInfo1.put("amount", "1"); |
|
|
|
outSplitInfoList.add(outSplitInfo1); |
|
|
|
outSplitInfoList.add(outSplitInfo1); |
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> outSplitInfo2 = new HashMap<>(); |
|
|
|
Map<String,Object> outSplitInfo2 = new HashMap<>(); |
|
|
|
outSplitInfo2.put("outSubTradeNo", MapUtils.getString(reqBody,"outTradeNo")+"_2"); |
|
|
|
outSplitInfo2.put("outSubTradeNo", MapUtils.getString(reqBody,"outTradeNo")+"_2"); |
|
|
|
outSplitInfo2.put("merchantNo", "2023091316462069203"); |
|
|
|
outSplitInfo2.put("merchantNo", "2024061217292423201"); |
|
|
|
outSplitInfo2.put("amount", "0.5"); |
|
|
|
outSplitInfo2.put("amount", "0.5"); |
|
|
|
outSplitInfoList.add(outSplitInfo2); |
|
|
|
outSplitInfoList.add(outSplitInfo2); |
|
|
|
|
|
|
|
|
|
|
@ -115,10 +171,10 @@ public class TestController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/refund",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/mergeRefund",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "合单退款") |
|
|
|
@ApiOperation(value = "合单退款") |
|
|
|
public Object refund(@RequestBody JSONObject body) { |
|
|
|
public Object mergeRefund(@RequestBody JSONObject body) { |
|
|
|
log.info("========= Start 查询交易 Start ==========="); |
|
|
|
log.info("========= Start 查询交易 Start ==========="); |
|
|
|
try { |
|
|
|
try { |
|
|
|
BsTradeOrderMerge orderMerge = tradeOrderMergeService.getOrderMerge(body.getString("outTradeNo")); |
|
|
|
BsTradeOrderMerge orderMerge = tradeOrderMergeService.getOrderMerge(body.getString("outTradeNo")); |
|
|
@ -158,6 +214,36 @@ public class TestController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/refund",method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "交易退款") |
|
|
|
|
|
|
|
public Object refund(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
log.info("========= Start 查询交易 Start ==========="); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
BsTradeOrder tradeOrder = tradeOrderService.getOrderByOutTradeNo(body.getString("outTradeNo")); |
|
|
|
|
|
|
|
if (tradeOrder == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "错误的订单"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String,Object> reqBody = new HashMap<>(); |
|
|
|
|
|
|
|
reqBody.put("merchantNo", tradeOrder.getMerNo()); |
|
|
|
|
|
|
|
reqBody.put("outTradeNo", tradeOrder.getOutTradeNo()); |
|
|
|
|
|
|
|
reqBody.put("refundTradeNo", "R"+DateUtil.date2String(new Date(),DateUtil.YMDHMS)+IDGenerator.nextId(2)); |
|
|
|
|
|
|
|
reqBody.put("refundAmount", body.getBigDecimal("refundAmount")); |
|
|
|
|
|
|
|
reqBody.put("refundReason", "测试退款"); |
|
|
|
|
|
|
|
reqBody.put("sign", SignatureUtil.createSign(reqBody,merKeyService.getKeyByMerNo(MapUtils.getString(reqBody,"merchantNo")))); |
|
|
|
|
|
|
|
System.out.println("请求接口参数:"+JSONObject.toJSONString(reqBody)); |
|
|
|
|
|
|
|
JSONObject object = HttpsUtils.doPost("http://localhost:9605/openApi/v1/trade/refund", JSONObject.parseObject(JSONObject.toJSONString(reqBody))); |
|
|
|
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(object)); |
|
|
|
|
|
|
|
return object; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
log.info("========= END 查询交易 END ==========="); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryTrade",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/queryTrade",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "查询交易") |
|
|
|
@ApiOperation(value = "查询交易") |
|
|
@ -184,6 +270,26 @@ public class TestController { |
|
|
|
log.info("========= END 查询交易 END ==========="); |
|
|
|
log.info("========= END 查询交易 END ==========="); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private LaKaLaTradeService laKaLaTradeService; |
|
|
|
|
|
|
|
@RequestMapping(value="/lklQueryTrade",method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "查询交易") |
|
|
|
|
|
|
|
public Object lklQueryTrade(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
log.info("========= Start 查询交易 Start ==========="); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//return laKaLaTradeService.queryTrade(body.getString("outTradeNo"));
|
|
|
|
|
|
|
|
//return laKaLaTradeService.queryTradeOrderTrans(body.getString("outTradeNo"));
|
|
|
|
|
|
|
|
return laKaLaTradeService.queryTradeOrderRefundTrans(body.getString("outTradeNo")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
log.info("========= END 查询交易 END ==========="); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|