Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.github.binarywang.wxpay.bean.request;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 押金消费请求
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=4">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=4</a>
* </pre>
*
* @author Binary Wang
* created on 2024-09-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
@XStreamAlias("xml")
public class WxDepositConsumeRequest extends BaseWxPayRequest {

/**
* <pre>
* 微信押金订单号
* transaction_id
* 是
* String(32)
* 1009660380201506130728806387
* 微信押金订单号
* </pre>
*/
@Required
@XStreamAlias("transaction_id")
private String transactionId;

/**
* <pre>
* 商户消费单号
* out_trade_no
* 是
* String(32)
* 20150806125346
* 商户系统内部的消费单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
* </pre>
*/
@Required
@XStreamAlias("out_trade_no")
private String outTradeNo;

/**
* <pre>
* 消费金额
* consume_fee
* 是
* Int
* 88
* 消费金额,单位为分,不能大于押金金额
* </pre>
*/
@Required
@XStreamAlias("consume_fee")
private Integer consumeFee;

/**
* <pre>
* 消费描述
* consume_desc
* 否
* String(128)
* 单车使用费
* 对一笔消费的具体描述信息
* </pre>
*/
@XStreamAlias("consume_desc")
private String consumeDesc;

@Override
protected void checkConstraints() throws WxPayException {
// No additional constraints beyond @Required fields
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("transaction_id", transactionId);
map.put("out_trade_no", outTradeNo);
map.put("consume_fee", consumeFee.toString());
if (consumeDesc != null) {
map.put("consume_desc", consumeDesc);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.github.binarywang.wxpay.bean.request;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 查询押金订单请求
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=3">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=3</a>
* </pre>
*
* @author Binary Wang
* created on 2024-09-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
@XStreamAlias("xml")
public class WxDepositOrderQueryRequest extends BaseWxPayRequest {

/**
* <pre>
* 微信订单号
* transaction_id
* 否
* String(32)
* 1009660380201506130728806387
* 微信的订单号,优先使用
* </pre>
*/
@XStreamAlias("transaction_id")
private String transactionId;

/**
* <pre>
* 商户订单号
* out_trade_no
* 否
* String(32)
* 20150806125346
* 商户系统内部的订单号,当没提供transaction_id时需要传这个
* </pre>
*/
@XStreamAlias("out_trade_no")
private String outTradeNo;

@Override
protected void checkConstraints() throws WxPayException {
if (transactionId == null && outTradeNo == null) {
throw new WxPayException("transaction_id 和 out_trade_no 不能同时为空");
}
}

@Override
protected void storeMap(Map<String, String> map) {
if (transactionId != null) {
map.put("transaction_id", transactionId);
}
if (outTradeNo != null) {
map.put("out_trade_no", outTradeNo);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.github.binarywang.wxpay.bean.request;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 押金退款请求
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=6">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=6</a>
* </pre>
*
* @author Binary Wang
* created on 2024-09-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
@XStreamAlias("xml")
public class WxDepositRefundRequest extends BaseWxPayRequest {

/**
* <pre>
* 微信押金订单号
* transaction_id
* 否
* String(32)
* 1009660380201506130728806387
* 微信押金订单号,与out_trade_no二选一
* </pre>
*/
@XStreamAlias("transaction_id")
private String transactionId;

/**
* <pre>
* 商户押金订单号
* out_trade_no
* 否
* String(32)
* 20150806125346
* 商户系统内部的押金订单号,与transaction_id二选一
* </pre>
*/
@XStreamAlias("out_trade_no")
private String outTradeNo;

/**
* <pre>
* 商户退款单号
* out_refund_no
* 是
* String(32)
* 1217752501201407033233368018
* 商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
* </pre>
*/
@Required
@XStreamAlias("out_refund_no")
private String outRefundNo;

/**
* <pre>
* 退款金额
* refund_fee
* 是
* Int
* 100
* 退款总金额,订单总金额,单位为分,只能为整数
* </pre>
*/
@Required
@XStreamAlias("refund_fee")
private Integer refundFee;

/**
* <pre>
* 退款原因
* refund_desc
* 否
* String(80)
* 商品已售完
* 若商户传入,会在下发给用户的退款消息中体现退款原因
* </pre>
*/
@XStreamAlias("refund_desc")
private String refundDesc;

@Override
protected void checkConstraints() throws WxPayException {
if (transactionId == null && outTradeNo == null) {
throw new WxPayException("transaction_id 和 out_trade_no 不能同时为空");
}
}

@Override
protected void storeMap(Map<String, String> map) {
if (transactionId != null) {
map.put("transaction_id", transactionId);
}
if (outTradeNo != null) {
map.put("out_trade_no", outTradeNo);
}
map.put("out_refund_no", outRefundNo);
map.put("refund_fee", refundFee.toString());
if (refundDesc != null) {
map.put("refund_desc", refundDesc);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.github.binarywang.wxpay.bean.request;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 押金撤销请求
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=5">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=5</a>
* </pre>
*
* @author Binary Wang
* created on 2024-09-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
@XStreamAlias("xml")
public class WxDepositUnfreezeRequest extends BaseWxPayRequest {

/**
* <pre>
* 微信押金订单号
* transaction_id
* 是
* String(32)
* 1009660380201506130728806387
* 微信押金订单号
* </pre>
*/
@Required
@XStreamAlias("transaction_id")
private String transactionId;

/**
* <pre>
* 商户撤销单号
* out_trade_no
* 是
* String(32)
* 20150806125346
* 商户系统内部的撤销单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
* </pre>
*/
@Required
@XStreamAlias("out_trade_no")
private String outTradeNo;

/**
* <pre>
* 撤销金额
* unfreeze_fee
* 是
* Int
* 99
* 撤销金额,单位为分,不能大于剩余押金金额
* </pre>
*/
@Required
@XStreamAlias("unfreeze_fee")
private Integer unfreezeFee;

/**
* <pre>
* 撤销原因
* unfreeze_desc
* 否
* String(128)
* 用户主动取消
* 对一笔撤销的具体原因描述
* </pre>
*/
@XStreamAlias("unfreeze_desc")
private String unfreezeDesc;

@Override
protected void checkConstraints() throws WxPayException {
// No additional constraints beyond @Required fields
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("transaction_id", transactionId);
map.put("out_trade_no", outTradeNo);
map.put("unfreeze_fee", unfreezeFee.toString());
if (unfreezeDesc != null) {
map.put("unfreeze_desc", unfreezeDesc);
}
}
}
Loading