完成会员卡的junit 。
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.7.3-SNAPSHOT</version>
|
||||
<version>1.7.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-base</artifactId>
|
||||
<name>weixin4j-base</name>
|
||||
|
||||
@@ -20,6 +20,8 @@ public abstract class BaseApi {
|
||||
|
||||
protected final WeixinRequestExecutor weixinExecutor;
|
||||
|
||||
private final Pattern uriPattern = Pattern.compile("(\\{[^\\}]*\\})");
|
||||
|
||||
public BaseApi() {
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
@@ -28,8 +30,7 @@ public abstract class BaseApi {
|
||||
|
||||
protected String getRequestUri(String key) {
|
||||
String url = weixinBundle().getString(key);
|
||||
Pattern p = Pattern.compile("(\\{[^\\}]*\\})");
|
||||
Matcher m = p.matcher(url);
|
||||
Matcher m = uriPattern.matcher(url);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String sub = null;
|
||||
while (m.find()) {
|
||||
|
||||
@@ -264,7 +264,7 @@
|
||||
</error>
|
||||
<error>
|
||||
<code>40073</code>
|
||||
<text>不合法的openid</text>
|
||||
<text>不合法的cardid</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40074</code>
|
||||
|
||||
@@ -115,4 +115,11 @@ public final class CardCoupons {
|
||||
GrouponCoupon coupon = new GrouponCoupon(couponBaseInfo, explain);
|
||||
return coupon;
|
||||
}
|
||||
|
||||
|
||||
public static MemberCard createMemberCard(CouponBaseInfo.Builder baseBuilder, MemberCard.Builder memberCardBudiler) {
|
||||
baseBuilder.build();
|
||||
MemberCard memberCard = new MemberCard(baseBuilder.build(), memberCardBudiler);
|
||||
return memberCard;
|
||||
}
|
||||
}
|
||||
@@ -432,9 +432,13 @@ public class CouponBaseInfo implements Serializable {
|
||||
*/
|
||||
private boolean canGiveFriend;
|
||||
|
||||
/**
|
||||
* 默认永久有效
|
||||
*/
|
||||
public Builder() {
|
||||
this.sku = new JSONObject();
|
||||
this.date = new JSONObject();
|
||||
this.date.put("type",CardActiveType.DATE_TYPE_PERMANENT);
|
||||
this.useAllLocation = true;
|
||||
this.canShare = true;
|
||||
this.canGiveFriend = true;
|
||||
@@ -534,6 +538,7 @@ public class CouponBaseInfo implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public Builder quantity(int quantity) {
|
||||
quantity = quantity > 100000000 ? 100000000 : quantity;
|
||||
this.sku.put("quantity", quantity);
|
||||
return this;
|
||||
}
|
||||
@@ -807,7 +812,10 @@ public class CouponBaseInfo implements Serializable {
|
||||
/**
|
||||
* 表示固定时长 (自领取后按天算。
|
||||
*/
|
||||
DATE_TYPE_FIX_TERM;
|
||||
DATE_TYPE_FIX_TERM, /**
|
||||
* 永久有效
|
||||
*/
|
||||
DATE_TYPE_PERMANENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MemberCard extends CardCoupon {
|
||||
* 显示余额
|
||||
*/
|
||||
@JSONField(name = "supply_balance")
|
||||
private String supplyBalance;
|
||||
private boolean supplyBalance;
|
||||
/**
|
||||
* 设置跳转外链查看余额详情。仅适用于余额无法通过激活接口同步的情况下使用该字段。
|
||||
*/
|
||||
@@ -134,6 +134,7 @@ public class MemberCard extends CardCoupon {
|
||||
this.bonusRule = builder.bonusRule;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return CardType.MEMBER_CARD;
|
||||
@@ -167,7 +168,7 @@ public class MemberCard extends CardCoupon {
|
||||
return bonusUrl;
|
||||
}
|
||||
|
||||
public String getSupplyBalance() {
|
||||
public boolean getSupplyBalance() {
|
||||
return supplyBalance;
|
||||
}
|
||||
|
||||
@@ -248,7 +249,7 @@ public class MemberCard extends CardCoupon {
|
||||
/**
|
||||
* 显示余额
|
||||
*/
|
||||
private String supplyBalance;
|
||||
private boolean supplyBalance;
|
||||
/**
|
||||
* 设置跳转外链查看余额详情。仅适用于余额无法通过激活接口同步的情况下使用该字段。
|
||||
*/
|
||||
@@ -291,92 +292,98 @@ public class MemberCard extends CardCoupon {
|
||||
private MemCardBonusRule bonusRule;
|
||||
|
||||
|
||||
public Builder setBackgroundPicUrl(String backgroundPicUrl) {
|
||||
public Builder backgroundPicUrl(String backgroundPicUrl) {
|
||||
this.backgroundPicUrl = backgroundPicUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPrerogative(String prerogative) {
|
||||
public Builder prerogative(String prerogative) {
|
||||
this.prerogative = prerogative;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAutoActivate(boolean autoActivate) {
|
||||
public Builder activateWithAuto(boolean autoActivate) {
|
||||
this.autoActivate = autoActivate;
|
||||
this.activateUrl = null;
|
||||
this.wxActivate = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setWxActivate(boolean wxActivate) {
|
||||
public Builder activateWithWx(boolean wxActivate) {
|
||||
this.wxActivate = wxActivate;
|
||||
this.autoActivate = false;
|
||||
this.activateUrl = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setActivateUrl(String activateUrl) {
|
||||
public Builder activateUrl(String activateUrl) {
|
||||
this.activateUrl = activateUrl;
|
||||
this.autoActivate = false;
|
||||
this.wxActivate = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSupplyBonus(boolean supplyBonus) {
|
||||
public Builder supplyBonus(boolean supplyBonus) {
|
||||
this.supplyBonus = supplyBonus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBonusUrl(String bonusUrl) {
|
||||
public Builder bonusUrl(String bonusUrl) {
|
||||
this.bonusUrl = bonusUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSupplyBalance(String supplyBalance) {
|
||||
public Builder supplyBalance(boolean supplyBalance) {
|
||||
this.supplyBalance = supplyBalance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBalanceUrl(String balanceUrl) {
|
||||
public Builder balanceUrl(String balanceUrl) {
|
||||
this.balanceUrl = balanceUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCustomField1(FieldNameType type, String name, String url) {
|
||||
public Builder customField1(FieldNameType type, String name, String url) {
|
||||
this.customField1 = new MemCardCustomField(type, name, url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCustomField2(FieldNameType type, String name, String url) {
|
||||
public Builder customField2(FieldNameType type, String name, String url) {
|
||||
this.customField2 = new MemCardCustomField(type, name, url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCustomField3(FieldNameType type, String name, String url) {
|
||||
public Builder customField3(FieldNameType type, String name, String url) {
|
||||
this.customField3 = new MemCardCustomField(type, name, url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBonusRules(String bonusRules) {
|
||||
public Builder bonusRules(String bonusRules) {
|
||||
this.bonusRules = bonusRules;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBalanceRules(String balanceRules) {
|
||||
public Builder balanceRules(String balanceRules) {
|
||||
this.balanceRules = balanceRules;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBonusCleared(String bonusCleared) {
|
||||
public Builder bonusCleared(String bonusCleared) {
|
||||
this.bonusCleared = bonusCleared;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCustomCell1(String name, String url, String tips) {
|
||||
public Builder customCell1(String name, String url, String tips) {
|
||||
this.customCell1 = new MemCardCustomField(name, url, tips);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDiscount(int discount) {
|
||||
public Builder discount(int discount) {
|
||||
this.discount = discount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBonusRule(MemCardBonusRule bonusRule) {
|
||||
public Builder bonusRule(MemCardBonusRule bonusRule) {
|
||||
this.bonusRule = bonusRule;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,14 @@ public class MemberUserForm {
|
||||
this.optionalForm = formBudiler;
|
||||
}
|
||||
|
||||
public FormBudiler getRequiredForm() {
|
||||
return requiredForm;
|
||||
}
|
||||
|
||||
public FormBudiler getOptionalForm() {
|
||||
return optionalForm;
|
||||
}
|
||||
|
||||
public final static class FormBudiler {
|
||||
|
||||
/**
|
||||
@@ -91,6 +99,7 @@ public class MemberUserForm {
|
||||
* 的字段是否允许用户激活后再次修改,商户设置为true
|
||||
* 时,需要接收相应事件通知处理修改事件
|
||||
*/
|
||||
@JSONField(name = "can_modify")
|
||||
private boolean canModify;
|
||||
/**
|
||||
* 自定义富文本类型,包含以下三个字段
|
||||
@@ -113,7 +122,7 @@ public class MemberUserForm {
|
||||
/**
|
||||
* 自定义富文本类型
|
||||
*/
|
||||
private FormBudiler addRichField(ActivateFormFieldType fieldType, String name, String... values) {
|
||||
public FormBudiler addRichField(ActivateFormFieldType fieldType, String name, String... values) {
|
||||
if (richFieldList == null) {
|
||||
richFieldList = new JSONArray();
|
||||
}
|
||||
@@ -125,6 +134,12 @@ public class MemberUserForm {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormBudiler canModify(boolean modify){
|
||||
this.canModify = canModify;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义公共字段
|
||||
*/
|
||||
@@ -152,8 +167,21 @@ public class MemberUserForm {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCanModify() {
|
||||
return canModify;
|
||||
}
|
||||
|
||||
public JSONArray getRichFieldList() {
|
||||
return richFieldList;
|
||||
}
|
||||
|
||||
public HashSet<ActivateCommonField> getCommonFieldIdList() {
|
||||
return commonFieldIdList;
|
||||
}
|
||||
|
||||
public HashSet<String> getCustomFieldList() {
|
||||
return customFieldList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user