提交代码

master
胡锐 4 weeks ago
parent 96acc211bf
commit ea2218beb8
  1. 57
      openapi/src/main/java/com/openapi/controller/BsDiscountController.java
  2. 8
      service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java
  3. 33
      service/src/main/java/com/hfkj/openapi/model/request/RequestQueryPkDiscountListModel.java
  4. 36
      service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryPkDiscountListModel.java
  5. 9
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.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<BsAgentDiscount> 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 = "查询优惠券包详情")

@ -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);
}

@ -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;
}

@ -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<Object> dataList;
/**
* 签名参数
*/
private String sign;
}

@ -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());

Loading…
Cancel
Save