提交代码

yy_dev
胡锐 2 years ago
parent 367478c18c
commit d7995316aa
  1. 12
      open-api/src/main/java/com/api/controller/v1/TradeController.java
  2. 4
      service/src/main/java/com/hfkj/openapi/v1/model/ResponseRefundTradeModel.java
  3. 2
      service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java
  4. 66
      service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java
  5. 5
      service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java

@ -9,10 +9,7 @@ import com.hfkj.entity.BsMer;
import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.openapi.v1.model.RequestQueryTradeModel; import com.hfkj.openapi.v1.model.*;
import com.hfkj.openapi.v1.model.RequestRefundTradeModel;
import com.hfkj.openapi.v1.model.RequestTradePreorderModel;
import com.hfkj.openapi.v1.model.ResponseQueryTradeModel;
import com.hfkj.openapi.v1.service.OpenApiTradeOrderService; import com.hfkj.openapi.v1.service.OpenApiTradeOrderService;
import com.hfkj.openapi.v1.utils.SignatureUtil; import com.hfkj.openapi.v1.utils.SignatureUtil;
import com.hfkj.service.BsMerKeyService; import com.hfkj.service.BsMerKeyService;
@ -141,7 +138,7 @@ public class TradeController {
responseQueryTradeModel.setPayTime(tradeOrder.getPayTime()); responseQueryTradeModel.setPayTime(tradeOrder.getPayTime());
responseQueryTradeModel.setSign(SignatureUtil.createSign(responseQueryTradeModel, merKeyService.getKeyByMerNo(body.getMerchantNo()))); responseQueryTradeModel.setSign(SignatureUtil.createSign(responseQueryTradeModel, merKeyService.getKeyByMerNo(body.getMerchantNo())));
log.info("响应参数:" + JSONObject.toJSONString(responseQueryTradeModel)); log.info("返回参数:" + JSONObject.toJSONString(responseQueryTradeModel));
return ResponseMsgUtil.success(responseQueryTradeModel); return ResponseMsgUtil.success(responseQueryTradeModel);
} catch (Exception e) { } catch (Exception e) {
@ -168,9 +165,10 @@ public class TradeController {
if (refund != null) { if (refund != null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "退款流水重复"); throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "退款流水重复");
} }
openApiTradeOrderService.refund(body);
return ResponseMsgUtil.success(null); ResponseRefundTradeModel responseRefundTradeModel = openApiTradeOrderService.refund(body);
log.info("返回参数:" + JSONObject.toJSONString(responseRefundTradeModel));
return ResponseMsgUtil.success(responseRefundTradeModel);
} catch (Exception e) { } catch (Exception e) {
log.info("出现异常:", e); log.info("出现异常:", e);

@ -43,9 +43,9 @@ public class ResponseRefundTradeModel {
private String refundAmount; private String refundAmount;
/** /**
* 退款原因 * 退款实际金额
*/ */
private String refundReason; private String refundPayerAmount;
/** /**
* 退款时间 * 退款时间

@ -32,7 +32,7 @@ public interface OpenApiTradeOrderService {
* @param refundTrade * @param refundTrade
* @return * @return
*/ */
ResponseRefundTradeModel refund(RequestRefundTradeModel refundTrade); ResponseRefundTradeModel refund(RequestRefundTradeModel refundTrade) throws Exception;
/** /**
* 根据退款单号查询退款信息 * 根据退款单号查询退款信息

@ -2,6 +2,9 @@ package com.hfkj.openapi.v1.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.channel.lakala.LaKaLaTradeService; import com.hfkj.channel.lakala.LaKaLaTradeService;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderExample; import com.hfkj.entity.BsTradeOrderExample;
import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.entity.BsTradeOrderRefund;
@ -13,12 +16,14 @@ import com.hfkj.service.BsMerKeyService;
import com.hfkj.service.BsTradeOrderRefundService; import com.hfkj.service.BsTradeOrderRefundService;
import com.hfkj.service.BsTradeOrderService; import com.hfkj.service.BsTradeOrderService;
import com.hfkj.sysenum.TradeOrderRefundStatusEnum; import com.hfkj.sysenum.TradeOrderRefundStatusEnum;
import com.hfkj.sysenum.TradeOrderStatusEnum;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Map; import java.util.Map;
/** /**
@ -65,28 +70,47 @@ public class OpenApiTradeOrderServiceImpl implements OpenApiTradeOrderService {
} }
@Override @Override
public ResponseRefundTradeModel refund(RequestRefundTradeModel refundTrade) { public ResponseRefundTradeModel refund(RequestRefundTradeModel refundTrade) throws Exception {
// 查询交易订单
BsTradeOrder tradeOrder = getOrderByOutTradeNo(refundTrade.getOutTradeNo());
/* BsTradeOrderRefund orderRefund = new BsTradeOrderRefund(); if (tradeOrder == null) {
orderRefund.setTradeOrderId(order.getId()); throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未知的交易订单");
orderRefund.setOutTradeNo(order.getOutTradeNo()); }
orderRefund.setTradeOrderId(order.getId()); if (!tradeOrder.getStatus().equals(TradeOrderStatusEnum.status3.getNumber())) {
orderRefund.setAgentId(order.getAgentId()); throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "交易订单状态不处于已支付");
orderRefund.setSalesmanId(order.getSalesmanId()); }
orderRefund.setMerId(order.getMerId());
orderRefund.setStoreId(order.getStoreId());
orderRefund.setPlatformType(order.getPlatformType());
orderRefund.setRefundNo(refundNo);
orderRefund.setTotalAmount(order.getTradeAmount());
orderRefund.setRefundAmount(body.getBigDecimal("refundAmount"));
orderRefund.setRefundReason(body.getString("refundReason"));
orderRefund.setStatus(TradeOrderRefundStatusEnum.status1.getNumber());
orderRefund.setOperatorId(userInfoModel.getSecUser().getId());
orderRefund.setOperatorName(userInfoModel.getSecUser().getUserName());
bsTradeOrderRefundService.tradeOrderRefund()*/ BsTradeOrderRefund orderRefund = new BsTradeOrderRefund();
return null; orderRefund.setSalesmanId(tradeOrder.getSalesmanId());
orderRefund.setAgentId(tradeOrder.getAgentId());
orderRefund.setMerId(tradeOrder.getMerId());
orderRefund.setStoreId(tradeOrder.getStoreId());
orderRefund.setPlatformType(tradeOrder.getPlatformType());
orderRefund.setTradeOrderId(tradeOrder.getId());
orderRefund.setOutTradeNo(tradeOrder.getOutTradeNo());
orderRefund.setRefundNo(refundTrade.getRefundTradeNo());
orderRefund.setTotalAmount(tradeOrder.getTradeAmount());
orderRefund.setRefundAmount(new BigDecimal(refundTrade.getRefundAmount()));
orderRefund.setRefundReason(refundTrade.getRefundReason());
orderRefund.setStatus(TradeOrderRefundStatusEnum.status1.getNumber());
orderRefund.setOperatorId(0L);
orderRefund.setOperatorName("API接口");
bsTradeOrderRefundService.editOrderRefund(orderRefund);
Map<String, Object> refundMap = bsTradeOrderRefundService.tradeOrderRefund(orderRefund);
orderRefund = (BsTradeOrderRefund) refundMap.get("orderRefund");
ResponseRefundTradeModel refundTradeModel = new ResponseRefundTradeModel();
refundTradeModel.setMerchantNo(tradeOrder.getMerNo());
refundTradeModel.setOutTradeNo(tradeOrder.getOutTradeNo());
refundTradeModel.setPayMode(tradeOrder.getPayMode());
refundTradeModel.setRefundTradeNo(orderRefund.getRefundNo());
refundTradeModel.setRefundAmount(orderRefund.getRefundAmount().toString());
refundTradeModel.setRefundPayerAmount(orderRefund.getPayerAmount().toString());
refundTradeModel.setRefundTime(orderRefund.getRefundTime());
refundTradeModel.setSign(SignatureUtil.createSign(refundTradeModel, merKeyService.getKeyByMerNo(tradeOrder.getMerNo())));
return refundTradeModel;
} }
@Override @Override

@ -81,7 +81,10 @@ public class SignatureUtil {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String paramStr = "{\n" + String paramStr = "{\n" +
" \"merchantNo\": \"2023030909414450700\",\n" + " \"merchantNo\": \"2023030909414450700\",\n" +
" \"outTradeNo\": \"ZF1130202305051459532538978807\"" + " \"outTradeNo\": \"ZF1130202305242035187441186606\",\n" +
" \"refundAmount\": \"0.01\",\n" +
" \"refundReason\": \"测试退款\",\n" +
" \"refundTradeNo\": \"1170202305051137247442194606\"" +
"}"; "}";
String sign = createSign(JSONObject.parseObject(paramStr), "LRL9uflTQGeyp9yVWDD6orhBp2VhYDvP"); String sign = createSign(JSONObject.parseObject(paramStr), "LRL9uflTQGeyp9yVWDD6orhBp2VhYDvP");
System.out.println(sign); System.out.println(sign);

Loading…
Cancel
Save