diff --git a/open-api/src/main/java/com/api/controller/v1/LedgerController.java b/open-api/src/main/java/com/api/controller/v1/LedgerController.java new file mode 100644 index 0000000..0053ab9 --- /dev/null +++ b/open-api/src/main/java/com/api/controller/v1/LedgerController.java @@ -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 ==========="); + } + } + + +} diff --git a/open-api/src/main/java/com/api/controller/v1/NotifyController.java b/open-api/src/main/java/com/api/controller/v1/NotifyController.java index 1ed7159..c3a1dac 100644 --- a/open-api/src/main/java/com/api/controller/v1/NotifyController.java +++ b/open-api/src/main/java/com/api/controller/v1/NotifyController.java @@ -1,32 +1,20 @@ package com.api.controller.v1; import com.alibaba.fastjson.JSONObject; -import com.ccb.wlpt.util.StringUtil; -import com.hfkj.common.exception.ErrorCode; -import com.hfkj.common.exception.ErrorHelp; -import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.HttpsUtils; -import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.BsMer; import com.hfkj.entity.BsTradeOrder; -import com.hfkj.entity.BsTradeOrderMsg; -import com.hfkj.entity.BsTradeOrderRefund; -import com.hfkj.model.ResponseData; -import com.hfkj.openapi.v1.model.*; +import com.hfkj.openapi.v1.model.response.ResponseQueryTradeModel; import com.hfkj.openapi.v1.service.OpenApiTradeOrderService; import com.hfkj.openapi.v1.utils.SignatureUtil; import com.hfkj.service.BsMerKeyService; -import com.hfkj.service.BsMerService; import com.hfkj.service.BsTradeOrderService; import com.hfkj.sysenum.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; -import org.apache.http.protocol.HTTP; 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; diff --git a/open-api/src/main/java/com/api/controller/v1/TradeController.java b/open-api/src/main/java/com/api/controller/v1/TradeController.java index b150a55..afbf645 100644 --- a/open-api/src/main/java/com/api/controller/v1/TradeController.java +++ b/open-api/src/main/java/com/api/controller/v1/TradeController.java @@ -2,7 +2,6 @@ package com.api.controller.v1; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; -import com.api.config.SysConst; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -14,6 +13,9 @@ import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.model.ResponseData; import com.hfkj.openapi.v1.model.*; +import com.hfkj.openapi.v1.model.request.*; +import com.hfkj.openapi.v1.model.response.ResponseQueryTradeModel; +import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel; import com.hfkj.openapi.v1.service.OpenApiTradeOrderService; import com.hfkj.openapi.v1.utils.SignatureUtil; import com.hfkj.service.BsMerKeyService; diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java index 1382725..72c9710 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java @@ -36,7 +36,7 @@ public class LaKaLaTradeSeparateService { private BsTradeOrderProfitSharingReceiverService tradeOrderProfitSharingReceiverService; /** - * 创建分账 + * 发起分账 * @param profitSharingOrderNo * @return */ diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/RequestQueryRefundModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestQueryRefundModel.java similarity index 94% rename from service/src/main/java/com/hfkj/openapi/v1/model/RequestQueryRefundModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/request/RequestQueryRefundModel.java index cd38a6c..b00d913 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/RequestQueryRefundModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestQueryRefundModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.request; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/RequestQueryTradeModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestQueryTradeModel.java similarity index 94% rename from service/src/main/java/com/hfkj/openapi/v1/model/RequestQueryTradeModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/request/RequestQueryTradeModel.java index 4c5b93b..fcf4d22 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/RequestQueryTradeModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestQueryTradeModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.request; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/RequestRefundTradeModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestRefundTradeModel.java similarity index 97% rename from service/src/main/java/com/hfkj/openapi/v1/model/RequestRefundTradeModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/request/RequestRefundTradeModel.java index 097f890..b6c4157 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/RequestRefundTradeModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestRefundTradeModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.request; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestSeparateModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestSeparateModel.java new file mode 100644 index 0000000..f5af498 --- /dev/null +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestSeparateModel.java @@ -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 recvDatas; + + /** + * 签名参数 + */ + @NotBlank(message = "签名必填项") + private String sign; + + +} diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestSeparateRecvDataModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestSeparateRecvDataModel.java new file mode 100644 index 0000000..4935d82 --- /dev/null +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestSeparateRecvDataModel.java @@ -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; + +} diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/RequestTradeBillsModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradeBillsModel.java similarity index 94% rename from service/src/main/java/com/hfkj/openapi/v1/model/RequestTradeBillsModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradeBillsModel.java index 3588b6d..6c9a04d 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/RequestTradeBillsModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradeBillsModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.request; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/RequestTradePreorderModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java similarity index 98% rename from service/src/main/java/com/hfkj/openapi/v1/model/RequestTradePreorderModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java index 2604684..a666a43 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/RequestTradePreorderModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.request; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/ResponseQueryTradeModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/response/ResponseQueryTradeModel.java similarity index 96% rename from service/src/main/java/com/hfkj/openapi/v1/model/ResponseQueryTradeModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/response/ResponseQueryTradeModel.java index 7a464dd..dab6417 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/ResponseQueryTradeModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/response/ResponseQueryTradeModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.response; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/ResponseRefundTradeModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/response/ResponseRefundTradeModel.java similarity index 95% rename from service/src/main/java/com/hfkj/openapi/v1/model/ResponseRefundTradeModel.java rename to service/src/main/java/com/hfkj/openapi/v1/model/response/ResponseRefundTradeModel.java index 64a31af..8da52b6 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/ResponseRefundTradeModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/response/ResponseRefundTradeModel.java @@ -1,4 +1,4 @@ -package com.hfkj.openapi.v1.model; +package com.hfkj.openapi.v1.model.response; import lombok.Data; import org.hibernate.validator.constraints.Length; diff --git a/service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java b/service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java index 9385e34..06cc353 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java +++ b/service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java @@ -2,8 +2,8 @@ package com.hfkj.openapi.v1.service; import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrderRefund; -import com.hfkj.openapi.v1.model.RequestRefundTradeModel; -import com.hfkj.openapi.v1.model.ResponseRefundTradeModel; +import com.hfkj.openapi.v1.model.request.RequestRefundTradeModel; +import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel; import com.hfkj.openapi.v1.model.TradeBillsModel; import java.util.List; diff --git a/service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java b/service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java index 68f191c..8879806 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java @@ -9,8 +9,8 @@ import com.hfkj.common.utils.DateUtil; import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.dao.OpenApiTradeOrderMapper; -import com.hfkj.openapi.v1.model.RequestRefundTradeModel; -import com.hfkj.openapi.v1.model.ResponseRefundTradeModel; +import com.hfkj.openapi.v1.model.request.RequestRefundTradeModel; +import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel; import com.hfkj.openapi.v1.model.TradeBillsModel; import com.hfkj.openapi.v1.service.OpenApiTradeOrderService; import com.hfkj.openapi.v1.utils.SignatureUtil;