Bladeren bron

#178 实现查询代金券批次和信息的接口

master
Binary Wang 8 jaren geleden
committed by Binary Wang
bovenliggende
commit
74e3cc569b
7 gewijzigde bestanden met toevoegingen van 1201 en 6 verwijderingen
  1. +280
    -0
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
  2. +351
    -0
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
  3. +221
    -0
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
  4. +288
    -0
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
  5. +19
    -2
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
  6. +23
    -2
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
  7. +19
    -2
      weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java

+ 280
- 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java Bestand weergeven

@@ -0,0 +1,280 @@
package com.github.binarywang.wxpay.bean.coupon;

import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import me.chanjar.weixin.common.annotation.Required;

/**
* <pre>
* 查询代金券信息请求对象类
* Created by Binary Wang on 2017-7-15.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@XStreamAlias("xml")
public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest {
/**
* <pre>
* 字段名:代金券id
* 变量名:coupon_id
* 是否必填:是
* 示例值:1757
* 类型:String
* 说明:代金券id
* </pre>
*/
@Required
@XStreamAlias("coupon_id")
private String couponId;

/**
* <pre>
* 字段名:代金券批次号
* 变量名:stock_id
* 是否必填:是
* 示例值:58818
* 类型:String
* 说明:代金劵对应的批次号
* </pre>
*/
@Required
@XStreamAlias("stock_id")
private String stockId;

/**
* <pre>
* 字段名:用户openid
* 变量名:openid
* 是否必填:是
* 示例值:onqOjjrXT-776SpHnfexGm1_P7iE
* 类型:String
* 说明:Openid信息,用户在appid下的openid。
* </pre>
*/
@Required
@XStreamAlias("openid")
private String openid;

/**
* <pre>
* 字段名:操作员
* 变量名:op_user_id
* 是否必填:否
* 示例值:10000098
* 类型:String(32)
* 说明:操作员帐号, 默认为商户号,可在商户平台配置操作员对应的api权限
* </pre>
*/
@XStreamAlias("op_user_id")
private String opUserId;

/**
* <pre>
* 字段名:设备号
* 变量名:device_info
* 是否必填:否
* 示例值:
* 类型:String(32)
* 说明:微信支付分配的终端设备号
* </pre>
*/
@XStreamAlias("device_info")
private String deviceInfo;

/**
* <pre>
* 字段名:协议版本
* 变量名:version
* 是否必填:否
* 示例值:1.0
* 类型:String(32)
* 说明:默认1.0
* </pre>
*/
@XStreamAlias("version")
private String version;

/**
* <pre>
* 字段名:协议类型
* 变量名:type
* 是否必填:否
* 示例值:XML
* 类型:String(32)
* 说明:XML【目前仅支持默认XML】
* </pre>
*/
@XStreamAlias("type")
private String type;

private WxPayCouponInfoQueryRequest(Builder builder) {
setAppid(builder.appid);
setMchId(builder.mchId);
setSubAppId(builder.subAppId);
setSubMchId(builder.subMchId);
setNonceStr(builder.nonceStr);
setSign(builder.sign);
setCouponId(builder.couponId);
setStockId(builder.stockId);
setOpenid(builder.openid);
setOpUserId(builder.opUserId);
setDeviceInfo(builder.deviceInfo);
setVersion(builder.version);
setType(builder.type);
}

public static Builder newBuilder() {
return new Builder();
}

public String getCouponId() {
return this.couponId;
}

public void setCouponId(String couponId) {
this.couponId = couponId;
}

public String getStockId() {
return this.stockId;
}

public void setStockId(String stockId) {
this.stockId = stockId;
}

public String getOpenid() {
return this.openid;
}

public void setOpenid(String openid) {
this.openid = openid;
}

public String getOpUserId() {
return this.opUserId;
}

public void setOpUserId(String opUserId) {
this.opUserId = opUserId;
}

public String getDeviceInfo() {
return this.deviceInfo;
}

public void setDeviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
}

public String getVersion() {
return this.version;
}

public void setVersion(String version) {
this.version = version;
}

public String getType() {
return this.type;
}

public void setType(String type) {
this.type = type;
}

@Override
protected void checkConstraints() {
//do nothing
}


public static final class Builder {
private String appid;
private String mchId;
private String subAppId;
private String subMchId;
private String nonceStr;
private String sign;
private String couponId;
private String stockId;
private String openid;
private String opUserId;
private String deviceInfo;
private String version;
private String type;

private Builder() {
}

public Builder appid(String appid) {
this.appid = appid;
return this;
}

public Builder mchId(String mchId) {
this.mchId = mchId;
return this;
}

public Builder subAppId(String subAppId) {
this.subAppId = subAppId;
return this;
}

public Builder subMchId(String subMchId) {
this.subMchId = subMchId;
return this;
}

public Builder nonceStr(String nonceStr) {
this.nonceStr = nonceStr;
return this;
}

public Builder sign(String sign) {
this.sign = sign;
return this;
}

public Builder couponId(String couponId) {
this.couponId = couponId;
return this;
}

public Builder stockId(String stockId) {
this.stockId = stockId;
return this;
}

public Builder openid(String openid) {
this.openid = openid;
return this;
}

public Builder opUserId(String opUserId) {
this.opUserId = opUserId;
return this;
}

public Builder deviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
return this;
}

public Builder version(String version) {
this.version = version;
return this;
}

public Builder type(String type) {
this.type = type;
return this;
}

public WxPayCouponInfoQueryRequest build() {
return new WxPayCouponInfoQueryRequest(this);
}
}
}

+ 351
- 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java Bestand weergeven

@@ -0,0 +1,351 @@
package com.github.binarywang.wxpay.bean.coupon;

import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
* <pre>
* 查询代金券信息响应结果类
* Created by Binary Wang on 2017-7-15.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@XStreamAlias("xml")
public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
* <pre>
* 字段名:设备号
* 变量名:device_info
* 是否必填:否
* 示例值:123456sb
* 类型:String(32)
* 说明:微信支付分配的终端设备号,
* </pre>
*/
@XStreamAlias("device_info")
private String deviceInfo;

/**
* <pre>
* 字段名:批次ID
* 变量名:coupon_stock_id
* 是否必填:是
* 示例值:1567
* 类型:String
* 说明:代金券批次Id
* </pre>
*/
@XStreamAlias("coupon_stock_id")
private String couponStockId;

/**
* <pre>
* 字段名:代金券id
* 变量名:coupon_id
* 是否必填:是
* 示例值:4242
* 类型:String
* 说明:代金券id
* </pre>
*/
@XStreamAlias("coupon_id")
private String couponId;

/**
* <pre>
* 字段名:代金券面额
* 变量名:coupon_value
* 是否必填:是
* 示例值:4
* 类型:Unsinged int
* 说明:代金券面值,单位是分
* </pre>
*/
@XStreamAlias("coupon_value")
private Integer couponValue;

/**
* <pre>
* 字段名:代金券使用门槛
* 变量名:coupon_mininum
* 是否必填:是
* 示例值:10
* 类型:Unsinged int
* 说明:代金券使用最低限额,单位是分
* </pre>
*/
@XStreamAlias("coupon_mininum")
private Integer couponMininum;

/**
* <pre>
* 字段名:代金券名称
* 变量名:coupon_name
* 是否必填:是
* 示例值:测试代金券
* 类型:String
* 说明:代金券名称
* </pre>
*/
@XStreamAlias("coupon_name")
private String couponName;

/**
* <pre>
* 字段名:代金券状态
* 变量名:coupon_state
* 是否必填:是
* 示例值:SENDED
* 类型:int
* 说明:代金券状态:SENDED-可用,USED-已实扣,EXPIRED-已过期
* </pre>
*/
@XStreamAlias("coupon_state")
private Integer couponState;

/**
* <pre>
* 字段名:代金券描述
* 变量名:coupon_desc
* 是否必填:是
* 示例值:微信支付-代金券
* 类型:String
* 说明:代金券描述
* </pre>
*/
@XStreamAlias("coupon_desc")
private String couponDesc;

/**
* <pre>
* 字段名:实际优惠金额
* 变量名:coupon_use_value
* 是否必填:是
* 示例值:0
* 类型:Unsinged int
* 说明:代金券实际使用金额
* </pre>
*/
@XStreamAlias("coupon_use_value")
private Integer couponUseValue;

/**
* <pre>
* 字段名:优惠剩余可用额
* 变量名:coupon_remain_value
* 是否必填:是
* 示例值:4
* 类型:Unsinged int
* 说明:代金券剩余金额:部分使用情况下,可能会存在券剩余金额
* </pre>
*/
@XStreamAlias("coupon_remain_value")
private Integer couponRemainValue;

/**
* <pre>
* 字段名:生效开始时间
* 变量名:begin_time
* 是否必填:是
* 示例值:1943787483
* 类型:String
* 说明:格式为时间戳
* </pre>
*/
@XStreamAlias("begin_time")
private String beginTime;

/**
* <pre>
* 字段名:生效结束时间
* 变量名:end_time
* 是否必填:是
* 示例值:1943787484
* 类型:String
* 说明:格式为时间戳
* </pre>
*/
@XStreamAlias("end_time")
private String endTime;

/**
* <pre>
* 字段名:发放时间
* 变量名:send_time
* 是否必填:是
* 示例值:1943787420
* 类型:String
* 说明:格式为时间戳
* </pre>
*/
@XStreamAlias("send_time")
private String sendTime;

/**
* <pre>
* 字段名:消耗方商户id
* 变量名:consumer_mch_id
* 是否必填:否
* 示例值:10000098
* 类型:String
* 说明:代金券使用后,消耗方商户id
* </pre>
*/
@XStreamAlias("consumer_mch_id")
private String consumerMchId;

/**
* <pre>
* 字段名:发放来源
* 变量名:send_source
* 是否必填:是
* 示例值:FULL_SEND
* 类型:String
* 说明:代金券发放来源:FULL_SEND-满送 NORMAL-普通发放场景
* </pre>
*/
@XStreamAlias("send_source")
private String sendSource;

/**
* <pre>
* 字段名:是否允许部分使用
* 变量名:is_partial_use
* 是否必填:否
* 示例值:1
* 类型:String
* 说明:该代金券是否允许部分使用标识:1-表示支持部分使用
* </pre>
*/
@XStreamAlias("is_partial_use")
private String isPartialUse;

public String getDeviceInfo() {
return this.deviceInfo;
}

public void setDeviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
}

public String getCouponStockId() {
return this.couponStockId;
}

public void setCouponStockId(String couponStockId) {
this.couponStockId = couponStockId;
}

public String getCouponId() {
return this.couponId;
}

public void setCouponId(String couponId) {
this.couponId = couponId;
}

public Integer getCouponValue() {
return this.couponValue;
}

public void setCouponValue(Integer couponValue) {
this.couponValue = couponValue;
}

public Integer getCouponMininum() {
return this.couponMininum;
}

public void setCouponMininum(Integer couponMininum) {
this.couponMininum = couponMininum;
}

public String getCouponName() {
return this.couponName;
}

public void setCouponName(String couponName) {
this.couponName = couponName;
}

public Integer getCouponState() {
return this.couponState;
}

public void setCouponState(Integer couponState) {
this.couponState = couponState;
}

public String getCouponDesc() {
return this.couponDesc;
}

public void setCouponDesc(String couponDesc) {
this.couponDesc = couponDesc;
}

public Integer getCouponUseValue() {
return this.couponUseValue;
}

public void setCouponUseValue(Integer couponUseValue) {
this.couponUseValue = couponUseValue;
}

public Integer getCouponRemainValue() {
return this.couponRemainValue;
}

public void setCouponRemainValue(Integer couponRemainValue) {
this.couponRemainValue = couponRemainValue;
}

public String getBeginTime() {
return this.beginTime;
}

public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}

public String getEndTime() {
return this.endTime;
}

public void setEndTime(String endTime) {
this.endTime = endTime;
}

public String getSendTime() {
return this.sendTime;
}

public void setSendTime(String sendTime) {
this.sendTime = sendTime;
}

public String getConsumerMchId() {
return this.consumerMchId;
}

public void setConsumerMchId(String consumerMchId) {
this.consumerMchId = consumerMchId;
}

public String getSendSource() {
return this.sendSource;
}

public void setSendSource(String sendSource) {
this.sendSource = sendSource;
}

public String getIsPartialUse() {
return this.isPartialUse;
}

public void setIsPartialUse(String isPartialUse) {
this.isPartialUse = isPartialUse;
}
}

+ 221
- 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java Bestand weergeven

@@ -0,0 +1,221 @@
package com.github.binarywang.wxpay.bean.coupon;

import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import me.chanjar.weixin.common.annotation.Required;

/**
* <pre>
* 查询代金券批次请求对象类
* Created by Binary Wang on 2017-7-15.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@XStreamAlias("xml")
public class WxPayCouponStockQueryRequest extends WxPayBaseRequest {
/**
* <pre>
* 字段名:代金券批次id
* 变量名:coupon_stock_id
* 是否必填:是
* 示例值:1757
* 类型:String
* 说明:代金券批次id
* </pre>
*/
@Required
@XStreamAlias("coupon_stock_id")
private String couponStockId;

/**
* <pre>
* 字段名:操作员
* 变量名:op_user_id
* 是否必填:否
* 示例值:10000098
* 类型:String(32)
* 说明:操作员帐号, 默认为商户号,可在商户平台配置操作员对应的api权限
* </pre>
*/
@XStreamAlias("op_user_id")
private String opUserId;

/**
* <pre>
* 字段名:设备号
* 变量名:device_info
* 是否必填:否
* 示例值:
* 类型:String(32)
* 说明:微信支付分配的终端设备号
* </pre>
*/
@XStreamAlias("device_info")
private String deviceInfo;

/**
* <pre>
* 字段名:协议版本
* 变量名:version
* 是否必填:否
* 示例值:1.0
* 类型:String(32)
* 说明:默认1.0
* </pre>
*/
@XStreamAlias("version")
private String version;

/**
* <pre>
* 字段名:协议类型
* 变量名:type
* 是否必填:否
* 示例值:XML
* 类型:String(32)
* 说明:XML【目前仅支持默认XML】
* </pre>
*/
@XStreamAlias("type")
private String type;

private WxPayCouponStockQueryRequest(Builder builder) {
setAppid(builder.appid);
setMchId(builder.mchId);
setSubAppId(builder.subAppId);
setSubMchId(builder.subMchId);
setNonceStr(builder.nonceStr);
setSign(builder.sign);
setCouponStockId(builder.couponStockId);
setOpUserId(builder.opUserId);
setDeviceInfo(builder.deviceInfo);
setVersion(builder.version);
setType(builder.type);
}

public static Builder newBuilder() {
return new Builder();
}

public String getCouponStockId() {
return this.couponStockId;
}

public void setCouponStockId(String couponStockId) {
this.couponStockId = couponStockId;
}

public String getOpUserId() {
return this.opUserId;
}

public void setOpUserId(String opUserId) {
this.opUserId = opUserId;
}

public String getDeviceInfo() {
return this.deviceInfo;
}

public void setDeviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
}

public String getVersion() {
return this.version;
}

public void setVersion(String version) {
this.version = version;
}

public String getType() {
return this.type;
}

public void setType(String type) {
this.type = type;
}

@Override
protected void checkConstraints() {
//do nothing
}

public static final class Builder {
private String appid;
private String mchId;
private String subAppId;
private String subMchId;
private String nonceStr;
private String sign;
private String couponStockId;
private String opUserId;
private String deviceInfo;
private String version;
private String type;

private Builder() {
}

public Builder appid(String appid) {
this.appid = appid;
return this;
}

public Builder mchId(String mchId) {
this.mchId = mchId;
return this;
}

public Builder subAppId(String subAppId) {
this.subAppId = subAppId;
return this;
}

public Builder subMchId(String subMchId) {
this.subMchId = subMchId;
return this;
}

public Builder nonceStr(String nonceStr) {
this.nonceStr = nonceStr;
return this;
}

public Builder sign(String sign) {
this.sign = sign;
return this;
}

public Builder couponStockId(String couponStockId) {
this.couponStockId = couponStockId;
return this;
}

public Builder opUserId(String opUserId) {
this.opUserId = opUserId;
return this;
}

public Builder deviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
return this;
}

public Builder version(String version) {
this.version = version;
return this;
}

public Builder type(String type) {
this.type = type;
return this;
}

public WxPayCouponStockQueryRequest build() {
return new WxPayCouponStockQueryRequest(this);
}
}
}

+ 288
- 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java Bestand weergeven

@@ -0,0 +1,288 @@
package com.github.binarywang.wxpay.bean.coupon;

import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
* <pre>
* 查询代金券批次响应结果类
* Created by Binary Wang on 2017-7-15.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@XStreamAlias("xml")
public class WxPayCouponStockQueryResult extends WxPayBaseResult {
/**
* <pre>
* 字段名:设备号
* 变量名:device_info
* 是否必填:否
* 示例值:123456sb
* 类型:String(32)
* 说明:微信支付分配的终端设备号
* </pre>
*/
@XStreamAlias("device_info")
private String deviceInfo;

/**
* <pre>
* 字段名:代金券批次ID
* 变量名:coupon_stock_id
* 是否必填:是
* 示例值:1757
* 类型:String
* 说明:代金券批次Id
* </pre>
*/
@XStreamAlias("coupon_stock_id")
private String couponStockId;

/**
* <pre>
* 字段名:代金券名称
* 变量名:coupon_name
* 是否必填:否
* 示例值:测试代金券
* 类型:String
* 说明:代金券名称
* </pre>
*/
@XStreamAlias("coupon_name")
private String couponName;

/**
* <pre>
* 字段名:代金券面额
* 变量名:coupon_value
* 是否必填:是
* 示例值:5
* 类型:Unsinged int
* 说明:代金券面值,单位是分
* </pre>
*/
@XStreamAlias("coupon_value")
private Integer couponValue;

/**
* <pre>
* 字段名:代金券使用最低限额
* 变量名:coupon_mininumn
* 是否必填:否
* 示例值:10
* 类型:Unsinged int
* 说明:代金券使用最低限额,单位是分
* </pre>
*/
@XStreamAlias("coupon_mininumn")
private Integer couponMininumn;

/**
* <pre>
* 字段名:代金券批次状态
* 变量名:coupon_stock_status
* 是否必填:是
* 示例值:4
* 类型:int
* 说明:批次状态: 1-未激活;2-审批中;4-已激活;8-已作废;16-中止发放;
* </pre>
*/
@XStreamAlias("coupon_stock_status")
private Integer couponStockStatus;

/**
* <pre>
* 字段名:代金券数量
* 变量名:coupon_total
* 是否必填:是
* 示例值:100
* 类型:Unsigned int
* 说明:代金券数量
* </pre>
*/
@XStreamAlias("coupon_total")
private Integer couponTotal;

/**
* <pre>
* 字段名:代金券最大领取数量
* 变量名:max_quota
* 是否必填:否
* 示例值:1
* 类型:Unsigned int
* 说明:代金券每个人最多能领取的数量, 如果为0,则表示没有限制
* </pre>
*/
@XStreamAlias("max_quota")
private Integer maxQuota;

/**
* <pre>
* 字段名:代金券已经发送的数量
* 变量名:is_send_num
* 是否必填:否
* 示例值:0
* 类型:Unsigned int
* 说明:代金券已经发送的数量
* </pre>
*/
@XStreamAlias("is_send_num")
private Integer isSendNum;

/**
* <pre>
* 字段名:生效开始时间
* 变量名:begin_time
* 是否必填:是
* 示例值:1943787483
* 类型:String
* 说明:格式为时间戳
* </pre>
*/
@XStreamAlias("begin_time")
private String beginTime;

/**
* <pre>
* 字段名:生效结束时间
* 变量名:end_time
* 是否必填:是
* 示例值:1943787490
* 类型:String
* 说明:格式为时间戳
* </pre>
*/
@XStreamAlias("end_time")
private String endTime;

/**
* <pre>
* 字段名:创建时间
* 变量名:create_time
* 是否必填:是
* 示例值:1943787420
* 类型:String
* 说明:格式为时间戳
* </pre>
*/
@XStreamAlias("create_time")
private String createTime;

/**
* <pre>
* 字段名:代金券预算额度
* 变量名:coupon_budget
* 是否必填:否
* 示例值:500
* 类型:Unsigned int
* 说明:代金券预算额度
* </pre>
*/
@XStreamAlias("coupon_budget")
private Integer couponBudget;

public String getDeviceInfo() {
return this.deviceInfo;
}

public void setDeviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
}

public String getCouponStockId() {
return this.couponStockId;
}

public void setCouponStockId(String couponStockId) {
this.couponStockId = couponStockId;
}

