提交代码

yy_dev
胡锐 1 year ago
parent aa756ddf1c
commit 6aa51df13d
  1. 4
      open-api/src/main/java/com/api/controller/v1/TradeController.java
  2. 17
      service/src/main/java/com/hfkj/dao/BsTradeOrderMapper.java
  3. 28
      service/src/main/java/com/hfkj/dao/BsTradeOrderSqlProvider.java
  4. 32
      service/src/main/java/com/hfkj/entity/BsTradeOrder.java
  5. 120
      service/src/main/java/com/hfkj/entity/BsTradeOrderExample.java
  6. 4
      service/src/main/java/com/hfkj/openapi/v1/model/RequestRefundTradeModel.java
  7. 9
      service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java
  8. 13
      service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java
  9. 36
      service/src/main/java/com/hfkj/sysenum/TradeOrderRefundTypeEnum.java

@ -101,6 +101,8 @@ public class TradeController {
tradeOrder.setPayUserId(body.getUserId());
tradeOrder.setTimeoutExpress(body.getTimeoutExpress());
tradeOrder.setPayNotifyUrl(body.getNotifyUrl());
tradeOrder.setSubject(body.getSubject());
tradeOrder.setRefundPrice(new BigDecimal("0"));
// 创建交易订单
Map<String, Object> returnParam = openApiTradeOrderService.createOrder(tradeOrder);
@ -238,7 +240,7 @@ public class TradeController {
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, "开始时间必须于结束时间");
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "开始时间必须于结束时间");
}
// 最大周期范围3个月 90天
Long maxTime = 60*24*90L;

@ -65,7 +65,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"card_type, `status`, ",
"profit_sharing_status, pay_time, ",
"timeout_express, subject, ",
"pay_notify_url, create_type, ",
"pay_notify_url, refund_type, ",
"refund_price, create_type, ",
"create_time, cancel_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
@ -95,7 +96,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"#{cardType,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
"#{profitSharingStatus,jdbcType=BIT}, #{payTime,jdbcType=TIMESTAMP}, ",
"#{timeoutExpress,jdbcType=INTEGER}, #{subject,jdbcType=VARCHAR}, ",
"#{payNotifyUrl,jdbcType=VARCHAR}, #{createType,jdbcType=INTEGER}, ",
"#{payNotifyUrl,jdbcType=VARCHAR}, #{refundType,jdbcType=INTEGER}, ",
"#{refundPrice,jdbcType=DECIMAL}, #{createType,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
@ -164,6 +166,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
@Result(column="timeout_express", property="timeoutExpress", jdbcType=JdbcType.INTEGER),
@Result(column="subject", property="subject", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_notify_url", property="payNotifyUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="refund_type", property="refundType", jdbcType=JdbcType.INTEGER),
@Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="create_type", property="createType", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@ -186,8 +190,9 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"user_discount_id, user_discount_name, user_discount_type, user_discount_price, ",
"user_discount_actual_price, trade_actual_amount, income_amout, acc_trade_no, ",
"acc_mdiscount_amount, acc_discount_amount, acc_payment_code, card_type, `status`, ",
"profit_sharing_status, pay_time, timeout_express, subject, pay_notify_url, create_type, ",
"create_time, cancel_time, update_time, ext_1, ext_2, ext_3",
"profit_sharing_status, pay_time, timeout_express, subject, pay_notify_url, refund_type, ",
"refund_price, create_type, create_time, cancel_time, update_time, ext_1, ext_2, ",
"ext_3",
"from bs_trade_order",
"where id = #{id,jdbcType=BIGINT}"
})
@ -247,6 +252,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
@Result(column="timeout_express", property="timeoutExpress", jdbcType=JdbcType.INTEGER),
@Result(column="subject", property="subject", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_notify_url", property="payNotifyUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="refund_type", property="refundType", jdbcType=JdbcType.INTEGER),
@Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="create_type", property="createType", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@ -322,6 +329,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"timeout_express = #{timeoutExpress,jdbcType=INTEGER},",
"subject = #{subject,jdbcType=VARCHAR},",
"pay_notify_url = #{payNotifyUrl,jdbcType=VARCHAR},",
"refund_type = #{refundType,jdbcType=INTEGER},",
"refund_price = #{refundPrice,jdbcType=DECIMAL},",
"create_type = #{createType,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"cancel_time = #{cancelTime,jdbcType=TIMESTAMP},",

