From ea2218beb84b367e762dae6f9a657a9864e31bcd Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Mon, 30 Dec 2024 10:07:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BsDiscountController.java | 57 +++++++++++++++++++ .../hfkj/common/pay/util/SignatureUtil.java | 8 +-- .../RequestQueryPkDiscountListModel.java | 33 +++++++++++ .../ResponseQueryPkDiscountListModel.java | 36 ++++++++++++ .../order/impl/BsOrderRefundServiceImpl.java | 9 ++- 5 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountListModel.java create mode 100644 service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountListModel.java diff --git a/openapi/src/main/java/com/openapi/controller/BsDiscountController.java b/openapi/src/main/java/com/openapi/controller/BsDiscountController.java index 3971062..1f170e9 100644 --- a/openapi/src/main/java/com/openapi/controller/BsDiscountController.java +++ b/openapi/src/main/java/com/openapi/controller/BsDiscountController.java @@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; @Controller @RequestMapping(value = "/discount") @@ -122,6 +123,62 @@ public class BsDiscountController { } } + @RequestMapping(value="/queryPkList",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询优惠券包列表") + public ResponseData queryPkList(@Validated @RequestBody RequestQueryPkDiscountListModel body) { + log.info("========= Start 查询优惠券包列表 Start ==========="); + log.info("请求参数:" + JSONObject.toJSONString(body)); + BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); + try { + // 验证签名 + BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); + if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { + throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); + } + // 验证请求id + if (agentApiLogService.isExist(body.getAppId(), body.getReqId())) { + throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_REQ_ID_ERR, ""); + } + apiLog.setAppId(body.getAppId()); + apiLog.setRequestId(body.getReqId()); + apiLog.setRequestUrl("discount/queryPkList"); + apiLog.setRequestParam(JSONObject.toJSONString(body)); + + ResponseQueryPkDiscountListModel response = new ResponseQueryPkDiscountListModel(); + response.setAppId(body.getAppId()); + response.setReqId(body.getReqId()); + response.setDataList(new LinkedList<>()); + + // 券包中的优惠券列表 + List list = agentDiscountService.getList(apiParam.getAgentId()).stream().filter(o->o.getType().equals(2)).collect(Collectors.toList()); + for (BsAgentDiscount discount : list) { + JSONObject discountObj = new JSONObject(); + discountObj.put("discountPkNo", discount.getObjectNo()); + discountObj.put("discountPkName", discount.getObjectName()); + response.getDataList().add(discountObj); + } + response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret())); + log.info("返回参数:" + JSONObject.toJSONString(response)); + apiLog.setResponseParam(JSONObject.toJSONString(response)); + + return ResponseMsgUtil.success(response); + + } catch (Exception e) { + log.info("出现异常:", e); + // 异常内容 + ResponseData exception = ResponseMsgUtil.exception(e); + apiLog.setErrorContent(JSONObject.toJSONString(exception)); + return exception; + } finally { + // 记录日志 + if (apiLog.getAppId() != null) { + agentApiLogService.edit(apiLog); + } + log.info("========= END 查询优惠券包列表 END ==========="); + } + } + @RequestMapping(value="/queryPkDetail",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询优惠券包详情") diff --git a/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java b/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java index 000afbc..74be8a1 100644 --- a/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java +++ b/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java @@ -86,12 +86,10 @@ public class SignatureUtil { public static void main(String[] args) throws Exception { String paramStr = "{\n" + - " \"appId\": \"hf7356c71fb97ab0\",\n" + - " \"phone\": \"15983485280\",\n" + - " \"reqId\": \"test10001\",\n" + - " \"status\":1" + + " \"appId\": \"hffeab7fdb44d4f1\",\n" + + " \"orderNo\": \"test10001\"\n" + "}"; - String sign = createSign(JSONObject.parseObject(paramStr), "8aef995ff71485dc19b36e35f04c4016"); + String sign = createSign(JSONObject.parseObject(paramStr), "3a9b2772b9a2d319a9b18e55fa30246d"); System.out.println(sign); } diff --git a/service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountListModel.java b/service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountListModel.java new file mode 100644 index 0000000..806da89 --- /dev/null +++ b/service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountListModel.java @@ -0,0 +1,33 @@ +package com.hfkj.openapi.model.request; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @className: RequestQueryDiscountListModel + * @author: HuRui + * @date: 2024/9/1 + **/ +@Data +public class RequestQueryPkDiscountListModel { + + /** + * appid + */ + @NotBlank(message = "请求id必填项") + private String reqId; + + /** + * appid + */ + @NotBlank(message = "appId必填项") + private String appId; + + /** + * 签名参数 + */ + @NotBlank(message = "签名必填项") + private String sign; + +} diff --git a/service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountListModel.java b/service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountListModel.java new file mode 100644 index 0000000..2652110 --- /dev/null +++ b/service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountListModel.java @@ -0,0 +1,36 @@ +package com.hfkj.openapi.model.response; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @className: RequestQueryDiscountListModel + * @author: HuRui + * @date: 2024/9/1 + **/ +@Data +public class ResponseQueryPkDiscountListModel { + + /** + * appid + */ + private String reqId; + + /** + * appid + */ + private String appId; + + /** + * 数据列表 + */ + List dataList; + + /** + * 签名参数 + */ + private String sign; + +} diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java index a132f28..76e9978 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java @@ -221,10 +221,15 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { if (gasOrder == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的加油订单"); } - if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber()) - || gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type3.getNumber())) { + if (gasOrder.getAbnormal().equals(true)) { orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); editData(orderRefund); + } else { + if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber()) + || gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type3.getNumber())) { + orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); + editData(orderRefund); + } } } else { orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode());