修正卡券advanced_info 的bug;
修正 更新卡券 api时,清除不可更改字段的内容;
This commit is contained in:
parent
a00c40d3bb
commit
76f2787f89
@ -33,6 +33,9 @@ public abstract class CardCoupon {
|
||||
this.couponBaseInfo = couponBaseInfo;
|
||||
}
|
||||
|
||||
public void cleanCantUpdateField(){
|
||||
this.couponBaseInfo.cleanCantUpdateField();
|
||||
}
|
||||
/**
|
||||
* 卡券类型
|
||||
*
|
||||
|
||||
@ -60,6 +60,27 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
this.businessServices = builder.businessServices;
|
||||
}
|
||||
|
||||
|
||||
public JSONObject getUseCondition() {
|
||||
return useCondition;
|
||||
}
|
||||
|
||||
public JSONObject getAbstractConver() {
|
||||
return abstractConver;
|
||||
}
|
||||
|
||||
public List<JSONObject> getSlideImages() {
|
||||
return slideImages;
|
||||
}
|
||||
|
||||
public List<JSONObject> getTimeLimits() {
|
||||
return timeLimits;
|
||||
}
|
||||
|
||||
public List<BusinessService> getBusinessServices() {
|
||||
return businessServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券高级信息构造器
|
||||
*
|
||||
@ -91,13 +112,10 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
private List<BusinessService> businessServices;
|
||||
|
||||
public Builder() {
|
||||
this.useCondition = new JSONObject();
|
||||
this.abstractConver = new JSONObject();
|
||||
this.slideImages = new ArrayList<JSONObject>();
|
||||
this.timeLimits = new ArrayList<JSONObject>();
|
||||
this.businessServices = new ArrayList<BusinessService>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置使用门槛(条件)字段,若不填写使用条件则在券面拼写 :无最低消费限制,全场通用,不限品类;并在使用说明显示: 可与其他优惠共享
|
||||
*
|
||||
@ -143,6 +161,8 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
public Builder useCondition(String acceptCategory,
|
||||
String rejectCategory, int leastCost, String objectUseFor,
|
||||
boolean canUseWithOtherDiscount) {
|
||||
if(useCondition == null)
|
||||
useCondition = new JSONObject();
|
||||
useCondition.clear();
|
||||
if (StringUtil.isNotBlank(acceptCategory)) {
|
||||
useCondition.put("accept_category", acceptCategory);
|
||||
@ -171,6 +191,8 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public Builder abstractConver(String abstracts, String... convers) {
|
||||
if(abstractConver == null)
|
||||
abstractConver = new JSONObject();
|
||||
abstractConver.clear();
|
||||
abstractConver.put("abstract", abstracts);
|
||||
abstractConver.put("icon_url_list", convers);
|
||||
@ -185,6 +207,8 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public Builder slideImages(NameValue... slideImages) {
|
||||
if(this.slideImages == null)
|
||||
this.slideImages = new ArrayList<JSONObject>();
|
||||
this.slideImages.clear();
|
||||
for (NameValue nv : slideImages) {
|
||||
JSONObject slide = new JSONObject();
|
||||
@ -205,6 +229,8 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public Builder slideImage(String title, String url) {
|
||||
if(this.slideImages == null)
|
||||
this.slideImages = new ArrayList<JSONObject>();
|
||||
JSONObject slide = new JSONObject();
|
||||
slide.put("text", title);
|
||||
slide.put("image_url", url);
|
||||
@ -250,6 +276,8 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
*/
|
||||
public Builder timeLimit(Week week, int beginHour, int beignMinute,
|
||||
int endHour, int endMinute) {
|
||||
if(this.timeLimits == null)
|
||||
this.timeLimits = new ArrayList<JSONObject>();
|
||||
JSONObject timeLimit = new JSONObject();
|
||||
if (week != null) {
|
||||
timeLimit.put("type", week.name());
|
||||
@ -262,6 +290,7 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
if (endMinute > 0) {
|
||||
timeLimit.put("end_minute", endMinute);
|
||||
}
|
||||
this.timeLimits.add(timeLimit);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -273,9 +302,15 @@ public class CouponAdvanceInfo implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public Builder businessServices(BusinessService... businessServices) {
|
||||
if(this.businessServices == null)
|
||||
this.businessServices = new ArrayList<BusinessService>();
|
||||
this.businessServices.addAll(Arrays.asList(businessServices));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CouponAdvanceInfo build(){
|
||||
return new CouponAdvanceInfo(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -69,12 +69,12 @@ public class CouponBaseInfo implements Serializable {
|
||||
* 是否自定义Code码
|
||||
*/
|
||||
@JSONField(name = "use_custom_code")
|
||||
private boolean useCustomCode;
|
||||
private Boolean useCustomCode;
|
||||
/**
|
||||
* 指定特殊用户群体
|
||||
*/
|
||||
@JSONField(name = "bind_openid")
|
||||
private boolean bindOpenId;
|
||||
private Boolean bindOpenId;
|
||||
/**
|
||||
* 客服电话
|
||||
*/
|
||||
@ -221,11 +221,11 @@ public class CouponBaseInfo implements Serializable {
|
||||
return date;
|
||||
}
|
||||
|
||||
public boolean isUseCustomCode() {
|
||||
public Boolean isUseCustomCode() {
|
||||
return useCustomCode;
|
||||
}
|
||||
|
||||
public boolean isBindOpenId() {
|
||||
public Boolean isBindOpenId() {
|
||||
return bindOpenId;
|
||||
}
|
||||
|
||||
@ -312,6 +312,14 @@ public class CouponBaseInfo implements Serializable {
|
||||
+ ", canGiveFriend=" + canGiveFriend;
|
||||
}
|
||||
|
||||
public void cleanCantUpdateField() {
|
||||
this.brandName = null;
|
||||
this.title = null;
|
||||
this.sku = null;
|
||||
this.bindOpenId = null;
|
||||
this.useCustomCode = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券基础信息构造器
|
||||
*
|
||||
|
||||
@ -91,7 +91,7 @@ public class PayTest {
|
||||
c.set(Calendar.DAY_OF_MONTH, 4);
|
||||
System.err.println(c.getTime());
|
||||
OutputStream os = new FileOutputStream("/tmp/bill20160813.txt");
|
||||
PAY.downloadBill(c.getTime(), BillType.ALL, os);
|
||||
PAY.downloadBill(c.getTime(), BillType.ALL, os,null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -225,6 +225,7 @@ public class CardApi extends MpApi {
|
||||
JSONObject request = new JSONObject();
|
||||
request.put("card_id", cardId);
|
||||
CardType cardType = card.getCardType();
|
||||
card.cleanCantUpdateField();
|
||||
request.put(cardType.name().toLowerCase(), card);
|
||||
String card_update_uri = getRequestUri("card_update_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
|
||||
@ -4,6 +4,7 @@ import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.ApiResult;
|
||||
import com.foxinmy.weixin4j.model.card.CardCoupons;
|
||||
import com.foxinmy.weixin4j.model.card.CardQR;
|
||||
import com.foxinmy.weixin4j.model.card.CouponAdvanceInfo;
|
||||
import com.foxinmy.weixin4j.model.card.CouponBaseInfo;
|
||||
import com.foxinmy.weixin4j.model.card.MemberCard;
|
||||
import com.foxinmy.weixin4j.model.card.MemberInitInfo;
|
||||
@ -129,4 +130,33 @@ public class MemberCardTest extends TokenTest {
|
||||
cardApi.updateUserInfo(memberUpdateInfo);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void update() throws WeixinException {
|
||||
CouponBaseInfo.Builder builder = CardCoupons.customBase();
|
||||
// 基础必填字段
|
||||
builder.logoUrl(
|
||||
"http://mmbiz.qpic.cn/mmbiz_jpg/LtkLicv5iclfqzGpaDqDoMibM6FcMVTrmYXjLu7bJ1tM5MzCxNONQiaZHqrYzs0fTk2T5bLAAXLpvx32hQLmJTGBxQ/0")
|
||||
.codeType(CardCodeType.CODE_TYPE_BARCODE).brandName("***").title("***会员卡").cardColor(CardColor.Color010).notice("请出示会员卡")
|
||||
.description("***的会员卡的描述").quantity(10000);
|
||||
// 基础选填字段
|
||||
builder.canShare(false).canGiveFriend(false);
|
||||
builder.centerTitle("卡券居中按钮").centerSubTitle("显示在入口下方的提示语");
|
||||
MemberCard.Builder memberCardBuilder = CardCoupons.customMemberCard();
|
||||
//会员卡必填字段
|
||||
// 会员卡选填字段
|
||||
memberCardBuilder.prerogative("会员卡特权说明").supplyBalance(true).supplyBonus(false).activateWithWx(true);
|
||||
memberCardBuilder.customField1(FieldNameType.FIELD_NAME_TYPE_LEVEL, "等级", null);
|
||||
memberCardBuilder.backgroundPicUrl(
|
||||
"https://mmbiz.qlogo.cn/mmbiz/2FyQ9TURqmdibM6nYBiagZT49lSlY9Aicw4P3vsoa7dEZIYfNkiaMyzNVYT9jmYhjBbeC8jnkibwbibB5tghC5XcgysQ/0?wx_fmt=jpeg");
|
||||
|
||||
MemberCard memberCard = CardCoupons.createMemberCard(builder, memberCardBuilder);
|
||||
CouponAdvanceInfo.Builder advanceBuilder = new CouponAdvanceInfo.Builder();
|
||||
advanceBuilder.slideImage("此菜品精选食材,以独特的烹饪方法,最大程度地刺激食 客的味蕾","http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
|
||||
memberCard.setCouponAdvanceInfo(advanceBuilder.build());
|
||||
Boolean cardCoupon = cardApi.updateCardCoupon("pn-YDwk59Ft0JSFdGqObxUccUQHw", memberCard);
|
||||
System.out.println(cardCoupon);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user