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

This commit is contained in:
Binary Wang 2017-07-15 19:16:52 +08:00
parent 9368177d00
commit 9f669dff82
7 changed files with 1201 additions and 6 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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());
}
}