提交代码

yy_dev
胡锐 1 year ago
parent e8f1c2aebf
commit 164c7cd308
  1. 36
      open-api/src/main/java/com/api/controller/v1/TradeController.java
  2. 30
      service/src/main/java/com/hfkj/dao/OpenApiTradeOrderMapper.java
  3. 63
      service/src/main/java/com/hfkj/openapi/v1/model/TradeRefundBillsModel.java
  4. 40
      service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradeRefundBillsModel.java
  5. 10
      service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java
  6. 9
      service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java
  7. 12
      service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java

@ -282,6 +282,42 @@ public class TradeController {
} }
} }
@RequestMapping(value="/tradeRefundBills",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "账单退款下载")
public ResponseData tradeRefundBills(@RequestBody RequestTradeRefundBillsModel 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, "");
}
if (body.getBillDateS().compareTo(body.getBillDateE()) >= 0) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "开始时间必须小于结束时间");
}
// 最大周期范围3个月 90天
Long maxTime = 60*24*90L;
if (maxTime.compareTo(DateUtil.getMinutesDiff(new Date(body.getBillDateS()), new Date(body.getBillDateE()))) < 0) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "时间范围大于3个月");
}
List<TradeRefundBillsModel> tradeBills = openApiTradeOrderService.tradeRefundBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeRefundBillsModel.class)
.sheet(body.getMerchantNo())
.doWrite(tradeBills);
String fileUrl = CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + fileName;
log.info("返回参数:" + fileUrl);
return ResponseMsgUtil.success(fileUrl);
} catch (Exception e) {
log.info("出现异常:", e);
return ResponseMsgUtil.exception(e);
} finally {
log.info("========= END 账单退款下载 END ===========");
}
}
} }

@ -1,6 +1,7 @@
package com.hfkj.dao; package com.hfkj.dao;
import com.hfkj.openapi.v1.model.TradeBillsModel; import com.hfkj.openapi.v1.model.TradeBillsModel;
import com.hfkj.openapi.v1.model.TradeRefundBillsModel;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -54,4 +55,33 @@ public interface OpenApiTradeOrderMapper {
}) })
List<TradeBillsModel> queryTradeBills(@Param("merNo") String merNo,@Param("billDateS") String billDateS, @Param("billDateE") String billDateE); List<TradeBillsModel> queryTradeBills(@Param("merNo") String merNo,@Param("billDateS") String billDateS, @Param("billDateE") String billDateE);
@Select({
"<script>" +
" select " +
" a.create_time createTime, " +
" a.refund_no refundNo, " +
" case a.`status` " +
" when 1 then '退款中' " +
" when 2 then '退款成功' " +
" when 3 then '退款失败' " +
" end refundStatus, " +
" a.refund_time refundTime, " +
" a.refund_amount refundAmount, " +
" b.out_trade_no outTradeNo, " +
" b.acc_trade_no accTradeNo, " +
" b.mer_no merNo, " +
" b.acc_settle_amount accSettleAmount, " +
" a.refund_reason refundReason, " +
" a.operator_name operatorName " +
" from bs_trade_order_refund a " +
" LEFT JOIN bs_trade_order b on b.out_trade_no = a.out_trade_no " +
" where <![CDATA[ a.`status` <> 0 ]]> and b.mer_no = #{merNo}" +
" <![CDATA[ and a.create_time >= #{billDateS} ]]>" +
" <![CDATA[ and a.create_time <= #{billDateE} ]]>" +
" ORDER BY a.create_time desc" +
"</script>"
})
List<TradeRefundBillsModel> queryRefundBills(@Param("merNo") String merNo, @Param("billDateS") String billDateS, @Param("billDateE") String billDateE);
} }

@ -0,0 +1,63 @@
package com.hfkj.openapi.v1.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 交易退款账单模型
* @className: TradeBillsModel
* @author: HuRui
* @date: 2023/5/25
**/
@Data
public class TradeRefundBillsModel {
@ColumnWidth(25)
@ExcelProperty("申请退款时间")
private Date createTime;
@ColumnWidth(35)
@ExcelProperty("商户退款单号")
private String refundNo;
@ColumnWidth(25)
@ExcelProperty("退款状态")
private String refundStatus;
@ColumnWidth(25)
@ExcelProperty("退款成功时间")
private Date refundTime;
@ColumnWidth(25)
@ExcelProperty("退款金额")
private BigDecimal refundAmount;
@ColumnWidth(35)
@ExcelProperty("商户交易单号")
private String outTradeNo;
@ColumnWidth(35)
@ExcelProperty("账户端交易单号")
private String accTradeNo;
@ColumnWidth(30)
@ExcelProperty("商户号")
private String merNo;
@ColumnWidth(25)
@ExcelProperty("交易金额")
private BigDecimal accSettleAmount;
@ColumnWidth(30)
@ExcelProperty("退款原因")
private String refundReason;
@ColumnWidth(25)
@ExcelProperty("操作人")
private String operatorName;
}

