mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
增加会员卡管理服务的更新会员信息接口的实现 (#283)
* 修复UserInfo反序列化的bug,补充其单元测试 * 增加`更新会员信息`接口的实现 * 增加会员卡相关接口的测试类 包含下述方法: 1. 会员卡激活接口 2. 会员信息获取接口 3. 更新会员信息接口
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package me.chanjar.weixin.mp.bean.membercard;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 控制原生消息结构体,包含各字段的消息控制字段。
|
||||
*
|
||||
* 用于 `7 更新会员信息` 的接口参数调用
|
||||
* https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
|
||||
*
|
||||
* @author YuJian(mgcnrx11@gmail.com)
|
||||
* @version 2017/7/15
|
||||
*/
|
||||
public class NotifyOptional {
|
||||
|
||||
// 积分变动时是否触发系统模板消息,默认为true
|
||||
@SerializedName("is_notify_bonus")
|
||||
private Boolean isNotifyBonus;
|
||||
|
||||
// 余额变动时是否触发系统模板消息,默认为true
|
||||
@SerializedName("is_notify_balance")
|
||||
private Boolean isNotifyBalance;
|
||||
|
||||
// 自定义group1变动时是否触发系统模板消息,默认为false。(2、3同理)
|
||||
@SerializedName("is_notify_custom_field1")
|
||||
private Boolean isNotifyCustomField1;
|
||||
|
||||
@SerializedName("is_notify_custom_field2")
|
||||
private Boolean isNotifyCustomField2;
|
||||
|
||||
@SerializedName("is_notify_custom_field3")
|
||||
private Boolean isNotifyCustomField3;
|
||||
|
||||
public Boolean getNotifyBonus() {
|
||||
return isNotifyBonus;
|
||||
}
|
||||
|
||||
public void setNotifyBonus(Boolean notifyBonus) {
|
||||
isNotifyBonus = notifyBonus;
|
||||
}
|
||||
|
||||
public Boolean getNotifyBalance() {
|
||||
return isNotifyBalance;
|
||||
}
|
||||
|
||||
public void setNotifyBalance(Boolean notifyBalance) {
|
||||
isNotifyBalance = notifyBalance;
|
||||
}
|
||||
|
||||
public Boolean getNotifyCustomField1() {
|
||||
return isNotifyCustomField1;
|
||||
}
|
||||
|
||||
public void setNotifyCustomField1(Boolean notifyCustomField1) {
|
||||
isNotifyCustomField1 = notifyCustomField1;
|
||||
}
|
||||
|
||||
public Boolean getNotifyCustomField2() {
|
||||
return isNotifyCustomField2;
|
||||
}
|
||||
|
||||
public void setNotifyCustomField2(Boolean notifyCustomField2) {
|
||||
isNotifyCustomField2 = notifyCustomField2;
|
||||
}
|
||||
|
||||
public Boolean getNotifyCustomField3() {
|
||||
return isNotifyCustomField3;
|
||||
}
|
||||
|
||||
public void setNotifyCustomField3(Boolean notifyCustomField3) {
|
||||
isNotifyCustomField3 = notifyCustomField3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package me.chanjar.weixin.mp.bean.membercard;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 更新会员信息所需字段消息。
|
||||
*
|
||||
* 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时
|
||||
* add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。
|
||||
* 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。
|
||||
*
|
||||
* @author YuJian(mgcnrx11@gmail.com)
|
||||
* @version 2017/7/15
|
||||
*/
|
||||
public class WxMpMemberCardUpdateMessage {
|
||||
|
||||
// 领取会员卡用户获得的code
|
||||
private String code;
|
||||
// 卡券ID,自定义code卡券必填
|
||||
@SerializedName("card_id")
|
||||
private String cardId;
|
||||
// 支持商家激活时针对单个会员卡分配自定义的会员卡背景
|
||||
@SerializedName("background_pic_url")
|
||||
private String backgroundPicUrl;
|
||||
// 需要设置的积分全量值,传入的数值会直接显示
|
||||
private Integer bonus;
|
||||
// 本次积分变动值,传负数代表减少
|
||||
@SerializedName("add_bonus")
|
||||
private Integer addBounus;
|
||||
// 商家自定义积分消耗记录,不超过14个汉字
|
||||
@SerializedName("record_bonus")
|
||||
private String recordBonus;
|
||||
// 需要设置的余额全量值,传入的数值会直接显示在卡面
|
||||
private Integer balance;
|
||||
// 本次余额变动值,传负数代表减少
|
||||
@SerializedName("add_balance")
|
||||
private Integer addBalance;
|
||||
// 商家自定义金额消耗记录,不超过14个汉字。
|
||||
@SerializedName("record_balance")
|
||||
private String recordBalance;
|
||||
|
||||
// 创建时字段custom_field定义类型的最新数值,限制为4个汉字,12字节。
|
||||
@SerializedName("custom_field_value1")
|
||||
private String customFieldValue1;
|
||||
@SerializedName("custom_field_value2")
|
||||
private String customFieldValue2;
|
||||
@SerializedName("custom_field_value3")
|
||||
private String customFieldValue3;
|
||||
|
||||
@SerializedName("notify_optional")
|
||||
private NotifyOptional notifyOptional;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCardId() {
|
||||
return cardId;
|
||||
}
|
||||
|
||||
public void setCardId(String cardId) {
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public String getBackgroundPicUrl() {
|
||||
return backgroundPicUrl;
|
||||
}
|
||||
|
||||
public void setBackgroundPicUrl(String backgroundPicUrl) {
|
||||
this.backgroundPicUrl = backgroundPicUrl;
|
||||
}
|
||||
|
||||
public Integer getBonus() {
|
||||
return bonus;
|
||||
}
|
||||
|
||||
public void setBonus(Integer bonus) {
|
||||
this.bonus = bonus;
|
||||
}
|
||||
|
||||
public Integer getAddBounus() {
|
||||
return addBounus;
|
||||
}
|
||||
|
||||
public void setAddBounus(Integer addBounus) {
|
||||
this.addBounus = addBounus;
|
||||
}
|
||||
|
||||
public String getRecordBonus() {
|
||||
return recordBonus;
|
||||
}
|
||||
|
||||
public void setRecordBonus(String recordBonus) {
|
||||
this.recordBonus = recordBonus;
|
||||
}
|
||||
|
||||
public Integer getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(Integer balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public Integer getAddBalance() {
|
||||
return addBalance;
|
||||
}
|
||||
|
||||
public void setAddBalance(Integer addBalance) {
|
||||
this.addBalance = addBalance;
|
||||
}
|
||||
|
||||
public String getRecordBalance() {
|
||||
return recordBalance;
|
||||
}
|
||||
|
||||
public void setRecordBalance(String recordBalance) {
|
||||
this.recordBalance = recordBalance;
|
||||
}
|
||||
|
||||
public String getCustomFieldValue1() {
|
||||
return customFieldValue1;
|
||||
}
|
||||
|
||||
public void setCustomFieldValue1(String customFieldValue1) {
|
||||
this.customFieldValue1 = customFieldValue1;
|
||||
}
|
||||
|
||||
public String getCustomFieldValue2() {
|
||||
return customFieldValue2;
|
||||
}
|
||||
|
||||
public void setCustomFieldValue2(String customFieldValue2) {
|
||||
this.customFieldValue2 = customFieldValue2;
|
||||
}
|
||||
|
||||
public String getCustomFieldValue3() {
|
||||
return customFieldValue3;
|
||||
}
|
||||
|
||||
public void setCustomFieldValue3(String customFieldValue3) {
|
||||
this.customFieldValue3 = customFieldValue3;
|
||||
}
|
||||
|
||||
public NotifyOptional getNotifyOptional() {
|
||||
return notifyOptional;
|
||||
}
|
||||
|
||||
public void setNotifyOptional(NotifyOptional notifyOptional) {
|
||||
this.notifyOptional = notifyOptional;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package me.chanjar.weixin.mp.bean.membercard;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用于 `7 更新会员信息` 的接口调用后的返回结果
|
||||
* https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
|
||||
*
|
||||
* @author YuJian(mgcnrx11@gmail.com)
|
||||
* @version 2017/7/15
|
||||
*/
|
||||
public class WxMpMemberCardUpdateResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9084886191442098311L;
|
||||
|
||||
private String errorCode;
|
||||
|
||||
private String errorMsg;
|
||||
|
||||
private String openId;
|
||||
|
||||
private Integer resultBonus;
|
||||
|
||||
private Integer resultBalance;
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public Integer getResultBonus() {
|
||||
return resultBonus;
|
||||
}
|
||||
|
||||
public void setResultBonus(Integer resultBonus) {
|
||||
this.resultBonus = resultBonus;
|
||||
}
|
||||
|
||||
public Integer getResultBalance() {
|
||||
return resultBalance;
|
||||
}
|
||||
|
||||
public void setResultBalance(Integer resultBalance) {
|
||||
this.resultBalance = resultBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxMpMemberCardUpdateResult{" +
|
||||
"errorCode='" + errorCode + '\'' +
|
||||
", errorMsg='" + errorMsg + '\'' +
|
||||
", openId='" + openId + '\'' +
|
||||
", resultBonus=" + resultBonus +
|
||||
", resultBalance=" + resultBalance +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static WxMpMemberCardUpdateResult fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpMemberCardUpdateResult.class);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package me.chanjar.weixin.mp.bean.membercard;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -133,5 +135,9 @@ public class WxMpMemberCardUserInfoResult implements Serializable {
|
||||
", hasActive=" + hasActive +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static WxMpMemberCardUserInfoResult fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpMemberCardUserInfoResult.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user