model包拆分media/paging & 包拆分card/mch & 新增card卡券相关类 & 新增CardApi:创建卡券接口
This commit is contained in:
+10
-1
@@ -155,4 +155,13 @@
|
||||
|
||||
+ 重新整理HttpClinet
|
||||
|
||||
+ 新增OkHttp实现
|
||||
+ 新增OkHttp实现
|
||||
|
||||
|
||||
* 2016-08-05
|
||||
|
||||
+ model包拆分media/paing
|
||||
|
||||
+ type包拆分card/mch
|
||||
|
||||
+ 新增card卡券相关类
|
||||
@@ -11,8 +11,8 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Pageable;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.model.paging.Pageable;
|
||||
import com.foxinmy.weixin4j.payment.mch.CorpPayment;
|
||||
import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.payment.mch.APPPayRequest;
|
||||
import com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest;
|
||||
@@ -36,12 +35,13 @@ import com.foxinmy.weixin4j.payment.mch.PrePay;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.WAPPayRequest;
|
||||
import com.foxinmy.weixin4j.type.BillType;
|
||||
import com.foxinmy.weixin4j.type.CurrencyType;
|
||||
import com.foxinmy.weixin4j.type.IdQuery;
|
||||
import com.foxinmy.weixin4j.type.IdType;
|
||||
import com.foxinmy.weixin4j.type.SignType;
|
||||
import com.foxinmy.weixin4j.type.TradeType;
|
||||
import com.foxinmy.weixin4j.type.mch.BillType;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.DigestUtil;
|
||||
import com.foxinmy.weixin4j.util.MapUtil;
|
||||
@@ -465,8 +465,8 @@ public class PayApi extends MchApi {
|
||||
try {
|
||||
Map<String, String> map = createBaseRequestMap(idQuery);
|
||||
map.put("out_refund_no", outRefundNo);
|
||||
map.put("total_fee", DateUtil.formatFee2Fen(totalFee));
|
||||
map.put("refund_fee", DateUtil.formatFee2Fen(refundFee));
|
||||
map.put("total_fee", Integer.toString(DateUtil.formatYuan2Fen(totalFee)));
|
||||
map.put("refund_fee", Integer.toString(DateUtil.formatYuan2Fen(refundFee)));
|
||||
if (StringUtil.isBlank(opUserId)) {
|
||||
opUserId = weixinAccount.getMchId();
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import redis.clients.jedis.HostAndPort;
|
||||
import redis.clients.jedis.JedisCluster;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardType;
|
||||
|
||||
/**
|
||||
* 卡券
|
||||
*
|
||||
* @className CardCoupon
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年4月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public abstract class CardCoupon {
|
||||
/**
|
||||
* 卡券基础信息,必填属性
|
||||
*/
|
||||
@JSONField(name = "base_info")
|
||||
private final CouponBaseInfo couponBaseInfo;
|
||||
/**
|
||||
* 卡券高级信息,选填属性
|
||||
*/
|
||||
@JSONField(name = "advanced_info")
|
||||
private CouponAdvanceInfo couponAdvanceInfo;
|
||||
|
||||
/**
|
||||
* 卡券
|
||||
*
|
||||
* @param couponBaseInfo
|
||||
* 基础信息
|
||||
*/
|
||||
protected CardCoupon(CouponBaseInfo couponBaseInfo) {
|
||||
this.couponBaseInfo = couponBaseInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract CardType getCardType();
|
||||
|
||||
public CouponBaseInfo getCouponBaseInfo() {
|
||||
return couponBaseInfo;
|
||||
}
|
||||
|
||||
public CouponAdvanceInfo getCouponAdvanceInfo() {
|
||||
return couponAdvanceInfo;
|
||||
}
|
||||
|
||||
public void setCouponAdvanceInfo(CouponAdvanceInfo couponAdvanceInfo) {
|
||||
this.couponAdvanceInfo = couponAdvanceInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "baseInfo=" + couponBaseInfo + ", advanceInfo="
|
||||
+ couponAdvanceInfo + ", cardType=" + getCardType();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
/**
|
||||
* 卡券构造器
|
||||
*
|
||||
* @className CardCoupons
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年6月1日
|
||||
* @since JDK 1.6
|
||||
* @see CashCoupon
|
||||
* @see DiscountCoupon
|
||||
* @see GeneralCoupon
|
||||
* @see GiftCoupon
|
||||
* @see GrouponCoupon
|
||||
*/
|
||||
public final class CardCoupons {
|
||||
private CardCoupons() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券基础信息构造器
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static CouponBaseInfo.Builder customBase() {
|
||||
return new CouponBaseInfo.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券高级信息构造器
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static CouponAdvanceInfo.Builder customAdvance() {
|
||||
return new CouponAdvanceInfo.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建代金券
|
||||
*
|
||||
* @param builder
|
||||
* 卡券基础信息构造器 必填
|
||||
* @param reduceCost
|
||||
* 减免金额 (单位为元) 必填
|
||||
* @param leastCost
|
||||
* 起用金额(单位为元),如果无起用门槛则填0
|
||||
*/
|
||||
public static CardCoupon createCashCoupon(CouponBaseInfo.Builder builder,
|
||||
double reduceCost, double leastCost) {
|
||||
CouponBaseInfo couponBaseInfo = builder.build();
|
||||
CashCoupon coupon = new CashCoupon(couponBaseInfo, reduceCost);
|
||||
coupon.setLeastCost(leastCost);
|
||||
return coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建折扣券
|
||||
*
|
||||
* @param builder
|
||||
* 卡券基础信息构造器 必填
|
||||
* @param discount
|
||||
* 打折额度百分百,如:传入30就是七折 必填
|
||||
*/
|
||||
public static CardCoupon createDiscountCoupon(
|
||||
CouponBaseInfo.Builder builder, int discount) {
|
||||
CouponBaseInfo couponBaseInfo = builder.build();
|
||||
DiscountCoupon coupon = new DiscountCoupon(couponBaseInfo, discount);
|
||||
return coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建普通优惠券
|
||||
*
|
||||
* @param builder
|
||||
* 卡券基础信息构造器 必填
|
||||
* @param explain
|
||||
* 优惠详情 如:音乐木盒 必填
|
||||
*/
|
||||
public static CardCoupon createGeneralCoupon(
|
||||
CouponBaseInfo.Builder builder, String explain) {
|
||||
CouponBaseInfo couponBaseInfo = builder.build();
|
||||
GeneralCoupon coupon = new GeneralCoupon(couponBaseInfo, explain);
|
||||
return coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建普通优惠券
|
||||
*
|
||||
* @param builder
|
||||
* 卡券基础信息构造器 必填
|
||||
* @param explain
|
||||
* 兑换说明 如:可兑换音乐木盒一个 必填
|
||||
*/
|
||||
public static CardCoupon createGiftCoupon(CouponBaseInfo.Builder builder,
|
||||
String explain) {
|
||||
CouponBaseInfo couponBaseInfo = builder.build();
|
||||
GiftCoupon coupon = new GiftCoupon(couponBaseInfo, explain);
|
||||
return coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建团购券
|
||||
*
|
||||
* @param builder
|
||||
* 卡券基础信息构造器 必填
|
||||
* @param explain
|
||||
* 团购详情 如:双人套餐\n -进口红酒一支。\n孜然牛肉一份 必填
|
||||
*/
|
||||
public static CardCoupon createGrouponCoupon(
|
||||
CouponBaseInfo.Builder builder, String explain) {
|
||||
CouponBaseInfo couponBaseInfo = builder.build();
|
||||
GrouponCoupon coupon = new GrouponCoupon(couponBaseInfo, explain);
|
||||
return coupon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
* 代金券
|
||||
*
|
||||
* @className CashCoupon
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public class CashCoupon extends CardCoupon {
|
||||
/**
|
||||
* 起用金额(单位为分),如果无起用门槛则填0
|
||||
*/
|
||||
@JSONField(name = "least_cost")
|
||||
private int leastCost;
|
||||
/**
|
||||
* 减免金额(单位为分)
|
||||
*/
|
||||
@JSONField(name = "reduce_cost")
|
||||
private final int reduceCost;
|
||||
|
||||
/**
|
||||
* 构造代金券
|
||||
*
|
||||
* @param couponBaseInfo
|
||||
* 基础信息
|
||||
* @param reduceCost
|
||||
* 减免金额 单位元
|
||||
*/
|
||||
public CashCoupon(CouponBaseInfo couponBaseInfo, double reduceCost) {
|
||||
super(couponBaseInfo);
|
||||
this.reduceCost = DateUtil.formatYuan2Fen(reduceCost);
|
||||
}
|
||||
|
||||
public int getLeastCost() {
|
||||
return leastCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
|
||||
*
|
||||
* @return 元单位
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
public double getFormatLeastCost() {
|
||||
return leastCost / 100d;
|
||||
}
|
||||
|
||||
public void setLeastCost(double leastCost) {
|
||||
this.leastCost = DateUtil.formatYuan2Fen(reduceCost);
|
||||
}
|
||||
|
||||
public int getReduceCost() {
|
||||
return reduceCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
|
||||
*
|
||||
* @return 元单位
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
public double getFormatReduceCost() {
|
||||
return reduceCost / 100d;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return CardType.CASH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CashCoupon [leastCost=" + leastCost + ", reduceCost="
|
||||
+ reduceCost + ", " + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.Week;
|
||||
import com.foxinmy.weixin4j.util.NameValue;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 卡券高级信息: <li>1.高级字段为商户额外展示信息字段,非必填,但是填入某些结构体后,须填充完整方可显示:如填入text_image_list结构体
|
||||
* 时,须同时传入image_url和text,否则也会报错; <li>
|
||||
* 2.填入时间限制字段(time_limit),只控制显示,不控制实际使用逻辑,不填默认不显示 <li>
|
||||
* 3.创建卡券时,开发者填入的时间戳须注意时间戳溢出时间,设置的时间戳须早于2038年1月19日
|
||||
*
|
||||
* @className CouponAdvancedInfo
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年6月1日
|
||||
* @since JDK 1.6
|
||||
* @see Builder
|
||||
*/
|
||||
public class CouponAdvanceInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3626615706377721404L;
|
||||
/**
|
||||
* 使用门槛(条件)字段,若不填写使用条件则在券面拼写 :无最低消费限制,全场通用,不限品类;并在使用说明显示: 可与其他优惠共享
|
||||
*/
|
||||
@JSONField(name = "use_condition")
|
||||
private final JSONObject useCondition;
|
||||
/**
|
||||
* 封面摘要结构
|
||||
*/
|
||||
@JSONField(name = "abstract")
|
||||
private final JSONObject abstractConver;
|
||||
/**
|
||||
* 图文列表,显示在详情内页 ,优惠券券开发者须至少传入 一组图文列表
|
||||
*/
|
||||
@JSONField(name = "text_image_list")
|
||||
private final List<JSONObject> slideImages;
|
||||
/**
|
||||
* 使用时段限制
|
||||
*/
|
||||
@JSONField(name = "time_limit")
|
||||
private final List<JSONObject> timeLimits;
|
||||
/**
|
||||
* 商家服务类型
|
||||
*/
|
||||
@JSONField(name = "business_service")
|
||||
private final List<BusinessService> businessServices;
|
||||
|
||||
private CouponAdvanceInfo(Builder builder) {
|
||||
this.useCondition = builder.useCondition;
|
||||
this.abstractConver = builder.abstractConver;
|
||||
this.slideImages = builder.slideImages;
|
||||
this.timeLimits = builder.timeLimits;
|
||||
this.businessServices = builder.businessServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券高级信息构造器
|
||||
*
|
||||
* @className Builder
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public static final class Builder {
|
||||
/**
|
||||
* 使用门槛(条件)字段,若不填写使用条件则在券面拼写 :无最低消费限制,全场通用,不限品类;并在使用说明显示: 可与其他优惠共享
|
||||
*/
|
||||
private JSONObject useCondition;
|
||||
/**
|
||||
* 封面摘要结构
|
||||
*/
|
||||
private JSONObject abstractConver;
|
||||
/**
|
||||
* 图文列表,显示在详情内页 ,优惠券券开发者须至少传入 一组图文列表
|
||||
*/
|
||||
private List<JSONObject> slideImages;
|
||||
/**
|
||||
* 使用时段限制
|
||||
*/
|
||||
private List<JSONObject> timeLimits;
|
||||
/**
|
||||
* 商家服务类型
|
||||
*/
|
||||
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>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置使用门槛(条件)字段,若不填写使用条件则在券面拼写 :无最低消费限制,全场通用,不限品类;并在使用说明显示: 可与其他优惠共享
|
||||
*
|
||||
* @param acceptCategory
|
||||
* 指定可用的商品类目,仅用于代金券类型 ,填入后将在券面拼写适用于xxx
|
||||
* @param rejectCategory
|
||||
* 指定可用的商品类目,仅用于代金券类型 ,填入后将在券面拼写不适用于xxxx
|
||||
* @return
|
||||
*/
|
||||
public Builder useCondition(String acceptCategory, String rejectCategory) {
|
||||
return useCondition(acceptCategory, rejectCategory, 0, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置使用门槛(条件)字段,若不填写使用条件则在券面拼写 :无最低消费限制,全场通用,不限品类;并在使用说明显示: 可与其他优惠共享
|
||||
*
|
||||
* @param leastCost
|
||||
* 满减门槛字段,可用于兑换券和代金券 ,填入后将在全面拼写消费满xx元可用。
|
||||
* @param objectUseFor
|
||||
* 购买xx可用类型门槛,仅用于兑换 ,填入后自动拼写购买xxx可用。
|
||||
* @return
|
||||
*/
|
||||
public Builder useCondition(int leastCost, String objectUseFor) {
|
||||
return useCondition(null, null, leastCost, objectUseFor, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置使用门槛(条件)字段,若不填写使用条件则在券面拼写 :无最低消费限制,全场通用,不限品类;并在使用说明显示: 可与其他优惠共享
|
||||
*
|
||||
* @param acceptCategory
|
||||
* 指定可用的商品类目,仅用于代金券类型 ,填入后将在券面拼写适用于xxx
|
||||
* @param rejectCategory
|
||||
* 指定可用的商品类目,仅用于代金券类型 ,填入后将在券面拼写不适用于xxxx
|
||||
* @param leastCost
|
||||
* 满减门槛字段,可用于兑换券和代金券 ,填入后将在全面拼写消费满xx元可用。
|
||||
* @param objectUseFor
|
||||
* 购买xx可用类型门槛,仅用于兑换 ,填入后自动拼写购买xxx可用。
|
||||
* @param canUseWithOtherDiscount
|
||||
* 不可以与其他类型共享门槛 ,填写false时系统将在使用须知里 拼写“不可与其他优惠共享”,
|
||||
* 填写true时系统将在使用须知里 拼写“可与其他优惠共享”, 默认为true
|
||||
* @return
|
||||
*/
|
||||
public Builder useCondition(String acceptCategory,
|
||||
String rejectCategory, int leastCost, String objectUseFor,
|
||||
boolean canUseWithOtherDiscount) {
|
||||
useCondition.clear();
|
||||
if (StringUtil.isNotBlank(acceptCategory)) {
|
||||
useCondition.put("accept_category", acceptCategory);
|
||||
}
|
||||
if (StringUtil.isNotBlank(rejectCategory)) {
|
||||
useCondition.put("reject_category", rejectCategory);
|
||||
}
|
||||
if (leastCost > 0) {
|
||||
useCondition.put("least_cost", leastCost);
|
||||
}
|
||||
if (StringUtil.isNotBlank(objectUseFor)) {
|
||||
useCondition.put("object_use_for", objectUseFor);
|
||||
}
|
||||
useCondition.put("can_use_with_other_discount",
|
||||
canUseWithOtherDiscount);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置封面摘要
|
||||
*
|
||||
* @param abstracts
|
||||
* 封面摘要简介
|
||||
* @param convers
|
||||
* 封面图片列表
|
||||
* @return
|
||||
*/
|
||||
public Builder abstractConver(String abstracts, String... convers) {
|
||||
abstractConver.clear();
|
||||
abstractConver.put("abstract", abstracts);
|
||||
abstractConver.put("icon_url_list", convers);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图文列表,显示在详情内页 ,优惠券券开发者须至少传入 一组图文列表
|
||||
*
|
||||
* @param slideImages
|
||||
* 图文列表,name为图片描述,value为图片链接
|
||||
* @return
|
||||
*/
|
||||
public Builder slideImages(NameValue... slideImages) {
|
||||
this.slideImages.clear();
|
||||
for (NameValue nv : slideImages) {
|
||||
JSONObject slide = new JSONObject();
|
||||
slide.put("text", nv.getName());
|
||||
slide.put("image_url", nv.getValue());
|
||||
this.slideImages.add(slide);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图文列表,显示在详情内页 ,优惠券券开发者须至少传入 一组图文列表
|
||||
*
|
||||
* @param title
|
||||
* 图片标题
|
||||
* @param url
|
||||
* 图片链接
|
||||
* @return
|
||||
*/
|
||||
public Builder slideImage(String title, String url) {
|
||||
JSONObject slide = new JSONObject();
|
||||
slide.put("text", title);
|
||||
slide.put("image_url", url);
|
||||
this.slideImages.add(slide);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置使用时段限制
|
||||
*
|
||||
* @param week
|
||||
* 星期,此处只控制显示, 不控制实际使用逻辑,不填默认不显示
|
||||
* @param beginHour
|
||||
* 当前week类型下的起始时间(小时) ,如当前结构体内填写了MONDAY, 此处填写了10,则此处表示周一
|
||||
* 10:00可用
|
||||
* @param beignMinute
|
||||
* 当前week类型下的起始时间(分钟) ,如当前结构体内填写了MONDAY,
|
||||
* begin_hour填写10,此处填写了59, 则此处表示周一 10:59可用
|
||||
* @return
|
||||
*/
|
||||
public Builder timeLimit(Week week, int beginHour, int beignMinute) {
|
||||
return timeLimit(week, beginHour, beignMinute, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 使用时段限制
|
||||
*
|
||||
* @param week
|
||||
* 星期,此处只控制显示, 不控制实际使用逻辑,不填默认不显示
|
||||
* @param beginHour
|
||||
* 当前week类型下的起始时间(小时) ,如当前结构体内填写了MONDAY, 此处填写了10,则此处表示周一
|
||||
* 10:00可用
|
||||
* @param beignMinute
|
||||
* 当前week类型下的起始时间(分钟) ,如当前结构体内填写了MONDAY,
|
||||
* begin_hour填写10,此处填写了59, 则此处表示周一 10:59可用
|
||||
* @param endHour
|
||||
* 当前week类型下的结束时间(小时) ,如当前结构体内填写了MONDAY, 此处填写了20,则此处表示周一
|
||||
* 10:00-20:00可用
|
||||
* @param endMinute
|
||||
* 当前week类型下的结束时间(分钟) ,如当前结构体内填写了MONDAY,
|
||||
* begin_hour填写10,此处填写了59, 则此处表示周一 10:59-00:59可用
|
||||
* @return
|
||||
*/
|
||||
public Builder timeLimit(Week week, int beginHour, int beignMinute,
|
||||
int endHour, int endMinute) {
|
||||
JSONObject timeLimit = new JSONObject();
|
||||
if (week != null) {
|
||||
timeLimit.put("type", week.name());
|
||||
}
|
||||
timeLimit.put("begin_hour", beginHour);
|
||||
if (beignMinute > 0) {
|
||||
timeLimit.put("begin_minute", beignMinute);
|
||||
}
|
||||
timeLimit.put("end_hour", endHour);
|
||||
if (endMinute > 0) {
|
||||
timeLimit.put("end_minute", endMinute);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商家服务类型
|
||||
*
|
||||
* @param businessServices
|
||||
* 服务类型
|
||||
* @return
|
||||
*/
|
||||
public Builder businessServices(BusinessService... businessServices) {
|
||||
this.businessServices.addAll(Arrays.asList(businessServices));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家服务
|
||||
*
|
||||
* @className BusinessService
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月5日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public enum BusinessService {
|
||||
/**
|
||||
* 外卖服务
|
||||
*/
|
||||
BIZ_SERVICE_DELIVER,
|
||||
/**
|
||||
* 停车位
|
||||
*/
|
||||
BIZ_SERVICE_FREE_PARK,
|
||||
/**
|
||||
* 可带宠物
|
||||
*/
|
||||
BIZ_SERVICE_WITH_PET,
|
||||
/**
|
||||
* 免费wifi
|
||||
*/
|
||||
BIZ_SERVICE_FREE_WIFI;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,813 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardCodeType;
|
||||
import com.foxinmy.weixin4j.type.card.CardColor;
|
||||
|
||||
/**
|
||||
* 卡券基本信息
|
||||
*
|
||||
* @className CouponBaseInfo
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年6月1日
|
||||
* @since JDK 1.6
|
||||
* @see Builder
|
||||
*/
|
||||
public class CouponBaseInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5725424121330101716L;
|
||||
/**
|
||||
* 卡券的商户logo,建议像素为300*300。
|
||||
*/
|
||||
@JSONField(name = "logo_url")
|
||||
private String logoUrl;
|
||||
/**
|
||||
* 商户名字,字数上限为12个汉字,如:海底捞
|
||||
*/
|
||||
@JSONField(name = "brand_name")
|
||||
private String brandName;
|
||||
/**
|
||||
* 卡券名,字数上限为9个汉字。(建议涵盖卡券属性、服务及金额),如:双人套餐100元兑换券
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 码型
|
||||
*/
|
||||
@JSONField(name = "code_type")
|
||||
private CardCodeType codeType;
|
||||
/**
|
||||
* 卡券颜色
|
||||
*/
|
||||
@JSONField(name = "color")
|
||||
private CardColor cardColor;
|
||||
/**
|
||||
* 卡券使用提醒,字数上限为16个汉字,如:请出示二维码
|
||||
*/
|
||||
private String notice;
|
||||
/**
|
||||
* 卡券使用说明,字数上限为1024个汉字,如:不可与其他优惠同享
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 卡券库存的数量,上限为100000000。
|
||||
*/
|
||||
private JSONObject sku;
|
||||
/**
|
||||
* 使用日期,有效期的信息。
|
||||
*/
|
||||
@JSONField(name = "date_info")
|
||||
private JSONObject date;
|
||||
|
||||
// 以下为选填字段
|
||||
/**
|
||||
* 是否自定义Code码
|
||||
*/
|
||||
@JSONField(name = "use_custom_code")
|
||||
private boolean useCustomCode;
|
||||
/**
|
||||
* 指定特殊用户群体
|
||||
*/
|
||||
@JSONField(name = "bind_openid")
|
||||
private boolean bindOpenId;
|
||||
/**
|
||||
* 客服电话
|
||||
*/
|
||||
@JSONField(name = "service_phone")
|
||||
private String servicePhone;
|
||||
/**
|
||||
* 门店位置poiid。具备线下门店
|
||||
*/
|
||||
@JSONField(name = "location_id_list")
|
||||
private List<String> locationIds;
|
||||
/**
|
||||
* 设置本卡券支持全部门店,与locationIds互斥
|
||||
*/
|
||||
@JSONField(name = "use_all_locations")
|
||||
private boolean useAllLocation;
|
||||
/**
|
||||
* 卡券顶部居中的按钮,仅在卡券状 态正常(可以核销)时显示,如:立即使用
|
||||
*/
|
||||
@JSONField(name = "center_title")
|
||||
private String centerTitle;
|
||||
/**
|
||||
* 顶部居中的url ,仅在卡券状态正常(可以核销)时显示,如:www.qq.com
|
||||
*/
|
||||
@JSONField(name = "center_url")
|
||||
private String centerUrl;
|
||||
/**
|
||||
* 显示在入口下方的提示语 ,仅在卡券状态正常(可以核销)时显示,如:立即享受优惠
|
||||
*/
|
||||
@JSONField(name = "center_sub_title")
|
||||
private String centerSubTitle;
|
||||
/**
|
||||
* 自定义跳转外链的入口名字,如:立即使用
|
||||
*/
|
||||
@JSONField(name = "custom_url_name")
|
||||
private String customTitle;
|
||||
/**
|
||||
* 自定义跳转的URL,如:www.qq.com
|
||||
*/
|
||||
@JSONField(name = "custom_url")
|
||||
private String customUrl;
|
||||
/**
|
||||
* 显示在入口右侧的提示语,如:更多惊喜
|
||||
*/
|
||||
@JSONField(name = "custom_url_sub_title")
|
||||
private String customSubTitle;
|
||||
/**
|
||||
* 营销场景的自定义入口名称,如:产品介绍
|
||||
*/
|
||||
@JSONField(name = "promotion_url_name")
|
||||
private String promotionTitle;
|
||||
/**
|
||||
* 入口跳转外链的地址链接,如:www.qq.com
|
||||
*/
|
||||
@JSONField(name = "promotion_url")
|
||||
private String promotionUrl;
|
||||
/**
|
||||
* 显示在营销入口右侧的提示语,如:卖场大优惠
|
||||
*/
|
||||
@JSONField(name = "promotion_url_sub_title")
|
||||
private String promotionSubTitle;
|
||||
/**
|
||||
* 第三方来源名,例如同程旅游、大众点评。
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 每人可领券的数量限制,不填写默认为50。
|
||||
*/
|
||||
@JSONField(name = "get_limit")
|
||||
private int limitNum;
|
||||
/**
|
||||
* 卡券领取页面是否可分享
|
||||
*/
|
||||
@JSONField(name = "can_share")
|
||||
private boolean canShare;
|
||||
/**
|
||||
* 卡券是否可转赠
|
||||
*/
|
||||
@JSONField(name = "can_give_friend")
|
||||
private boolean canGiveFriend;
|
||||
|
||||
private CouponBaseInfo(Builder builder) {
|
||||
this.logoUrl = builder.logoUrl;
|
||||
this.brandName = builder.brandName;
|
||||
this.title = builder.title;
|
||||
this.codeType = builder.codeType;
|
||||
this.cardColor = builder.cardColor;
|
||||
this.notice = builder.notice;
|
||||
this.description = builder.description;
|
||||
this.sku = builder.sku;
|
||||
this.date = builder.date;
|
||||
this.useCustomCode = builder.useCustomCode;
|
||||
this.bindOpenId = builder.bindOpenId;
|
||||
this.servicePhone = builder.servicePhone;
|
||||
this.locationIds = builder.locationIds;
|
||||
this.useAllLocation = builder.useAllLocation;
|
||||
this.centerTitle = builder.centerTitle;
|
||||
this.centerUrl = builder.centerUrl;
|
||||
this.centerSubTitle = builder.centerSubTitle;
|
||||
this.customTitle = builder.customTitle;
|
||||
this.customUrl = builder.customUrl;
|
||||
this.customSubTitle = builder.customSubTitle;
|
||||
this.promotionTitle = builder.promotionTitle;
|
||||
this.promotionUrl = builder.promotionUrl;
|
||||
this.promotionSubTitle = builder.promotionSubTitle;
|
||||
this.source = builder.source;
|
||||
this.limitNum = builder.limitNum;
|
||||
this.canShare = builder.canShare;
|
||||
this.canGiveFriend = builder.canGiveFriend;
|
||||
};
|
||||
|
||||
public String getLogoUrl() {
|
||||
return logoUrl;
|
||||
}
|
||||
|
||||
public String getBrandName() {
|
||||
return brandName;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public CardCodeType getCodeType() {
|
||||
return codeType;
|
||||
}
|
||||
|
||||
public CardColor getCardColor() {
|
||||
return cardColor;
|
||||
}
|
||||
|
||||
public String getNotice() {
|
||||
return notice;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public JSONObject getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
public JSONObject getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public boolean isUseCustomCode() {
|
||||
return useCustomCode;
|
||||
}
|
||||
|
||||
public boolean isBindOpenId() {
|
||||
return bindOpenId;
|
||||
}
|
||||
|
||||
public String getServicePhone() {
|
||||
return servicePhone;
|
||||
}
|
||||
|
||||
public List<String> getLocationIds() {
|
||||
return locationIds;
|
||||
}
|
||||
|
||||
public boolean isUseAllLocation() {
|
||||
return useAllLocation;
|
||||
}
|
||||
|
||||
public String getCenterTitle() {
|
||||
return centerTitle;
|
||||
}
|
||||
|
||||
public String getCenterUrl() {
|
||||
return centerUrl;
|
||||
}
|
||||
|
||||
public String getCenterSubTitle() {
|
||||
return centerSubTitle;
|
||||
}
|
||||
|
||||
public String getCustomTitle() {
|
||||
return customTitle;
|
||||
}
|
||||
|
||||
public String getCustomUrl() {
|
||||
return customUrl;
|
||||
}
|
||||
|
||||
public String getCustomSubTitle() {
|
||||
return customSubTitle;
|
||||
}
|
||||
|
||||
public String getPromotionTitle() {
|
||||
return promotionTitle;
|
||||
}
|
||||
|
||||
public String getPromotionUrl() {
|
||||
return promotionUrl;
|
||||
}
|
||||
|
||||
public String getPromotionSubTitle() {
|
||||
return promotionSubTitle;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public int getLimitNum() {
|
||||
return limitNum;
|
||||
}
|
||||
|
||||
public boolean isCanShare() {
|
||||
return canShare;
|
||||
}
|
||||
|
||||
public boolean isCanGiveFriend() {
|
||||
return canGiveFriend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "logoUrl=" + logoUrl + ", brandName=" + brandName + ", title="
|
||||
+ title + ", codeType=" + codeType + ", cardColor=" + cardColor
|
||||
+ ", notice=" + notice + ", description=" + description
|
||||
+ ", sku=" + sku + ", date=" + date + ", useCustomCode="
|
||||
+ useCustomCode + ", bindOpenId=" + bindOpenId
|
||||
+ ", servicePhone=" + servicePhone + ", locationIds="
|
||||
+ locationIds + ", useAllLocation=" + useAllLocation
|
||||
+ ", centerTitle=" + centerTitle + ", centerUrl=" + centerUrl
|
||||
+ ", centerSubTitle=" + centerSubTitle + ", customTitle="
|
||||
+ customTitle + ", customUrl=" + customUrl
|
||||
+ ", customSubTitle=" + customSubTitle + ", promotionTitle="
|
||||
+ promotionTitle + ", promotionUrl=" + promotionUrl
|
||||
+ ", promotionSubTitle=" + promotionSubTitle + ", source="
|
||||
+ source + ", limitNum=" + limitNum + ", canShare=" + canShare
|
||||
+ ", canGiveFriend=" + canGiveFriend;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券基础信息构造器
|
||||
*
|
||||
* @className Builder
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public static final class Builder {
|
||||
/**
|
||||
* 卡券的商户logo,建议像素为300*300
|
||||
*/
|
||||
private String logoUrl;
|
||||
/**
|
||||
* 商户名字,字数上限为12个汉字,如:海底捞
|
||||
*/
|
||||
private String brandName;
|
||||
/**
|
||||
* 卡券名,字数上限为9个汉字。(建议涵盖卡券属性、服务及金额),如:双人套餐100元兑换券
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 码型
|
||||
*/
|
||||
private CardCodeType codeType;
|
||||
/**
|
||||
* 卡券颜色
|
||||
*/
|
||||
private CardColor cardColor;
|
||||
/**
|
||||
* 卡券使用提醒,字数上限为16个汉字,如:请出示二维码
|
||||
*/
|
||||
private String notice;
|
||||
/**
|
||||
* 卡券使用说明,字数上限为1024个汉字,如:不可与其他优惠同享
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 卡券库存的数量,上限为100000000。
|
||||
*/
|
||||
private JSONObject sku;
|
||||
/**
|
||||
* 使用日期,有效期的信息。
|
||||
*/
|
||||
private JSONObject date;
|
||||
|
||||
// 以下为选填字段
|
||||
/**
|
||||
* 是否自定义Code码
|
||||
*/
|
||||
private boolean useCustomCode;
|
||||
/**
|
||||
* 指定特殊用户群体
|
||||
*/
|
||||
private boolean bindOpenId;
|
||||
/**
|
||||
* 客服电话
|
||||
*/
|
||||
private String servicePhone;
|
||||
/**
|
||||
* 门店位置poiid。具备线下门店
|
||||
*/
|
||||
private List<String> locationIds;
|
||||
/**
|
||||
* 设置本卡券支持全部门店,与locationIds互斥
|
||||
*/
|
||||
private boolean useAllLocation;
|
||||
/**
|
||||
* 卡券顶部居中的按钮,仅在卡券状 态正常(可以核销)时显示,如:立即使用
|
||||
*/
|
||||
private String centerTitle;
|
||||
/**
|
||||
* 顶部居中的url ,仅在卡券状态正常(可以核销)时显示,如:www.qq.com
|
||||
*/
|
||||
private String centerUrl;
|
||||
/**
|
||||
* 显示在入口下方的提示语 ,仅在卡券状态正常(可以核销)时显示,如:立即享受优惠
|
||||
*/
|
||||
private String centerSubTitle;
|
||||
/**
|
||||
* 自定义跳转外链的入口名字,如:立即使用
|
||||
*/
|
||||
private String customTitle;
|
||||
/**
|
||||
* 自定义跳转的URL,如:www.qq.com
|
||||
*/
|
||||
private String customUrl;
|
||||
/**
|
||||
* 显示在入口右侧的提示语,如:更多惊喜
|
||||
*/
|
||||
private String customSubTitle;
|
||||
/**
|
||||
* 营销场景的自定义入口名称,如:产品介绍
|
||||
*/
|
||||
private String promotionTitle;
|
||||
/**
|
||||
* 入口跳转外链的地址链接,如:www.qq.com
|
||||
*/
|
||||
private String promotionUrl;
|
||||
/**
|
||||
* 显示在营销入口右侧的提示语,如:卖场大优惠
|
||||
*/
|
||||
private String promotionSubTitle;
|
||||
/**
|
||||
* 第三方来源名,例如同程旅游、大众点评。
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 每人可领券的数量限制,不填写默认为50。
|
||||
*/
|
||||
private int limitNum;
|
||||
/**
|
||||
* 卡券领取页面是否可分享,不填写默认true
|
||||
*/
|
||||
private boolean canShare;
|
||||
/**
|
||||
* 卡券是否可转赠,不填写默认true
|
||||
*/
|
||||
private boolean canGiveFriend;
|
||||
|
||||
public Builder() {
|
||||
this.sku = new JSONObject();
|
||||
this.date = new JSONObject();
|
||||
this.useAllLocation = true;
|
||||
this.canShare = true;
|
||||
this.canGiveFriend = true;
|
||||
this.limitNum = 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商户logo
|
||||
*
|
||||
* @param logoUrl
|
||||
* 卡券的商户logo,建议像素为300*300。
|
||||
* @return
|
||||
*/
|
||||
public Builder logoUrl(String logoUrl) {
|
||||
this.logoUrl = logoUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商户名字
|
||||
*
|
||||
* @param brandName
|
||||
* 商户名字,字数上限为12个汉字
|
||||
* @return
|
||||
*/
|
||||
public Builder brandName(String brandName) {
|
||||
this.brandName = brandName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券名
|
||||
*
|
||||
* @param title
|
||||
* 卡券名,字数上限为9个汉字。(建议涵盖卡券属性、服务及金额)。
|
||||
* @return
|
||||
*/
|
||||
public Builder title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置码型
|
||||
*
|
||||
* @param codeType
|
||||
* 码型
|
||||
* @return
|
||||
*/
|
||||
public Builder codeType(CardCodeType codeType) {
|
||||
this.codeType = codeType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券颜色
|
||||
*
|
||||
* @param cardColor
|
||||
* 卡券颜色
|
||||
* @return
|
||||
*/
|
||||
public Builder cardColor(CardColor cardColor) {
|
||||
this.cardColor = cardColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券使用提醒
|
||||
*
|
||||
* @param notice
|
||||
* 卡券使用提醒,字数上限为16个汉字。
|
||||
* @return
|
||||
*/
|
||||
public Builder notice(String notice) {
|
||||
this.notice = notice;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券使用说明
|
||||
*
|
||||
* @param description
|
||||
* 卡券使用说明,字数上限为1024个汉字。
|
||||
* @return
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券库存的数量
|
||||
*
|
||||
* @param quantity
|
||||
* 卡券库存的数量,上限为100000000。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Builder quantity(int quantity) {
|
||||
this.sku.put("quantity", quantity);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券在某个时间范围有效
|
||||
*
|
||||
* @param beginTime
|
||||
* 表示起用时间
|
||||
* @param endTime
|
||||
* 表示结束时间,建议设置为截止日期的23:59:59过期
|
||||
* @return
|
||||
*/
|
||||
public Builder activeAt(Date beginTime, Date endTime) {
|
||||
this.date.clear();
|
||||
this.date.put("type", CardActiveType.DATE_TYPE_FIX_TIME_RANGE);
|
||||
this.date.put("begin_timestamp", beginTime.getTime() / 1000l);
|
||||
this.date.put("end_timestamp", endTime.getTime() / 1000l);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券在领取多少天后有效
|
||||
*
|
||||
* @param days
|
||||
* 表示自领取后多少天内有效,不支持填写0。
|
||||
* @param beginDays
|
||||
* 表示自领取后多少天开始生效,领取后当天生效填写0。(单位为天)
|
||||
* @param endTime
|
||||
* 表示卡券统一过期时间,建议设置为截止日期的23:59:59过期。(东八区时间,单位为秒),设置了days卡券,
|
||||
* 当时间达到end_timestamp时卡券统一过期
|
||||
* @return
|
||||
*/
|
||||
public Builder activeAt(int days, int beginDays, Date endTime) {
|
||||
this.date.clear();
|
||||
this.date.put("type", CardActiveType.DATE_TYPE_FIX_TERM);
|
||||
this.date.put("fixed_term", days);
|
||||
this.date.put("fixed_begin_term", beginDays);
|
||||
this.date.put("end_timestamp", endTime.getTime() / 1000l);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否自定义Code码
|
||||
*
|
||||
* @param useCustomCode
|
||||
* 填写true或false,默认为false。
|
||||
* @return
|
||||
*/
|
||||
public Builder useCustomCode(boolean useCustomCode) {
|
||||
this.useCustomCode = useCustomCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否指定用户领取,填写true或false
|
||||
*
|
||||
* @param bindOpenId
|
||||
* 默认为false。通常指定特殊用户群体 投放卡券或防止刷券时选择指定用户领取。
|
||||
* @return
|
||||
*/
|
||||
public Builder bindOpenId(boolean bindOpenId) {
|
||||
this.bindOpenId = bindOpenId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置客服电话
|
||||
*
|
||||
* @param servicePhone
|
||||
* 客服电话
|
||||
* @return
|
||||
*/
|
||||
public Builder servicePhone(String servicePhone) {
|
||||
this.servicePhone = servicePhone;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置门店位置poiid。具备线下门店 的商户为必填
|
||||
*
|
||||
* @param locationIds
|
||||
* 门店列表
|
||||
* @return
|
||||
*/
|
||||
public Builder locationIds(String... locationIds) {
|
||||
this.locationIds.addAll(Arrays.asList(locationIds));
|
||||
this.useAllLocation = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券顶部居中的按钮,仅在卡券状态正常(可以核销)时显示
|
||||
*
|
||||
* @param centerTitle
|
||||
* 按钮文字
|
||||
* @return
|
||||
*/
|
||||
public Builder centerTitle(String centerTitle) {
|
||||
this.centerTitle = centerTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部居中的url ,仅在卡券状态正常(可以核销)时显示
|
||||
*
|
||||
* @param centerUrl
|
||||
* 按钮链接
|
||||
* @return
|
||||
*/
|
||||
public Builder centerUrl(String centerUrl) {
|
||||
this.centerUrl = centerUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示在入口下方的提示语 ,仅在卡券状态正常(可以核销)时显示。
|
||||
*
|
||||
* @param centerSubTitle
|
||||
* 入口下方的提示语
|
||||
* @return
|
||||
*/
|
||||
public Builder centerSubTitle(String centerSubTitle) {
|
||||
this.centerSubTitle = centerSubTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自定义跳转外链的入口名字
|
||||
*
|
||||
* @param customTitle
|
||||
* 自定义外链入口文字
|
||||
* @return
|
||||
*/
|
||||
public Builder customTitle(String customTitle) {
|
||||
this.customTitle = customTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自定义跳转的URL
|
||||
*
|
||||
* @param customUrl
|
||||
* 跳转链接
|
||||
* @return
|
||||
*/
|
||||
public Builder customUrl(String customUrl) {
|
||||
this.customUrl = customUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示在入口右侧的提示语
|
||||
*
|
||||
* @param customSubTitle
|
||||
* 入口右侧的提示语
|
||||
* @return
|
||||
*/
|
||||
public Builder customSubTitle(String customSubTitle) {
|
||||
this.customSubTitle = customSubTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置营销场景的自定义入口名称
|
||||
*
|
||||
* @param promotionTitle
|
||||
* 自定义入口文字
|
||||
* @return
|
||||
*/
|
||||
public Builder promotionTitle(String promotionTitle) {
|
||||
this.promotionTitle = promotionTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置入口跳转外链的地址链接。
|
||||
*
|
||||
* @param promotionUrl
|
||||
* 入口跳转链接
|
||||
* @return
|
||||
*/
|
||||
public Builder promotionUrl(String promotionUrl) {
|
||||
this.promotionUrl = promotionUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示在营销入口右侧的提示语
|
||||
*
|
||||
* @param promotionSubTitle
|
||||
* 入口右侧的提示语
|
||||
* @return
|
||||
*/
|
||||
public Builder promotionSubTitle(String promotionSubTitle) {
|
||||
this.promotionSubTitle = promotionSubTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置第三方来源名,例如同程旅游、大众点评。
|
||||
*
|
||||
* @param source
|
||||
* 来源
|
||||
* @return
|
||||
*/
|
||||
public Builder source(String source) {
|
||||
this.source = source;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置每人可领券的数量限制,不填写默认为50。
|
||||
*
|
||||
* @param limitNum
|
||||
* 限制数量
|
||||
* @return
|
||||
*/
|
||||
public Builder limitNum(int limitNum) {
|
||||
this.limitNum = limitNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券领取页面是否可分享。
|
||||
*
|
||||
* @param canShare
|
||||
* 是否可以分享
|
||||
* @return
|
||||
*/
|
||||
public Builder canShare(boolean canShare) {
|
||||
this.canShare = canShare;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券是否可转赠
|
||||
*
|
||||
* @param canGiveFriend
|
||||
* 是否可以转赠
|
||||
* @return
|
||||
*/
|
||||
public Builder canGiveFriend(boolean canGiveFriend) {
|
||||
this.canGiveFriend = canGiveFriend;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回卡券的基础信息
|
||||
*
|
||||
* @return 卡券基础信息
|
||||
*/
|
||||
public CouponBaseInfo build() {
|
||||
return new CouponBaseInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券使用时间类型
|
||||
*
|
||||
* @className CardActiveType
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月5日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public enum CardActiveType {
|
||||
/**
|
||||
* 表示固定日期区间
|
||||
*/
|
||||
DATE_TYPE_FIX_TIME_RANGE,
|
||||
/**
|
||||
* 表示固定时长 (自领取后按天算。
|
||||
*/
|
||||
DATE_TYPE_FIX_TERM;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardType;
|
||||
|
||||
/**
|
||||
* 折扣券
|
||||
*
|
||||
* @className DiscountCoupon
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public class DiscountCoupon extends CardCoupon {
|
||||
/**
|
||||
* 打折额度百分比
|
||||
*/
|
||||
private final int discount;
|
||||
|
||||
/**
|
||||
* 构造折扣券
|
||||
*
|
||||
* @param couponBaseInfo
|
||||
* 基础信息
|
||||
* @param discount
|
||||
* 打折额度百分百,如:传入30就是七折。
|
||||
*/
|
||||
public DiscountCoupon(CouponBaseInfo couponBaseInfo, int discount) {
|
||||
super(couponBaseInfo);
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public int getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return CardType.DISCOUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DiscountCoupon [discount=" + discount + ", " + super.toString()
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardType;
|
||||
|
||||
/**
|
||||
* 普通优惠券
|
||||
*
|
||||
* @className GeneralCoupon
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public class GeneralCoupon extends CardCoupon {
|
||||
/**
|
||||
* 优惠详情
|
||||
*/
|
||||
@JSONField(name = "default_detail")
|
||||
private final String explain;
|
||||
|
||||
/**
|
||||
* 构造普通优惠券
|
||||
*
|
||||
* @param couponBaseInfo
|
||||
* 基础信息
|
||||
* @param explain
|
||||
* 优惠详情 如:音乐木盒
|
||||
*/
|
||||
public GeneralCoupon(CouponBaseInfo couponBaseInfo, String explain) {
|
||||
super(couponBaseInfo);
|
||||
this.explain = explain;
|
||||
}
|
||||
|
||||
public String getExplain() {
|
||||
return explain;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return CardType.GENERAL_COUPON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GrouponCoupon [explain=" + explain + ", " + super.toString()
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardType;
|
||||
|
||||
/**
|
||||
* 兑换券
|
||||
*
|
||||
* @className GifCoupon
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public class GiftCoupon extends CardCoupon {
|
||||
/**
|
||||
* 兑换说明
|
||||
*/
|
||||
@JSONField(name = "gift")
|
||||
private final String explain;
|
||||
|
||||
/**
|
||||
* 构造兑换券
|
||||
*
|
||||
* @param couponBaseInfo
|
||||
* 基础信息
|
||||
* @param explain
|
||||
* 兑换说明 如:可兑换音乐木盒一个。
|
||||
*/
|
||||
public GiftCoupon(CouponBaseInfo couponBaseInfo, String explain) {
|
||||
super(couponBaseInfo);
|
||||
this.explain = explain;
|
||||
}
|
||||
|
||||
public String getExplain() {
|
||||
return explain;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return CardType.GIFT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GiftCoupon [explain=" + explain + ", " + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.foxinmy.weixin4j.card;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.card.CardType;
|
||||
|
||||
/**
|
||||
* 团购券
|
||||
*
|
||||
* @className GrouponCoupon
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public class GrouponCoupon extends CardCoupon {
|
||||
/**
|
||||
* 团购详情
|
||||
*/
|
||||
@JSONField(name = "deal_detail")
|
||||
private final String explain;
|
||||
|
||||
/**
|
||||
* 构造团购券
|
||||
*
|
||||
* @param couponBaseInfo
|
||||
* 基础信息
|
||||
* @param explain
|
||||
* 团购详情 如:双人套餐\n -进口红酒一支。\n孜然牛肉一份。
|
||||
*/
|
||||
public GrouponCoupon(CouponBaseInfo couponBaseInfo, String explain) {
|
||||
super(couponBaseInfo);
|
||||
this.explain = explain;
|
||||
}
|
||||
|
||||
public String getExplain() {
|
||||
return explain;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public CardType getCardType() {
|
||||
return CardType.GROUPON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GrouponCoupon [explain=" + explain + ", " + super.toString()
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* reference of apache pivot
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.foxinmy.weixin4j.http;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.NameValue;
|
||||
import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import com.foxinmy.weixin4j.http.ContentType;
|
||||
import com.foxinmy.weixin4j.http.URLParameter;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
||||
|
||||
public class FormUrlEntity extends StringEntity {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
|
||||
import com.foxinmy.weixin4j.http.HttpResponse;
|
||||
import com.foxinmy.weixin4j.http.MimeType;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
public abstract class AbstractMessageConverter implements MessageConverter {
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import com.foxinmy.weixin4j.http.HttpRequest;
|
||||
import com.foxinmy.weixin4j.http.HttpResponse;
|
||||
import com.foxinmy.weixin4j.http.apache.MultipartEntity;
|
||||
import com.foxinmy.weixin4j.http.entity.HttpEntity;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.apache.commons.httpclient.protocol.Protocol;
|
||||
import com.foxinmy.weixin4j.http.HttpParams;
|
||||
import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
|
||||
import com.foxinmy.weixin4j.http.support.apache3.HttpComponent3.SSLProtocolSocketFactory;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* 使用commons-httpclient3.x
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import com.foxinmy.weixin4j.http.HttpHeaders;
|
||||
import com.foxinmy.weixin4j.http.HttpParams;
|
||||
import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
|
||||
import com.foxinmy.weixin4j.http.support.apache4.HttpComponent4.CustomHostnameVerifier;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* 使用Apache的HttpClient<=4.2
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import com.foxinmy.weixin4j.http.HttpClient;
|
||||
import com.foxinmy.weixin4j.http.HttpParams;
|
||||
import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
|
||||
import com.foxinmy.weixin4j.http.support.apache4.HttpComponent4.CustomHostnameVerifier;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* 使用Apache的HttpClient>=4.3
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import com.foxinmy.weixin4j.http.HttpRequest;
|
||||
import com.foxinmy.weixin4j.http.HttpResponse;
|
||||
import com.foxinmy.weixin4j.http.entity.HttpEntity;
|
||||
import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.SettableFuture;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
|
||||
import com.foxinmy.weixin4j.http.message.XmlMessageConverter;
|
||||
import com.foxinmy.weixin4j.logging.InternalLogger;
|
||||
import com.foxinmy.weixin4j.logging.InternalLoggerFactory;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* 负责微信请求的执行
|
||||
|
||||
@@ -695,6 +695,10 @@
|
||||
<code>45033</code>
|
||||
<text>用户领取次数超过限制get_limit</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45046</code>
|
||||
<text>该card_id已经设置了买单功能,不可变更为自助核销功能,设置冲突</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45047</code>
|
||||
<text>客服接口下行条数超过上限</text>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.media;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.media;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.media;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
+3
-1
@@ -1,9 +1,11 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.media;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.model.paging.Pageable;
|
||||
import com.foxinmy.weixin4j.model.paging.Pagedata;
|
||||
import com.foxinmy.weixin4j.type.MediaType;
|
||||
|
||||
/**
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.media;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Sort.Direction;
|
||||
import com.foxinmy.weixin4j.model.paging.Sort.Direction;
|
||||
|
||||
/**
|
||||
* 分页数据(页码从1开始
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.model.paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -18,7 +18,6 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年12月18日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@@ -45,7 +44,7 @@ public class PayPackage extends MerchantResult {
|
||||
*/
|
||||
@XmlElement(name = "total_fee")
|
||||
@JSONField(name = "total_fee")
|
||||
private String totalFee;
|
||||
private int totalFee;
|
||||
/**
|
||||
* 通知地址接收微信支付成功通知 必须
|
||||
*/
|
||||
@@ -117,7 +116,7 @@ public class PayPackage extends MerchantResult {
|
||||
this.body = body;
|
||||
this.detail = detail;
|
||||
this.outTradeNo = outTradeNo;
|
||||
this.totalFee = DateUtil.formatFee2Fen(totalFee);
|
||||
this.totalFee = DateUtil.formatYuan2Fen(totalFee);
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.createIp = createIp;
|
||||
this.attach = attach;
|
||||
@@ -152,9 +151,19 @@ public class PayPackage extends MerchantResult {
|
||||
this.outTradeNo = outTradeNo;
|
||||
}
|
||||
|
||||
public String getTotalFee() {
|
||||
public int getTotalFee() {
|
||||
return totalFee;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
|
||||
*
|
||||
* @return 元单位
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
public double getFormatTotalFee() {
|
||||
return totalFee / 100d;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">单位为元,自动格式化为分</font>
|
||||
@@ -163,7 +172,7 @@ public class PayPackage extends MerchantResult {
|
||||
* 订单总额 单位为元
|
||||
*/
|
||||
public void setTotalFee(double totalFee) {
|
||||
this.totalFee = DateUtil.formatFee2Fen(totalFee);
|
||||
this.totalFee = DateUtil.formatYuan2Fen(totalFee);
|
||||
}
|
||||
|
||||
public String getNotifyUrl() {
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.foxinmy.weixin4j.api.CustomsApi;
|
||||
import com.foxinmy.weixin4j.api.PayApi;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.model.Pageable;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.model.paging.Pageable;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponDetail;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
|
||||
@@ -39,10 +39,10 @@ import com.foxinmy.weixin4j.payment.mch.RefundResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.SettlementRecord;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.sign.WeixinSignature;
|
||||
import com.foxinmy.weixin4j.type.BillType;
|
||||
import com.foxinmy.weixin4j.type.CurrencyType;
|
||||
import com.foxinmy.weixin4j.type.CustomsCity;
|
||||
import com.foxinmy.weixin4j.type.IdQuery;
|
||||
import com.foxinmy.weixin4j.type.mch.BillType;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,9 +9,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
|
||||
import com.foxinmy.weixin4j.type.CouponStatus;
|
||||
import com.foxinmy.weixin4j.type.CouponStockType;
|
||||
import com.foxinmy.weixin4j.type.CouponType;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponStatus;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponStockType;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
|
||||
import com.foxinmy.weixin4j.type.CouponStockStatus;
|
||||
import com.foxinmy.weixin4j.type.CouponType;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponStockStatus;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.CouponType;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponType;
|
||||
|
||||
/**
|
||||
* 订单代金券信息
|
||||
@@ -34,7 +34,7 @@ public class OrderCouponInfo implements Serializable {
|
||||
/**
|
||||
* 代金券类型
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.type.CouponType
|
||||
* @see com.foxinmy.weixin4j.type.mch.CouponType
|
||||
*/
|
||||
@XmlElement(name = "coupon_type")
|
||||
@JSONField(name = "coupon_type")
|
||||
|
||||
@@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType;
|
||||
import com.foxinmy.weixin4j.type.mch.CorpPaymentCheckNameType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public class CorpPayment extends MerchantResult {
|
||||
/**
|
||||
* 校验用户姓名选项
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.CorpPaymentCheckNameType.type.MPPaymentCheckNameType
|
||||
* @see com.foxinmy.weixin4j.type.mch.CorpPaymentCheckNameType.type.MPPaymentCheckNameType
|
||||
*/
|
||||
@XmlElement(name = "check_name")
|
||||
@JSONField(name = "check_name")
|
||||
@@ -54,9 +54,9 @@ public class CorpPayment extends MerchantResult {
|
||||
*/
|
||||
private String desc;
|
||||
/**
|
||||
* 付款金额
|
||||
* 付款金额 单位分
|
||||
*/
|
||||
private String amount;
|
||||
private int amount;
|
||||
/**
|
||||
* 调用接口的机器Ip地址
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ public class CorpPayment extends MerchantResult {
|
||||
* @param desc
|
||||
* 描述
|
||||
* @param amount
|
||||
* 金额
|
||||
* 金额 单位元
|
||||
* @param clientIp
|
||||
* 调用接口IP
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ public class CorpPayment extends MerchantResult {
|
||||
this.openId = openId;
|
||||
this.checkNameType = checkNameType;
|
||||
this.desc = desc;
|
||||
this.amount = DateUtil.formatFee2Fen(amount);
|
||||
this.amount = DateUtil.formatYuan2Fen(amount);
|
||||
this.clientIp = clientIp;
|
||||
}
|
||||
|
||||
@@ -115,9 +115,19 @@ public class CorpPayment extends MerchantResult {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
|
||||
*
|
||||
* @return 元单位
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
public double getFormatAmount() {
|
||||
return amount / 100d;
|
||||
}
|
||||
|
||||
public String getClientIp() {
|
||||
return clientIp;
|
||||
|
||||
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType;
|
||||
import com.foxinmy.weixin4j.type.mch.CorpPaymentCheckNameType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public class CorpPaymentRecord extends MerchantResult {
|
||||
/**
|
||||
* 校验用户姓名选项
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.CorpPaymentCheckNameType.type.MPPaymentCheckNameType
|
||||
* @see com.foxinmy.weixin4j.type.mch.CorpPaymentCheckNameType.type.MPPaymentCheckNameType
|
||||
*/
|
||||
@XmlElement(name = "check_name")
|
||||
@JSONField(name = "check_name")
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.foxinmy.weixin4j.payment.mch;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
* 企业付款结果
|
||||
@@ -57,6 +60,12 @@ public class CorpPaymentResult extends MerchantResult {
|
||||
return paymentTime;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
public Date getFormatPaymentTime() {
|
||||
return paymentTime != null ? DateUtil.parseDate(paymentTime,
|
||||
"yyyy-MM-dd HH:mm:ss") : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CorpPaymentResult [transactionId=" + transactionId
|
||||
|
||||
@@ -7,9 +7,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.exception.WeixinPayException;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.sign.WeixinPaymentSignature;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.RandomUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Redpacket extends MerchantResult {
|
||||
*/
|
||||
@XmlElement(name = "total_amount")
|
||||
@JSONField(name = "total_amount")
|
||||
private String totalAmount;
|
||||
private int totalAmount;
|
||||
/**
|
||||
* 红包发放总人数
|
||||
*/
|
||||
@@ -134,7 +134,7 @@ public class Redpacket extends MerchantResult {
|
||||
this.clientIp = clientIp;
|
||||
this.actName = actName;
|
||||
this.remark = remark;
|
||||
this.totalAmount = DateUtil.formatFee2Fen(totalAmount);
|
||||
this.totalAmount = DateUtil.formatYuan2Fen(totalAmount);
|
||||
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
||||
}
|
||||
|
||||
@@ -150,9 +150,19 @@ public class Redpacket extends MerchantResult {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public String getTotalAmount() {
|
||||
public int getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
|
||||
*
|
||||
* @return 元单位
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
public double getFormatTotalAmount() {
|
||||
return totalAmount / 100d;
|
||||
}
|
||||
|
||||
public int getTotalNum() {
|
||||
return totalNum;
|
||||
|
||||
@@ -12,9 +12,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.type.RedpacketSendType;
|
||||
import com.foxinmy.weixin4j.type.RedpacketStatus;
|
||||
import com.foxinmy.weixin4j.type.RedpacketType;
|
||||
import com.foxinmy.weixin4j.type.mch.RedpacketSendType;
|
||||
import com.foxinmy.weixin4j.type.mch.RedpacketStatus;
|
||||
import com.foxinmy.weixin4j.type.mch.RedpacketType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,9 +10,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.payment.coupon.RefundCouponInfo;
|
||||
import com.foxinmy.weixin4j.type.CouponType;
|
||||
import com.foxinmy.weixin4j.type.RefundChannel;
|
||||
import com.foxinmy.weixin4j.type.RefundStatus;
|
||||
import com.foxinmy.weixin4j.type.mch.CouponType;
|
||||
import com.foxinmy.weixin4j.type.mch.RefundChannel;
|
||||
import com.foxinmy.weixin4j.type.mch.RefundStatus;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResult;
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public class RefundDetail implements Serializable {
|
||||
/**
|
||||
* 代金券类型
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.type.CouponType
|
||||
* @see com.foxinmy.weixin4j.type.mch.CouponType
|
||||
*/
|
||||
@XmlElement(name = "coupon_type")
|
||||
@JSONField(name = "coupon_type")
|
||||
|
||||
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.RefundChannel;
|
||||
import com.foxinmy.weixin4j.type.mch.RefundChannel;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResult;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.foxinmy.weixin4j.payment.mch;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.payment.PayRequest;
|
||||
import com.foxinmy.weixin4j.type.TradeType;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.DigestUtil;
|
||||
import com.foxinmy.weixin4j.util.MapUtil;
|
||||
import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MpArticle implements Serializable {
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 图文页的URL 获取图文消息时
|
||||
* 图文页的URL 获取图文消息时,群发消息时填写无效。
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MpNews implements MassTuple, NotifyTuple {
|
||||
/**
|
||||
* 允许最多的图文列表数
|
||||
*/
|
||||
private static final int MAX_ARTICLE_COUNT = 10;
|
||||
private static final int MAX_ARTICLE_COUNT = 8;
|
||||
|
||||
@Override
|
||||
public String getMessageType() {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class News implements NotifyTuple {
|
||||
/**
|
||||
* 允许最多的图文列表数
|
||||
*/
|
||||
private static final int MAX_ARTICLE_COUNT = 10;
|
||||
private static final int MAX_ARTICLE_COUNT = 8;
|
||||
|
||||
/**
|
||||
* 图文列表
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.type;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
|
||||
/**
|
||||
* 星期
|
||||
*
|
||||
* @className Week
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月5日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public enum Week {
|
||||
MONDAY("周一"), TUESDAY("周二"), WEDNESDAY("周三"), THURSDAY("周四"), FRIDAY("周五"), SATURDAY(
|
||||
"周六"), SUNDAY("周日");
|
||||
private String desc;
|
||||
|
||||
Week(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.foxinmy.weixin4j.type.card;
|
||||
|
||||
/**
|
||||
* 卡券码型
|
||||
*
|
||||
* @className CardCodeType
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年8月4日
|
||||
* @since JDK 1.7
|
||||
*/
|
||||
public enum CardCodeType {
|
||||
/**
|
||||
* 文本
|
||||
*/
|
||||
CODE_TYPE_TEXT,
|
||||
/**
|
||||
* 一维码
|
||||
*/
|
||||
CODE_TYPE_BARCODE,
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
CODE_TYPE_QRCODE,
|
||||
/**
|
||||
* 二维码无code显示
|
||||
*/
|
||||
CODE_TYPE_ONLY_QRCODE,
|
||||
/**
|
||||
* 一维码无code显示
|
||||
*/
|
||||
CODE_TYPE_ONLY_BARCODE,
|
||||
/**
|
||||
* 不显示code和条形码类型
|
||||
*/
|
||||
CODE_TYPE_NONE;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.foxinmy.weixin4j.type.card;
|
||||
|
||||
/**
|
||||
* 卡券颜色
|
||||
*
|
||||
* @className CardColor
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年4月4日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public enum CardColor {
|
||||
/**
|
||||
* <font Color="#63b359">Color010</font>
|
||||
*/
|
||||
Color010(99, 179, 89, "#63b359"),
|
||||
/**
|
||||
* <font Color="#2c9f67">Color020</font>
|
||||
*/
|
||||
Color020(44, 159, 103, "#2c9f67"),
|
||||
/**
|
||||
* <font Color="#509fc9">Color030</font>
|
||||
*/
|
||||
Color030(80, 159, 201, "#509fc9"),
|
||||
/**
|
||||
* <font Color="#5885cf">Color040</font>
|
||||
*/
|
||||
Color040(88, 133, 207, "#5885cf"),
|
||||
/**
|
||||
* <font Color="#9062c0">Color050</font>
|
||||
*/
|
||||
Color050(144, 98, 192, "#9062c0"),
|
||||
/**
|
||||
* <font Color="#d09a45">Color060</font>
|
||||
*/
|
||||
Color060(208, 154, 69, "#d09a45"),
|
||||
/**
|
||||
* <font Color="#e4b138">Color070</font>
|
||||
*/
|
||||
Color070(228, 117, 56, "#e4b138"),
|
||||
/**
|
||||
* <font Color="#ee903c">Color080</font>
|
||||
*/
|
||||
Color080(238, 144, 60, "#ee903c"),
|
||||
/**
|
||||
* <font Color="#f08500">Color081</font>
|
||||
*/
|
||||
Color081(240, 133, 0, "#f08500"),
|
||||
/**
|
||||
* <font Color="#a9d92d">Color082</font>
|
||||
*/
|
||||
Color082(169, 217, 45, "#a9d92d"),
|
||||
/**
|
||||
* <font Color="#dd6549">Color090</font>
|
||||
*/
|
||||
Color090(221, 101, 73, "#dd6549"),
|
||||
/**
|
||||
* <font Color="#cc463d">Color0100</font>
|
||||
*/
|
||||
Color0100(204, 70, 61, "#cc463d"),
|
||||
/**
|
||||
* <font Color="#cf3e36">Color0101</font>
|
||||
*/
|
||||
Color0101(207, 62, 54, "#cf3e36"),
|
||||
/**
|
||||
* <font Color="#5E6671">Color0102</font>
|
||||
*/
|
||||
Color0102(94, 102, 113, "#5E6671");
|
||||
private int r;
|
||||
private int g;
|
||||
private int b;
|
||||
private String hex;
|
||||
|
||||
CardColor(int r, int g, int b, String hex) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.hex = hex;
|
||||
}
|
||||
|
||||
public int getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public int getG() {
|
||||
return g;
|
||||
}
|
||||
|
||||
public int getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public String getHex() {
|
||||
return hex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.foxinmy.weixin4j.type.card;
|
||||
|
||||
/**
|
||||
* 卡券类型
|
||||
*
|
||||
* @className CardType
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年4月4日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public enum CardType {
|
||||
/**
|
||||
* 团购券
|
||||
*/
|
||||
GROUPON,
|
||||
/**
|
||||
* 代金券
|
||||
*/
|
||||
CASH,
|
||||
/**
|
||||
* 折扣券
|
||||
*/
|
||||
DISCOUNT,
|
||||
/**
|
||||
* 兑换券
|
||||
*/
|
||||
GIFT,
|
||||
/**
|
||||
* 优惠券
|
||||
*/
|
||||
GENERAL_COUPON;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 对账单类型
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 企业付款检查收款人姓名的策略
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 代金券状态
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 代金券批次状态
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 代金券批次类型
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 代金券类型
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 红包发放类型
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 红包状态
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 红包类型
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 退款渠道
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 退款类型
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.model;
|
||||
package com.foxinmy.weixin4j.util;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.foxinmy.weixin4j.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* 日期工具类
|
||||
@@ -15,7 +15,7 @@ import java.util.Date;
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class DateUtil {
|
||||
public final class DateUtil {
|
||||
private static final String yyyyMMdd = "yyyyMMdd";
|
||||
private static final String yyyy_MM_dd = "yyyy-MM-dd";
|
||||
private static final String yyyyMMddHHmmss = "yyyyMMddHHmmss";
|
||||
@@ -28,7 +28,7 @@ public class DateUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String fortmat2yyyyMMdd(Date date) {
|
||||
return new SimpleDateFormat(yyyyMMdd).format(date);
|
||||
return formatDate(date, yyyyMMdd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ public class DateUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String fortmat2yyyy_MM_dd(Date date) {
|
||||
return new SimpleDateFormat(yyyy_MM_dd).format(date);
|
||||
return formatDate(date, yyyy_MM_dd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,22 @@ public class DateUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String fortmat2yyyyMMddHHmmss(Date date) {
|
||||
return new SimpleDateFormat(yyyyMMddHHmmss).format(date);
|
||||
return formatDate(date, yyyyMMddHHmmss);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
*
|
||||
* @param date
|
||||
* 日期对象
|
||||
* @param pattern
|
||||
* 格式表达式
|
||||
* @return 日期字符串
|
||||
*/
|
||||
public static String formatDate(Date date, String pattern) {
|
||||
SimpleDateFormat df = new SimpleDateFormat(pattern);
|
||||
df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
return df.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,26 +76,26 @@ public class DateUtil {
|
||||
* @return
|
||||
*/
|
||||
public static Date parse2yyyyMMddHHmmss(String date) {
|
||||
try {
|
||||
return new SimpleDateFormat(yyyyMMddHHmmss).parse(date);
|
||||
} catch (ParseException e) {
|
||||
;
|
||||
}
|
||||
return null;
|
||||
return parseDate(date, yyyyMMddHHmmss);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位为分的金额格式化为元的字符串形式
|
||||
* 转换日期
|
||||
*
|
||||
* @param fee
|
||||
* 金额 单位为分
|
||||
* @return 四舍五入后的字符串形式金额
|
||||
* @param date
|
||||
* 日期字符串
|
||||
* @param pattern
|
||||
* 格式表达式
|
||||
* @return 日期对象
|
||||
*/
|
||||
public static String formatFee2Fen(double fee) {
|
||||
BigDecimal _fee = new BigDecimal(Double.toString(fee));
|
||||
fee = _fee.multiply(new BigDecimal("100"))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
|
||||
return new DecimalFormat("#").format(fee);
|
||||
public static Date parseDate(String date, String pattern) {
|
||||
SimpleDateFormat df = new SimpleDateFormat(pattern);
|
||||
df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
try {
|
||||
return df.parse(date);
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,4 +106,17 @@ public class DateUtil {
|
||||
public static String timestamp2string() {
|
||||
return String.valueOf(System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位为元的金额格式化为分
|
||||
*
|
||||
* @param fee
|
||||
* 金额 单位为元
|
||||
* @return 四舍六入五成双的整型金额
|
||||
*/
|
||||
public static int formatYuan2Fen(double fee) {
|
||||
BigDecimal _fee = new BigDecimal(Double.toString(fee));
|
||||
return _fee.multiply(new BigDecimal("100"))
|
||||
.setScale(0, BigDecimal.ROUND_HALF_EVEN).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.foxinmy.weixin4j.util;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
|
||||
/**
|
||||
* 签名工具类
|
||||
*
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResultSerializer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
|
||||
public final class StringUtil {
|
||||
|
||||
public static final String EMPTY = "";
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.ReflectionUtil;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.NameFilter;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.xml.transform.Source;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,14 +7,14 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.payment.mch.CorpPayment;
|
||||
import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.Redpacket;
|
||||
import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
|
||||
import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType;
|
||||
import com.foxinmy.weixin4j.type.mch.CorpPaymentCheckNameType;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* 现金发放测试
|
||||
|
||||
@@ -8,10 +8,10 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponDetail;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.payment.WeixinPayProxy;
|
||||
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
|
||||
@@ -27,6 +26,7 @@ import com.foxinmy.weixin4j.sign.WeixinSignature;
|
||||
import com.foxinmy.weixin4j.type.IdQuery;
|
||||
import com.foxinmy.weixin4j.type.IdType;
|
||||
import com.foxinmy.weixin4j.type.TradeType;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
/**
|
||||
* 支付测试(商户平台)
|
||||
|
||||
Reference in New Issue
Block a user