@ -0,0 +1,40 @@
package com.hfkj.openapi.v1.model.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 请求账单下载模型
* @className: TradePreorderModel
* @author: HuRui
* @date: 2023/5/23
**/
@Data
public class RequestTradeRefundBillsModel {
/**
* 商户号
*/
@NotBlank(message = "商户号必填项")
private String merchantNo;
/**
* 报表开始时间
*/
@NotBlank(message = "开始时间必填项")
private Long billDateS;
/**
* 报表结束时间
*/
@NotBlank(message = "结束时间必填项")
private Long billDateE;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -2,6 +2,7 @@ package com.hfkj.openapi.v1.service;
import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.openapi.v1.model.TradeRefundBillsModel;
import com.hfkj.openapi.v1.model.request.RequestRefundTradeModel; import com.hfkj.openapi.v1.model.request.RequestRefundTradeModel;
import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel; import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel;
import com.hfkj.openapi.v1.model.TradeBillsModel; import com.hfkj.openapi.v1.model.TradeBillsModel;
@ -51,4 +52,13 @@ public interface OpenApiTradeOrderService {
* @return * @return
*/ */
List<TradeBillsModel> tradeBills(String merNo, Long billDateS, Long billDateE); List<TradeBillsModel> tradeBills(String merNo, Long billDateS, Long billDateE);
/**
* 交易退款账单
* @param merNo
* @param billDateS
* @param billDateE
* @return
*/
List<TradeRefundBillsModel> tradeRefundBills(String merNo, Long billDateS, Long billDateE);
} }

@ -9,6 +9,7 @@ import com.hfkj.common.utils.DateUtil;
import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.dao.OpenApiTradeOrderMapper; import com.hfkj.dao.OpenApiTradeOrderMapper;
import com.hfkj.openapi.v1.model.TradeRefundBillsModel;
import com.hfkj.openapi.v1.model.request.RequestRefundTradeModel; import com.hfkj.openapi.v1.model.request.RequestRefundTradeModel;
import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel; import com.hfkj.openapi.v1.model.response.ResponseRefundTradeModel;
import com.hfkj.openapi.v1.model.TradeBillsModel; import com.hfkj.openapi.v1.model.TradeBillsModel;
@ -142,4 +143,12 @@ public class OpenApiTradeOrderServiceImpl implements OpenApiTradeOrderService {
); );
} }
@Override
public List<TradeRefundBillsModel> tradeRefundBills(String merNo, Long billDateS, Long billDateE) {
return openApiTradeOrderMapper.queryRefundBills(merNo,
DateUtil.date2String(new Date(billDateS), DateUtil.Y_M_D_HMS),
DateUtil.date2String(new Date(billDateE), DateUtil.Y_M_D_HMS)
);
}
} }

@ -82,15 +82,11 @@ 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\": \"2023041916292112804\",\n" + " \"merchantNo\": \"2023051910562136809\",\n" +
" \"outTradeNo\": \"ZF1130202305051459532538970009\",\n" + " \"billDateS\": 1684568344000,\n" +
" \"payMode\": \"UQRCODEPAY\",\n" + " \"billDateE\": 1690527064867" +
" \"totalAmount\": 0.01,\n" +
" \"transType\": \"NATIVE\",\n" +
" \"profitSharing\": 0,\n" +
" \"specialField\": \"测试\"" +
"}"; "}";
String sign = createSign(JSONObject.parseObject(paramStr), "2jLO2WjXcSRSzTCaca0Kmv0OFrfYBbrA"); String sign = createSign(JSONObject.parseObject(paramStr), "NGixVhkzVYFFMj8tjj4zOkYQtUiU3bd4");
System.out.println(sign); System.out.println(sign);
} }
} }

Loading…
Cancel
Save