@ -244,6 +244,14 @@ public class BsTradeOrderSqlProvider {
sql.VALUES("pay_notify_url", "#{payNotifyUrl,jdbcType=VARCHAR}");
}
if (record.getRefundType() != null) {
sql.VALUES("refund_type", "#{refundType,jdbcType=INTEGER}");
}
if (record.getRefundPrice() != null) {
sql.VALUES("refund_price", "#{refundPrice,jdbcType=DECIMAL}");
}
if (record.getCreateType() != null) {
sql.VALUES("create_type", "#{createType,jdbcType=INTEGER}");
}
@ -336,6 +344,8 @@ public class BsTradeOrderSqlProvider {
sql.SELECT("timeout_express");
sql.SELECT("subject");
sql.SELECT("pay_notify_url");
sql.SELECT("refund_type");
sql.SELECT("refund_price");
sql.SELECT("create_type");
sql.SELECT("create_time");
sql.SELECT("cancel_time");
@ -580,6 +590,14 @@ public class BsTradeOrderSqlProvider {
sql.SET("pay_notify_url = #{record.payNotifyUrl,jdbcType=VARCHAR}");
}
if (record.getRefundType() != null) {
sql.SET("refund_type = #{record.refundType,jdbcType=INTEGER}");
}
if (record.getRefundPrice() != null) {
sql.SET("refund_price = #{record.refundPrice,jdbcType=DECIMAL}");
}
if (record.getCreateType() != null) {
sql.SET("create_type = #{record.createType,jdbcType=INTEGER}");
}
@ -671,6 +689,8 @@ public class BsTradeOrderSqlProvider {
sql.SET("timeout_express = #{record.timeoutExpress,jdbcType=INTEGER}");
sql.SET("subject = #{record.subject,jdbcType=VARCHAR}");
sql.SET("pay_notify_url = #{record.payNotifyUrl,jdbcType=VARCHAR}");
sql.SET("refund_type = #{record.refundType,jdbcType=INTEGER}");
sql.SET("refund_price = #{record.refundPrice,jdbcType=DECIMAL}");
sql.SET("create_type = #{record.createType,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("cancel_time = #{record.cancelTime,jdbcType=TIMESTAMP}");
@ -904,6 +924,14 @@ public class BsTradeOrderSqlProvider {
sql.SET("pay_notify_url = #{payNotifyUrl,jdbcType=VARCHAR}");
}
if (record.getRefundType() != null) {
sql.SET("refund_type = #{refundType,jdbcType=INTEGER}");
}
if (record.getRefundPrice() != null) {
sql.SET("refund_price = #{refundPrice,jdbcType=DECIMAL}");
}
if (record.getCreateType() != null) {
sql.SET("create_type = #{createType,jdbcType=INTEGER}");
}

@ -293,6 +293,16 @@ public class BsTradeOrder implements Serializable {
*/
private String payNotifyUrl;
/**
* 退款类型 1全额退款 2部分退款
*/
private Integer refundType;
/**
* 退款金额
*/
private BigDecimal refundPrice;
/**
* 创建方式 1扫一扫 2被扫 3API
*/
@ -761,6 +771,22 @@ public class BsTradeOrder implements Serializable {
this.payNotifyUrl = payNotifyUrl;
}
public Integer getRefundType() {
return refundType;
}
public void setRefundType(Integer refundType) {
this.refundType = refundType;
}
public BigDecimal getRefundPrice() {
return refundPrice;
}
public void setRefundPrice(BigDecimal refundPrice) {
this.refundPrice = refundPrice;
}
public Integer getCreateType() {
return createType;
}
@ -884,6 +910,8 @@ public class BsTradeOrder implements Serializable {
&& (this.getTimeoutExpress() == null ? other.getTimeoutExpress() == null : this.getTimeoutExpress().equals(other.getTimeoutExpress()))
&& (this.getSubject() == null ? other.getSubject() == null : this.getSubject().equals(other.getSubject()))
&& (this.getPayNotifyUrl() == null ? other.getPayNotifyUrl() == null : this.getPayNotifyUrl().equals(other.getPayNotifyUrl()))
&& (this.getRefundType() == null ? other.getRefundType() == null : this.getRefundType().equals(other.getRefundType()))
&& (this.getRefundPrice() == null ? other.getRefundPrice() == null : this.getRefundPrice().equals(other.getRefundPrice()))
&& (this.getCreateType() == null ? other.getCreateType() == null : this.getCreateType().equals(other.getCreateType()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime()))
@ -952,6 +980,8 @@ public class BsTradeOrder implements Serializable {
result = prime * result + ((getTimeoutExpress() == null) ? 0 : getTimeoutExpress().hashCode());
result = prime * result + ((getSubject() == null) ? 0 : getSubject().hashCode());
result = prime * result + ((getPayNotifyUrl() == null) ? 0 : getPayNotifyUrl().hashCode());
result = prime * result + ((getRefundType() == null) ? 0 : getRefundType().hashCode());
result = prime * result + ((getRefundPrice() == null) ? 0 : getRefundPrice().hashCode());
result = prime * result + ((getCreateType() == null) ? 0 : getCreateType().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode());
@ -1023,6 +1053,8 @@ public class BsTradeOrder implements Serializable {
sb.append(", timeoutExpress=").append(timeoutExpress);
sb.append(", subject=").append(subject);
sb.append(", payNotifyUrl=").append(payNotifyUrl);
sb.append(", refundType=").append(refundType);
sb.append(", refundPrice=").append(refundPrice);
sb.append(", createType=").append(createType);
sb.append(", createTime=").append(createTime);
sb.append(", cancelTime=").append(cancelTime);

@ -3646,6 +3646,126 @@ public class BsTradeOrderExample {
return (Criteria) this;
}
public Criteria andRefundTypeIsNull() {
addCriterion("refund_type is null");
return (Criteria) this;
}
public Criteria andRefundTypeIsNotNull() {
addCriterion("refund_type is not null");
return (Criteria) this;
}
public Criteria andRefundTypeEqualTo(Integer value) {
addCriterion("refund_type =", value, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeNotEqualTo(Integer value) {
addCriterion("refund_type <>", value, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeGreaterThan(Integer value) {
addCriterion("refund_type >", value, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("refund_type >=", value, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeLessThan(Integer value) {
addCriterion("refund_type <", value, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeLessThanOrEqualTo(Integer value) {
addCriterion("refund_type <=", value, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeIn(List<Integer> values) {
addCriterion("refund_type in", values, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeNotIn(List<Integer> values) {
addCriterion("refund_type not in", values, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeBetween(Integer value1, Integer value2) {
addCriterion("refund_type between", value1, value2, "refundType");
return (Criteria) this;
}
public Criteria andRefundTypeNotBetween(Integer value1, Integer value2) {
addCriterion("refund_type not between", value1, value2, "refundType");
return (Criteria) this;
}
public Criteria andRefundPriceIsNull() {
addCriterion("refund_price is null");
return (Criteria) this;
}
public Criteria andRefundPriceIsNotNull() {
addCriterion("refund_price is not null");
return (Criteria) this;
}
public Criteria andRefundPriceEqualTo(BigDecimal value) {
addCriterion("refund_price =", value, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceNotEqualTo(BigDecimal value) {
addCriterion("refund_price <>", value, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceGreaterThan(BigDecimal value) {
addCriterion("refund_price >", value, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("refund_price >=", value, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceLessThan(BigDecimal value) {
addCriterion("refund_price <", value, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceLessThanOrEqualTo(BigDecimal value) {
addCriterion("refund_price <=", value, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceIn(List<BigDecimal> values) {
addCriterion("refund_price in", values, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceNotIn(List<BigDecimal> values) {
addCriterion("refund_price not in", values, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("refund_price between", value1, value2, "refundPrice");
return (Criteria) this;
}
public Criteria andRefundPriceNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("refund_price not between", value1, value2, "refundPrice");
return (Criteria) this;
}
public Criteria andCreateTypeIsNull() {
addCriterion("create_type is null");
return (Criteria) this;

@ -39,8 +39,8 @@ public class RequestRefundTradeModel {
/**
* 退款金额
*/
@DecimalMax(value = "99999999", message = "交易最大金额99999999元")
@DecimalMin(value = "0.01", message = "交易最小金额0.01元")
@DecimalMax(value = "99999999", message = "退款最大金额99999999元")
@DecimalMin(value = "0.01", message = "退款最小金额0.01元")
@NotBlank(message = "退款金额必填项")
private String refundAmount;

@ -18,6 +18,7 @@ import com.hfkj.service.BsMerKeyService;
import com.hfkj.service.BsTradeOrderRefundService;
import com.hfkj.service.BsTradeOrderService;
import com.hfkj.sysenum.TradeOrderRefundStatusEnum;
import com.hfkj.sysenum.TradeOrderRefundTypeEnum;
import com.hfkj.sysenum.TradeOrderStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
@ -117,6 +118,14 @@ public class OpenApiTradeOrderServiceImpl implements OpenApiTradeOrderService {
refundTradeModel.setRefundPayerAmount(orderRefund.getPayerAmount().toString());
refundTradeModel.setRefundTime(orderRefund.getRefundTime());
refundTradeModel.setSign(SignatureUtil.createSign(refundTradeModel, merKeyService.getKeyByMerNo(tradeOrder.getMerNo())));
tradeOrder.setRefundPrice(tradeOrder.getRefundPrice().add(orderRefund.getRefundAmount()));
if (tradeOrder.getRefundPrice().compareTo(tradeOrder.getTradeActualAmount()) == 0) {
tradeOrder.setRefundType(TradeOrderRefundTypeEnum.type1.getNumber());
} else {
tradeOrder.setRefundType(TradeOrderRefundTypeEnum.type2.getNumber());
}
bsTradeOrderService.editOrder(tradeOrder);
return refundTradeModel;
}

@ -82,16 +82,9 @@ public class SignatureUtil {
public static void main(String[] args) throws Exception {
String paramStr = "{\n" +
" \"merchantNo\": \"2023030909414450700\",\n" +
" \"outTradeNo\": \"ZF1130202305051459532538978812\",\n" +
" \"payMode\": \"ALIPAY\",\n" +
" \"totalAmount\": 0.01,\n" +
" \"transType\": \"JSAPI\",\n" +
" \"subject\": \"支付测试\",\n" +
" \"userId\": \"2088612673845396\",\n" +
" \"profitSharing\": 0,\n" +
" \"timeoutExpress\": \"5\",\n" +
" \"notifyUrl\": \"https://gratia-pay.dctpay.com/crest/laKaLaNotify/microPay\"\n" +
" \"merchantNo\": \"2023030909414450700\",\n" +
" \"billDateS\": 1684568344000,\n" +
" \"billDateE\": 1685008407667\n" +
"}";
String sign = createSign(JSONObject.parseObject(paramStr), "LRL9uflTQGeyp9yVWDD6orhBp2VhYDvP");
System.out.println(sign);

@ -0,0 +1,36 @@
package com.hfkj.sysenum;
/**
* 退款类型
* @author hurui
*/
public enum TradeOrderRefundTypeEnum {
type1(1, "全额退款"),
type2(2, "部分退款"),
;
private Integer number;
private String name;
TradeOrderRefundTypeEnum(int number, String name) {
this.number = number;
this.name = name;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Loading…
Cancel
Save