public String getCouponName() {
return this.couponName;
}

public void setCouponName(String couponName) {
this.couponName = couponName;
}

public Integer getCouponValue() {
return this.couponValue;
}

public void setCouponValue(Integer couponValue) {
this.couponValue = couponValue;
}

public Integer getCouponMininumn() {
return this.couponMininumn;
}

public void setCouponMininumn(Integer couponMininumn) {
this.couponMininumn = couponMininumn;
}

public Integer getCouponStockStatus() {
return this.couponStockStatus;
}

public void setCouponStockStatus(Integer couponStockStatus) {
this.couponStockStatus = couponStockStatus;
}

public Integer getCouponTotal() {
return this.couponTotal;
}

public void setCouponTotal(Integer couponTotal) {
this.couponTotal = couponTotal;
}

public Integer getMaxQuota() {
return this.maxQuota;
}

public void setMaxQuota(Integer maxQuota) {
this.maxQuota = maxQuota;
}

public Integer getIsSendNum() {
return this.isSendNum;
}

public void setIsSendNum(Integer isSendNum) {
this.isSendNum = isSendNum;
}

public String getBeginTime() {
return this.beginTime;
}

public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}

public String getEndTime() {
return this.endTime;
}

public void setEndTime(String endTime) {
this.endTime = endTime;
}

public String getCreateTime() {
return this.createTime;
}

public void setCreateTime(String createTime) {
this.createTime = createTime;
}

public Integer getCouponBudget() {
return this.couponBudget;
}

public void setCouponBudget(Integer couponBudget) {
this.couponBudget = couponBudget;
}
}

+ 19
- 2
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java Bestand weergeven

@@ -1,7 +1,6 @@
package com.github.binarywang.wxpay.service;

import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest;
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult;
import com.github.binarywang.wxpay.bean.coupon.*;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.config.WxPayConfig;
@@ -351,4 +350,22 @@ public interface WxPayService {
* </pre>
*/
WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws WxPayException;

/**
* <pre>
* 查询代金券批次
* 接口请求链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/query_coupon_stock
* 文档地址:https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_4
* </pre>
*/
WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest request) throws WxPayException;

/**
* <pre>
* 查询代金券信息
* 接口请求链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/querycouponsinfo
* 文档地址:https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_5
* </pre>
*/
WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException;
}

+ 23
- 2
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java Bestand weergeven

@@ -1,8 +1,7 @@
package com.github.binarywang.wxpay.service.impl;

import com.github.binarywang.utils.qrcode.QrcodeUtils;
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest;
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult;
import com.github.binarywang.wxpay.bean.coupon.*;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.config.WxPayConfig;
@@ -476,4 +475,26 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService {
result.checkResult(this);
return result;
}

@Override
public WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest request) throws WxPayException {
request.checkAndSign(this.getConfig());

String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock";
String responseContent = this.post(url, request.toXML(), false);
WxPayCouponStockQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponStockQueryResult.class);
result.checkResult(this);
return result;
}

@Override
public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException {
request.checkAndSign(this.getConfig());

String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo";
String responseContent = this.post(url, request.toXML(), false);
WxPayCouponInfoQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class);
result.checkResult(this);
return result;
}
}

+ 19
- 2
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java Bestand weergeven

@@ -1,8 +1,7 @@
package com.github.binarywang.wxpay.service.impl;

import com.github.binarywang.utils.qrcode.QrcodeUtils;
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest;
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult;
import com.github.binarywang.wxpay.bean.coupon.*;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.exception.WxPayException;
@@ -283,4 +282,22 @@ public class WxPayServiceAbstractImplTest {
.build());
this.logger.info(result.toString());
}

@Test
public void testQueryCouponStock() throws Exception {
WxPayCouponStockQueryResult result = this.payService.queryCouponStock(WxPayCouponStockQueryRequest.newBuilder()
.couponStockId("123")
.build());
this.logger.info(result.toString());
}

@Test
public void testQueryCouponInfo() throws Exception {
WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(WxPayCouponInfoQueryRequest.newBuilder()
.openid("onqOjjrXT-776SpHnfexGm1_P7iE")
.couponId("11")
.stockId("1121")
.build());
this.logger.info(result.toString());
}
}

Laden…
Annuleren
Opslaan