parent
a5be76e1d4
commit
407e746d57
@ -0,0 +1,218 @@ |
|||||||
|
package com.api.controller.v1; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.entity.BsTradeOrder; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import com.hfkj.openapi.v1.model.request.RequestSeparateModel; |
||||||
|
import com.hfkj.openapi.v1.model.request.RequestTradePreorderModel; |
||||||
|
import com.hfkj.openapi.v1.service.OpenApiTradeOrderService; |
||||||
|
import com.hfkj.openapi.v1.utils.SignatureUtil; |
||||||
|
import com.hfkj.service.BsMerKeyService; |
||||||
|
import com.hfkj.sysenum.TradeOrderStatusEnum; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.validation.annotation.Validated; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: LedgerController |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/26 |
||||||
|
**/ |
||||||
|
@Controller |
||||||
|
@Api(value = "交易订单") |
||||||
|
@RequestMapping(value = "/v1/ledger") |
||||||
|
public class LedgerController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(TradeController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsMerKeyService merKeyService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private OpenApiTradeOrderService openApiTradeOrderService; |
||||||
|
|
||||||
|
@RequestMapping(value="/applyBind",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账关系申请") |
||||||
|
public ResponseData applyBind(@Validated @RequestBody RequestTradePreorderModel body) { |
||||||
|
log.info("========= Start 聚合主扫接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 聚合主扫接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/applyUnBind",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账关系解绑申请") |
||||||
|
public ResponseData applyUnBind(@Validated @RequestBody RequestTradePreorderModel body) { |
||||||
|
log.info("========= Start 聚合主扫接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 聚合主扫接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/separate",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账发起") |
||||||
|
public ResponseData separate(@Validated @RequestBody RequestSeparateModel body) { |
||||||
|
log.info("========= Start 分账发起接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
// 查询交易订单
|
||||||
|
BsTradeOrder tradeOrder = openApiTradeOrderService.getOrderByOutTradeNo(body.getOutTradeNo()); |
||||||
|
if (tradeOrder == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未知的交易单号"); |
||||||
|
} |
||||||
|
if (!tradeOrder.getStatus().equals(TradeOrderStatusEnum.status3.getNumber())) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "交易订单不处于已支付"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 分账发起接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/cancel",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账撤销") |
||||||
|
public ResponseData cancel(@Validated @RequestBody RequestTradePreorderModel body) { |
||||||
|
log.info("========= Start 分账撤销接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 分账撤销接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/fallback",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账退回") |
||||||
|
public ResponseData fallback(@Validated @RequestBody RequestTradePreorderModel body) { |
||||||
|
log.info("========= Start 分账退回接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 分账退回接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/query",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账结果查询") |
||||||
|
public ResponseData query(@Validated @RequestBody RequestTradePreorderModel body) { |
||||||
|
log.info("========= Start 分账结果查询接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 分账结果查询接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/queryAmt",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "可分账金额查询") |
||||||
|
public ResponseData queryAmt(@Validated @RequestBody RequestTradePreorderModel body) { |
||||||
|
log.info("========= Start 可分账金额查询接口 Start ==========="); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||||
|
try { |
||||||
|
// 验证签名
|
||||||
|
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { |
||||||
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
log.info("返回参数:" + JSONObject.toJSONString(null)); |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.info("出现异常:", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} finally { |
||||||
|
log.info("========= END 可分账金额查询接口 END ==========="); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
@ -0,0 +1,62 @@ |
|||||||
|
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.hibernate.validator.constraints.Length; |
||||||
|
|
||||||
|
import javax.validation.constraints.DecimalMax; |
||||||
|
import javax.validation.constraints.DecimalMin; |
||||||
|
import javax.validation.constraints.NotBlank; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 请求分账 |
||||||
|
* @className: RequestSeparateModel |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/26 |
||||||
|
**/ |
||||||
|
@Data |
||||||
|
public class RequestSeparateModel { |
||||||
|
|
||||||
|
/** |
||||||
|
* 商户号 |
||||||
|
*/ |
||||||
|
@NotBlank(message = "商户号必填项") |
||||||
|
private String merchantNo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 商户交易单号 |
||||||
|
*/ |
||||||
|
@Length(min = 6, max = 50, message = "商户交易单号长度限制6至50位字符串长度") |
||||||
|
@NotBlank(message = "商户交易单号必填项") |
||||||
|
private String outTradeNo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 分账流水号 |
||||||
|
*/ |
||||||
|
@NotBlank(message = "分账流水号必填项") |
||||||
|
@Length(min = 6, max = 50, message = "分账流水号限制6至50位字符串长度") |
||||||
|
private String outSeparateNo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 分账总金额 |
||||||
|
*/ |
||||||
|
@NotBlank(message = "分账总金额必填项") |
||||||
|
@DecimalMin(value = "0.01", message = "分账总金额最小0.01") |
||||||
|
@DecimalMax(value = "9999999", message = "分账总金额最大9999999") |
||||||
|
private BigDecimal totalAmount; |
||||||
|
|
||||||
|
/** |
||||||
|
* 分账接收方 |
||||||
|
*/ |
||||||
|
@NotBlank(message = "分账接收方必填项") |
||||||
|
private List<RequestSeparateRecvDataModel> recvDatas; |
||||||
|
|
||||||
|
/** |
||||||
|
* 签名参数 |
||||||
|
*/ |
||||||
|
@NotBlank(message = "签名必填项") |
||||||
|
private String sign; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.hibernate.validator.constraints.Length; |
||||||
|
|
||||||
|
import javax.validation.constraints.DecimalMax; |
||||||
|
import javax.validation.constraints.DecimalMin; |
||||||
|
import javax.validation.constraints.NotBlank; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* 请求分账接收方 |
||||||
|
* @className: RequestSeparateModel |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/26 |
||||||
|
**/ |
||||||
|
@Data |
||||||
|
public class RequestSeparateRecvDataModel { |
||||||
|
|
||||||
|
@NotBlank(message = "分账接收方商户号必填项") |
||||||
|
private String recvMerchantNo; |
||||||
|
|
||||||
|
|
||||||
|
@NotBlank(message = "分账接收方金额必填项") |
||||||
|
@DecimalMin(value = "0.01", message = "分账总金额最小0.01") |
||||||
|
@DecimalMax(value = "9999999", message = "分账总金额最大9999999") |
||||||
|
private String separateAmount; |
||||||
|
|
||||||
|
} |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.request; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.response; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
@ -1,4 +1,4 @@ |
|||||||
package com.hfkj.openapi.v1.model; |
package com.hfkj.openapi.v1.model.response; |
||||||
|
|
||||||
import lombok.Data; |
import lombok.Data; |
||||||
import org.hibernate.validator.constraints.Length; |
import org.hibernate.validator.constraints.Length; |
Loading…
Reference in new issue