model包拆分media/paging & 包拆分card/mch & 新增card卡券相关类 & 新增CardApi:创建卡券接口

This commit is contained in:
jinyu 2016-08-05 21:56:34 +08:00
parent 5aaeec29e7
commit a2b9122b71
103 changed files with 2303 additions and 249 deletions

View File

@ -155,4 +155,13 @@
+ 重新整理HttpClinet
+ 新增OkHttp实现
+ 新增OkHttp实现
* 2016-08-05
+ model包拆分media/paing
+ type包拆分card/mch
+ 新增card卡券相关类

View File

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

View File

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

View File

@ -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;
/**

View File

@ -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;
/**

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
/**
* 自定义跳转的URLwww.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;
/**
* 自定义跳转的URLwww.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;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
/**

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
/**
* 负责微信请求的执行

View File

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

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.model.media;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.model.media;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.model.media;
import java.io.Serializable;
import java.util.Date;

View File

@ -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;
/**

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.model.media;
import java.io.Serializable;
import java.util.Date;

View File

@ -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开始

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.model.paging;
import java.io.Serializable;
import java.util.Iterator;

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.model.paging;
import java.io.Serializable;
import java.util.ArrayList;

View File

@ -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() {

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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")

View File

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

View File

@ -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")

View File

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

View File

@ -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;
/**

View File

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

View File

@ -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;
/**

View File

@ -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")

View File

@ -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;
/**

View File

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

View File

@ -35,7 +35,7 @@ public class MpArticle implements Serializable {
*/
private String title;
/**
* 图文页的URL 获取图文消息时
* 图文页的URL 获取图文消息时群发消息时填写无效
*/
private String url;
/**

View File

@ -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() {

View File

@ -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;
/**
* 图文列表

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.type;
/**
* 用户性别

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.mp.type;
package com.foxinmy.weixin4j.type.card;
/**
* 卡券类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 对账单类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 企业付款检查收款人姓名的策略

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 代金券状态

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 代金券批次状态

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 代金券批次类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 代金券类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 红包发放类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 红包状态

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 红包类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 退款渠道

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 退款状态

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.type;
package com.foxinmy.weixin4j.type.mch;
/**
* 退款类型

View File

@ -1,4 +1,4 @@
package com.foxinmy.weixin4j.model;
package com.foxinmy.weixin4j.util;
import java.nio.charset.Charset;

View File

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

View File

@ -3,8 +3,6 @@ package com.foxinmy.weixin4j.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import com.foxinmy.weixin4j.model.Consts;
/**
* 签名工具类
*

View File

@ -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;
/**

View File

@ -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 = "";

View File

@ -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;
/**

View File

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

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;
/**
* 现金发放测试

View File

@ -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;
/**

View File

@ -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;
/**
* 支付测试商户平台

View File

@ -238,4 +238,8 @@
* 2016-07-06
+ 新增第三方组件WeixinComponentProxy
+ 新增第三方组件WeixinComponentProxy
* 2016-08-05
+ 新增CardApi:创建卡券接口

View File

@ -36,6 +36,8 @@ weixin4j-mp
* TagApi `用户标签管理API`
* ComponentApi `第三方组件API`
* CardApi `卡券API`
[如何使用](https://github.com/foxinmy/weixin4j/wiki)
---------

View File

@ -8,7 +8,6 @@ import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.mp.api.ComponentApi;
@ -16,6 +15,7 @@ import com.foxinmy.weixin4j.mp.model.WeixinMpAccount;
import com.foxinmy.weixin4j.mp.type.URLConsts;
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
import com.foxinmy.weixin4j.token.TicketManager;
import com.foxinmy.weixin4j.util.Consts;
import com.foxinmy.weixin4j.util.StringUtil;
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;

View File

@ -4,16 +4,19 @@ import java.io.InputStream;
import java.util.Date;
import java.util.List;
import com.foxinmy.weixin4j.card.CardCoupon;
import com.foxinmy.weixin4j.card.CardCoupons;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.model.Button;
import com.foxinmy.weixin4j.model.MediaCounter;
import com.foxinmy.weixin4j.model.MediaDownloadResult;
import com.foxinmy.weixin4j.model.MediaItem;
import com.foxinmy.weixin4j.model.MediaRecord;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.model.media.MediaCounter;
import com.foxinmy.weixin4j.model.media.MediaDownloadResult;
import com.foxinmy.weixin4j.model.media.MediaItem;
import com.foxinmy.weixin4j.model.media.MediaRecord;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.model.paging.Pageable;
import com.foxinmy.weixin4j.mp.api.CardApi;
import com.foxinmy.weixin4j.mp.api.CustomApi;
import com.foxinmy.weixin4j.mp.api.DataApi;
import com.foxinmy.weixin4j.mp.api.GroupApi;
@ -122,6 +125,10 @@ public class WeixinProxy {
* 标签API
*/
private final TagApi tagApi;
/**
* 卡券API
*/
private final CardApi cardApi;
/**
* token实现
*/
@ -192,6 +199,7 @@ public class WeixinProxy {
this.helperApi = new HelperApi(tokenManager);
this.dataApi = new DataApi(tokenManager);
this.tagApi = new TagApi(tokenManager);
this.cardApi = new CardApi(tokenManager);
}
/**
@ -283,7 +291,7 @@ public class WeixinProxy {
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">
* 上传永久素材</a>
* @see com.foxinmy.weixin4j.model.MediaUploadResult
* @see com.foxinmy.weixin4j.model.media.MediaUploadResult
* @see com.foxinmy.weixin4j.type.MediaType
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @throws WeixinException
@ -303,7 +311,7 @@ public class WeixinProxy {
* @return 媒体文件下载结果
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @see com.foxinmy.weixin4j.model.MediaDownloadResult
* @see com.foxinmy.weixin4j.model.media.MediaDownloadResult
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738727&token=&lang=zh_CN">
* 下载临时媒体素材</a>
@ -420,7 +428,7 @@ public class WeixinProxy {
*
* @return 总数对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.model.MediaCounter
* @see com.com.foxinmy.weixin4j.model.media.MediaCounter
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738733&token=&lang=zh_CN">
* 获取素材总数</a>
@ -440,11 +448,11 @@ public class WeixinProxy {
* @return 媒体素材的记录对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @see com.foxinmy.weixin4j.mp.model.MediaRecord
* @see com.com.foxinmy.weixin4j.model.media.MediaRecord
* @see com.foxinmy.weixin4j.type.MediaType
* @see com.foxinmy.weixin4j.model.MediaItem
* @see com.foxinmy.weixin4j.model.Pageable
* @see com.foxinmy.weixin4j.model.Pagedata
* @see com.foxinmy.weixin4j.model.media.MediaItem
* @see com.foxinmy.weixin4j.model.paging.Pageable
* @see com.foxinmy.weixin4j.model.paging.Pagedata
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738734&token=&lang=zh_CN">
* 获取素材列表</a>
@ -1835,5 +1843,66 @@ public class WeixinProxy {
return tagApi.getUserTags(openId);
}
/**
* 创建卡券:创建卡券接口是微信卡券的基础接口用于创建一类新的卡券获取card_id创建成功并通过审核后
* 商家可以通过文档提供的其他接口将卡券下发给用户每次成功领取库存数量相应扣除
*
* <li>1.需自定义Code码的商家必须在创建卡券时候设定use_custom_code为true且在调用投放卡券接口时填入指定的Code码
* 指定OpenID同理特别注意在公众平台创建的卡券均为非自定义Code类型 <li>
* 2.can_share字段指领取卡券原生页面是否可分享建议指定Code码指定OpenID等强限制条件的卡券填写false <li>
* 3.创建成功后该卡券会自动提交审核
* 审核结果将通过事件通知商户开发者可调用设置白名单接口设置用户白名单领取未通过审核的卡券测试整个卡券的使用流程
*
* @param cardCoupon
* 卡券对象
* @see <a
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025056&token=&lang=zh_CN">创建卡券</a>
* @see CardCoupons
* @see MediaApi#uploadImage(java.io.InputStream, String)
* @see com.foxinmy.weixin4j.mp.api.CardApi
* @return 卡券ID
* @throws WeixinException
*/
public String createCardCoupon(CardCoupon cardCoupon)
throws WeixinException {
return cardApi.createCardCoupon(cardCoupon);
}
/**
* 设置卡券买单创建卡券之后开发者可以通过设置微信买单接口设置该card_id支持微信买单功能值得开发者注意的是
* 设置买单的card_id必须已经配置了门店否则会报错
*
* @param cardId
* 卡券ID
* @param isOpen
* 是否开启买单功能填true/false
* @see #createCardCoupon(CardCoupon)
* @see com.foxinmy.weixin4j.mp.api.CardApi
* @return 操作结果
* @throws WeixinException
*/
public ApiResult setCardPayCell(String cardId, boolean isOpen)
throws WeixinException {
return cardApi.setCardPayCell(cardId, isOpen);
}
/**
* 设置自助核销:创建卡券之后开发者可以通过设置微信买单接口设置该card_id支持自助核销功能值得开发者注意的是
* 设置自助核销的card_id必须已经配置了门店否则会报错
*
* @param cardId
* 卡券ID
* @param isOpen
* 是否开启买单功能填true/false
* @see #createCardCoupon(CardCoupon)
* @see com.foxinmy.weixin4j.mp.api.CardApi
* @return 操作结果
* @throws WeixinException
*/
public ApiResult setCardSelfConsumeCell(String cardId, boolean isOpen)
throws WeixinException {
return cardApi.setCardSelfConsumeCell(cardId, isOpen);
}
public final static String VERSION = "1.7.0";
}

View File

@ -0,0 +1,114 @@
package com.foxinmy.weixin4j.mp.api;
import com.alibaba.fastjson.JSONObject;
import com.foxinmy.weixin4j.card.CardCoupon;
import com.foxinmy.weixin4j.card.CardCoupons;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.token.TokenManager;
/**
* 卡券API
*
* @className CardApi
* @author jinyu(foxinmy@gmail.com)
* @date 2016年8月3日
* @since JDK 1.6
* @see <a
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025056&token=&lang=zh_CN">卡券说明</a>
*/
public class CardApi extends MpApi {
private final TokenManager tokenManager;
public CardApi(TokenManager tokenManager) {
this.tokenManager = tokenManager;
}
/**
* 创建卡券:创建卡券接口是微信卡券的基础接口用于创建一类新的卡券获取card_id创建成功并通过审核后
* 商家可以通过文档提供的其他接口将卡券下发给用户每次成功领取库存数量相应扣除
*
* <li>1.需自定义Code码的商家必须在创建卡券时候设定use_custom_code为true且在调用投放卡券接口时填入指定的Code码
* 指定OpenID同理特别注意在公众平台创建的卡券均为非自定义Code类型 <li>
* 2.can_share字段指领取卡券原生页面是否可分享建议指定Code码指定OpenID等强限制条件的卡券填写false <li>
* 3.创建成功后该卡券会自动提交审核
* 审核结果将通过事件通知商户开发者可调用设置白名单接口设置用户白名单领取未通过审核的卡券测试整个卡券的使用流程
*
* @param cardCoupon
* 卡券对象
* @see <a
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025056&token=&lang=zh_CN">创建卡券</a>
* @see CardCoupons
* @see MediaApi#uploadImage(java.io.InputStream, String)
* @return 卡券ID
* @throws WeixinException
*/
public String createCardCoupon(CardCoupon cardCoupon)
throws WeixinException {
JSONObject content = new JSONObject();
String cardType = cardCoupon.getCardType().name();
content.put("card_type", cardType);
content.put(cardType.toLowerCase(), cardCoupon);
JSONObject card = new JSONObject();
card.put("card", content);
System.err.println(card);
Token token = tokenManager.getCache();
String card_create_uri = getRequestUri("card_create_uri");
WeixinResponse response = weixinExecutor.post(
String.format(card_create_uri, token.getAccessToken()),
card.toJSONString());
return response.getAsJson().getString("card_id");
}
/**
* 设置卡券买单创建卡券之后开发者可以通过设置微信买单接口设置该card_id支持微信买单功能值得开发者注意的是
* 设置买单的card_id必须已经配置了门店否则会报错
*
* @param cardId
* 卡券ID
* @param isOpen
* 是否开启买单功能填true/false
* @see #createCardCoupon(CardCoupon)
* @return 操作结果
* @throws WeixinException
*/
public ApiResult setCardPayCell(String cardId, boolean isOpen)
throws WeixinException {
JSONObject params = new JSONObject();
params.put("card_id", cardId);
params.put("is_open", isOpen);
Token token = tokenManager.getCache();
String card_paycell_uri = getRequestUri("card_paycell_uri");
WeixinResponse response = weixinExecutor.post(
String.format(card_paycell_uri, token.getAccessToken()),
params.toJSONString());
return response.getAsResult();
}
/**
* 设置自助核销:创建卡券之后开发者可以通过设置微信买单接口设置该card_id支持自助核销功能值得开发者注意的是
* 设置自助核销的card_id必须已经配置了门店否则会报错
*
* @param cardId
* 卡券ID
* @param isOpen
* 是否开启买单功能填true/false
* @see #createCardCoupon(CardCoupon)
* @return 操作结果
* @throws WeixinException
*/
public ApiResult setCardSelfConsumeCell(String cardId, boolean isOpen)
throws WeixinException {
JSONObject params = new JSONObject();
params.put("card_id", cardId);
params.put("is_open", isOpen);
Token token = tokenManager.getCache();
String card_selfconsumecell_uri = getRequestUri("card_selfconsumecell_uri");
WeixinResponse response = weixinExecutor
.post(String.format(card_selfconsumecell_uri,
token.getAccessToken()), params.toJSONString());
return response.getAsResult();
}
}

View File

@ -28,18 +28,18 @@ import com.foxinmy.weixin4j.http.entity.StringEntity;
import com.foxinmy.weixin4j.http.message.JsonMessageConverter;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.model.MediaCounter;
import com.foxinmy.weixin4j.model.MediaDownloadResult;
import com.foxinmy.weixin4j.model.MediaItem;
import com.foxinmy.weixin4j.model.MediaRecord;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.model.media.MediaCounter;
import com.foxinmy.weixin4j.model.media.MediaDownloadResult;
import com.foxinmy.weixin4j.model.media.MediaItem;
import com.foxinmy.weixin4j.model.media.MediaRecord;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.model.paging.Pageable;
import com.foxinmy.weixin4j.token.TokenManager;
import com.foxinmy.weixin4j.tuple.MpArticle;
import com.foxinmy.weixin4j.tuple.MpVideo;
import com.foxinmy.weixin4j.type.MediaType;
import com.foxinmy.weixin4j.util.Consts;
import com.foxinmy.weixin4j.util.FileUtil;
import com.foxinmy.weixin4j.util.IOUtil;
import com.foxinmy.weixin4j.util.ObjectId;
@ -140,7 +140,7 @@ public class MediaApi extends MpApi {
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738726&token=&lang=zh_CN">上传临时素材</a>
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">上传永久素材</a>
* @see com.foxinmy.weixin4j.model.MediaUploadResult
* @see com.foxinmy.weixin4j.model.media.MediaUploadResult
* @see com.foxinmy.weixin4j.type.MediaType
* @throws WeixinException
*/
@ -214,7 +214,7 @@ public class MediaApi extends MpApi {
* @return 媒体下载结果
*
* @throws WeixinException
* @see com.foxinmy.weixin4j.model.MediaDownloadResult
* @see com.foxinmy.weixin4j.model.media.MediaDownloadResult
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738727&token=&lang=zh_CN">下载临时媒体素材</a>
* @see <a href=
@ -407,7 +407,7 @@ public class MediaApi extends MpApi {
*
* @return 总数对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.model.MediaCounter
* @see com.foxinmy.weixin4j.model.media.MediaCounter
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738733&token=&lang=zh_CN">获取素材总数</a>
*/
@ -429,11 +429,11 @@ public class MediaApi extends MpApi {
* 分页数据
* @return 媒体素材的记录对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.model.MediaRecord
* @see com.foxinmy.weixin4j.model.media.MediaRecord
* @see com.foxinmy.weixin4j.type.MediaType
* @see com.foxinmy.weixin4j.model.MediaItem
* @see com.foxinmy.weixin4j.model.Pageable
* @see com.foxinmy.weixin4j.model.Pagedata
* @see com.foxinmy.weixin4j.model.media.MediaItem
* @see com.foxinmy.weixin4j.model.paging.Pageable
* @see com.foxinmy.weixin4j.model.paging.Pagedata
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738734&token=&lang=zh_CN">获取素材列表</a>
*/

View File

@ -7,11 +7,11 @@ 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.Consts;
import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.mp.model.OauthToken;
import com.foxinmy.weixin4j.mp.model.User;
import com.foxinmy.weixin4j.mp.type.Lang;
import com.foxinmy.weixin4j.util.Consts;
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
/**

View File

@ -29,7 +29,6 @@ import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.entity.FormUrlEntity;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.mp.oldpayment.OrderV2;
import com.foxinmy.weixin4j.mp.oldpayment.PayPackageV2;
@ -43,10 +42,11 @@ import com.foxinmy.weixin4j.setting.Weixin4jSettings;
import com.foxinmy.weixin4j.sign.WeixinPaymentSignature;
import com.foxinmy.weixin4j.sign.WeixinSignature;
import com.foxinmy.weixin4j.token.TokenManager;
import com.foxinmy.weixin4j.type.BillType;
import com.foxinmy.weixin4j.type.IdQuery;
import com.foxinmy.weixin4j.type.RefundType;
import com.foxinmy.weixin4j.type.SignType;
import com.foxinmy.weixin4j.type.mch.BillType;
import com.foxinmy.weixin4j.type.mch.RefundType;
import com.foxinmy.weixin4j.util.Consts;
import com.foxinmy.weixin4j.util.DateUtil;
import com.foxinmy.weixin4j.util.DigestUtil;
import com.foxinmy.weixin4j.util.MapUtil;
@ -261,8 +261,10 @@ public class PayOldApi extends MpApi {
map.put("service_version", "1.1");
map.put("partner", weixinAccount.getPartnerId());
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)));
map.put(idQuery.getType().getName(), idQuery.getId());
if (StringUtil.isBlank(opUserId)) {
opUserId = weixinAccount.getPartnerId();
@ -465,7 +467,7 @@ public class PayOldApi extends MpApi {
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file), Consts.GBK));
reader = new BufferedReader(new InputStreamReader(
response.getBody(), com.foxinmy.weixin4j.model.Consts.GBK));
response.getBody(), com.foxinmy.weixin4j.util.Consts.GBK));
String line = null;
while ((line = reader.readLine()) != null) {
writer.write(line);

View File

@ -180,6 +180,13 @@ tag_userids_uri={api_cgi_url}/tags/getidlist?access_token=%s
# \u83b7\u53d6\u6807\u7b7e\u4e0b\u7c89\u4e1d\u5217\u8868
tag_user_uri={api_cgi_url}/user/tag/get?access_token=%s
# \u521b\u5efa\u5361\u5238
card_create_uri={api_base_url}/card/create?access_token=%s
# \u8bbe\u7f6e\u4e70\u5355\u63a5\u53e3
card_paycell_uri={api_base_url}/card/paycell/set?access_token=%s
# \u8bbe\u7f6e\u81ea\u52a9\u6838\u9500\u63a5\u53e3
card_selfconsumecell_uri={api_base_url}/card/selfconsumecell/set?access_token=%s
# \u4f7f\u7528\u6388\u6743\u7801\u6362\u53d6\u516c\u4f17\u53f7\u7684\u63a5\u53e3\u8c03\u7528\u51ed\u636e\u548c\u6388\u6743\u4fe1\u606f
component_exchange_authorizer_uri={api_cgi_url}/component/api_query_auth?component_access_token=%s
# \u83b7\u53d6\u6388\u6743\u65b9\u7684\u516c\u4f17\u53f7\u5e10\u53f7\u57fa\u672c\u4fe1\u606f

View File

@ -4,9 +4,9 @@ import java.io.Serializable;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.Gender;
import com.foxinmy.weixin4j.mp.type.ClientPlatformType;
import com.foxinmy.weixin4j.mp.type.Lang;
import com.foxinmy.weixin4j.type.Gender;
/**
* 个性化菜单匹配规则

View File

@ -5,9 +5,9 @@ import java.util.Date;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.Gender;
import com.foxinmy.weixin4j.mp.type.FaceSize;
import com.foxinmy.weixin4j.mp.type.Lang;
import com.foxinmy.weixin4j.type.Gender;
import com.foxinmy.weixin4j.util.StringUtil;
/**

View File

@ -47,13 +47,13 @@ public class PayPackageV2 extends PayPackage {
*/
@XmlElement(name = "transport_fee")
@JSONField(name = "transport_fee")
private String transportFee;
private Integer transportFee;
/**
* 商品费用 可为空 商品费用,单位为分如果有值,必须保 transport_fee +product_fee=total_fee;
*/
@XmlElement(name = "product_fee")
@JSONField(name = "product_fee")
private String productFee;
private Integer productFee;
/**
* 传入参数字符编码 取值范围:"GBK""UTF-8",默认:"GBK" 可为空
*/
@ -133,8 +133,8 @@ public class PayPackageV2 extends PayPackage {
this.inputCharset = "UTF-8";
this.partner = partner;
this.transportFee = transportFee > 0d ? DateUtil
.formatFee2Fen(transportFee) : null;
this.productFee = productFee > 0 ? DateUtil.formatFee2Fen(productFee)
.formatYuan2Fen(transportFee) : null;
this.productFee = productFee > 0 ? DateUtil.formatYuan2Fen(productFee)
: null;
}
@ -154,9 +154,19 @@ public class PayPackageV2 extends PayPackage {
return feeType;
}
public String getTransportFee() {
public Integer getTransportFee() {
return transportFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatTransportFee() {
return transportFee != null ? transportFee / 100d : 0d;
}
/**
* <font color="red">单位为元,自动格式化为分</font>
@ -165,12 +175,22 @@ public class PayPackageV2 extends PayPackage {
* 物流费用 单位为元
*/
public void setTransportFee(double transportFee) {
this.transportFee = DateUtil.formatFee2Fen(transportFee);
this.transportFee = DateUtil.formatYuan2Fen(transportFee);
}
public String getProductFee() {
public Integer getProductFee() {
return productFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatProductFee() {
return productFee != null ? productFee / 100d : 0d;
}
/**
* <font color="red">单位为元,自动格式化为分</font>
@ -179,7 +199,7 @@ public class PayPackageV2 extends PayPackage {
* 商品 单位为元
*/
public void setProductFee(double productFee) {
this.productFee = DateUtil.formatFee2Fen(productFee);
this.productFee = DateUtil.formatYuan2Fen(productFee);
}
public String getInputCharset() {

View File

@ -6,8 +6,8 @@ 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.RefundStatus;
import com.foxinmy.weixin4j.type.mch.RefundChannel;
import com.foxinmy.weixin4j.type.mch.RefundStatus;
/**
* V2退款详细

View File

@ -1,47 +0,0 @@
package com.foxinmy.weixin4j.mp.type;
/**
* 卡券颜色
*
* @className CardColor
* @author jinyu(foxinmy@gmail.com)
* @date 2016年4月4日
* @since JDK 1.6
* @see
*/
public enum CardColor {
COLOR010(99, 179, 89, "#63b359"), COLOR020(44, 159, 103, "#2c9f67"), COLOR030(
80, 159, 201, "#509fc9"), COLOR040(88, 133, 207, "#5885cf"), COLOR050(
144, 98, 192, "#9062c0"), COLOR060(208, 154, 69, "#d09a45"), COLOR070(
228, 117, 56, "#e4b138"), COLOR080(238, 144, 60, "#ee903c"), COLOR081(
240, 133, 0, "#f08500"), COLOR082(169, 217, 45, "#a9d92d"), COLOR090(
221, 101, 73, "#dd6549"), COLOR0100(204, 70, 61, "#cc463d"), COLOR0101(
207, 62, 54, "#cf3e36"), 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;
}
}

View File

@ -0,0 +1,81 @@
package com.foxinmy.weixin4j.mp.test;
import java.util.Calendar;
import java.util.Date;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.foxinmy.weixin4j.card.CardCoupon;
import com.foxinmy.weixin4j.card.CardCoupons;
import com.foxinmy.weixin4j.card.CouponBaseInfo;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.mp.api.CardApi;
import com.foxinmy.weixin4j.type.card.CardCodeType;
import com.foxinmy.weixin4j.type.card.CardColor;
/**
* 卡券测试
*
* @className CardTest
* @author jinyu(foxinmy@gmail.com)
* @date 2016年8月5日
* @since JDK 1.6
*/
public class CardTest extends TokenTest {
private CardApi cardApi;
@Before
public void init() {
cardApi = new CardApi(tokenManager);
}
/**
* 创建卡券测试
*
* @throws WeixinException
*/
@Test
public void createCardCoupon() throws WeixinException {
CouponBaseInfo.Builder builder = CardCoupons.customBase();
// ... 必选字段
builder.logoUrl("商户logo").brandName("商户名称").title("双人套餐100元兑换券");
builder.codeType(CardCodeType.CODE_TYPE_BARCODE).cardColor(
CardColor.Color010);
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DAY_OF_MONTH, 1);
Date beginTime = ca.getTime();
ca.add(Calendar.DAY_OF_MONTH, 1);
Date endTime = ca.getTime();
builder.notice("请出示二维码").description("不可与其他优惠同享").quantity(100)
.activeAt(beginTime, endTime);
// ... 可选字段
CardCoupon coupon = CardCoupons.createGeneralCoupon(builder, "优惠券描述");
String cardId = cardApi.createCardCoupon(coupon);
// pwGBft8tDsk_gj2rfVeAfreCxQS8
Assert.assertNotNull(cardId);
}
/**
* 设置卡券买单
*
* @throws WeixinException
*/
@Test
public void setCardPayCell() throws WeixinException {
String cardId = "pwGBft8tDsk_gj2rfVeAfreCxQS8";
cardApi.setCardPayCell(cardId, true);
}
/**
* 设置自助核销
*
* @throws WeixinException
*/
@Test
public void setCardSelfConsumeCell() throws WeixinException {
String cardId = "pwGBft8tDsk_gj2rfVeAfreCxQS8";
cardApi.setCardSelfConsumeCell(cardId, true);
}
}

View File

@ -12,7 +12,7 @@ import org.junit.Test;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.mp.api.MassApi;
import com.foxinmy.weixin4j.mp.api.MediaApi;
import com.foxinmy.weixin4j.tuple.Image;

View File

@ -13,12 +13,12 @@ import org.junit.Test;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.model.MediaCounter;
import com.foxinmy.weixin4j.model.MediaDownloadResult;
import com.foxinmy.weixin4j.model.MediaItem;
import com.foxinmy.weixin4j.model.MediaRecord;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.media.MediaCounter;
import com.foxinmy.weixin4j.model.media.MediaDownloadResult;
import com.foxinmy.weixin4j.model.media.MediaItem;
import com.foxinmy.weixin4j.model.media.MediaRecord;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.model.paging.Pageable;
import com.foxinmy.weixin4j.mp.api.MediaApi;
import com.foxinmy.weixin4j.tuple.MpArticle;
import com.foxinmy.weixin4j.tuple.MpVideo;

View File

@ -10,7 +10,7 @@ import org.junit.Test;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.mp.api.MediaApi;
import com.foxinmy.weixin4j.mp.api.NotifyApi;
import com.foxinmy.weixin4j.mp.message.NotifyMessage;

View File

@ -6,13 +6,13 @@ import java.util.List;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.model.Button;
import com.foxinmy.weixin4j.model.MediaCounter;
import com.foxinmy.weixin4j.model.MediaDownloadResult;
import com.foxinmy.weixin4j.model.MediaItem;
import com.foxinmy.weixin4j.model.MediaRecord;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.model.media.MediaCounter;
import com.foxinmy.weixin4j.model.media.MediaDownloadResult;
import com.foxinmy.weixin4j.model.media.MediaItem;
import com.foxinmy.weixin4j.model.media.MediaRecord;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.model.paging.Pageable;
import com.foxinmy.weixin4j.qy.api.AgentApi;
import com.foxinmy.weixin4j.qy.api.BatchApi;
import com.foxinmy.weixin4j.qy.api.ChatApi;
@ -369,7 +369,7 @@ public class WeixinProxy {
* 文件名
* @return 上传到微信服务器返回的媒体标识
* @see com.foxinmy.weixin4j.qy.api.MediaApi
* @see com.foxinmy.weixin4j.model.MediaUploadResult
* @see com.foxinmy.weixin4j.model.media.MediaUploadResult
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">
* 上传临时素材文件说明</a>
@ -391,7 +391,7 @@ public class WeixinProxy {
* @param mediaId
* 媒体ID
* @return 媒体下载结果
* @see com.foxinmy.weixin4j.model.MediaDownloadResult
* @see com.foxinmy.weixin4j.model.media.MediaDownloadResult
* @see com.foxinmy.weixin4j.qy.api.MediaApi
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">
@ -497,7 +497,7 @@ public class WeixinProxy {
* @return 总数对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.qy.api.MediaApi
* @see com.foxinmy.weixin4j.model.MediaCounter
* @see com.foxinmy.weixin4j.model.media.MediaCounter
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E6%80%BB%E6%95%B0">
* 获取素材总数</a>
@ -518,11 +518,11 @@ public class WeixinProxy {
* @return 媒体素材的记录对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.qy.api.MediaApi
* @see com.foxinmy.weixin4j.model.MediaRecord
* @see com.foxinmy.weixin4j.model.media.MediaRecord
* @see com.foxinmy.weixin4j.type.MediaType
* @see com.foxinmy.weixin4j.model.MediaItem
* @see com.foxinmy.weixin4j.model.Pageable
* @see com.foxinmy.weixin4j.model.Pagedata
* @see com.foxinmy.weixin4j.model.media.MediaItem
* @see com.foxinmy.weixin4j.model.paging.Pageable
* @see com.foxinmy.weixin4j.model.paging.Pagedata
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E5%88%97%E8%A1%A8">
* 获取素材列表</a>

View File

@ -8,7 +8,6 @@ import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.qy.api.ProviderApi;
@ -21,6 +20,7 @@ import com.foxinmy.weixin4j.qy.type.URLConsts;
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
import com.foxinmy.weixin4j.token.TicketManager;
import com.foxinmy.weixin4j.token.TokenManager;
import com.foxinmy.weixin4j.util.Consts;
import com.foxinmy.weixin4j.util.StringUtil;
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;

View File

@ -29,20 +29,20 @@ import com.foxinmy.weixin4j.http.apache.InputStreamBody;
import com.foxinmy.weixin4j.http.message.JsonMessageConverter;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.model.MediaCounter;
import com.foxinmy.weixin4j.model.MediaDownloadResult;
import com.foxinmy.weixin4j.model.MediaItem;
import com.foxinmy.weixin4j.model.MediaRecord;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.model.media.MediaCounter;
import com.foxinmy.weixin4j.model.media.MediaDownloadResult;
import com.foxinmy.weixin4j.model.media.MediaItem;
import com.foxinmy.weixin4j.model.media.MediaRecord;
import com.foxinmy.weixin4j.model.media.MediaUploadResult;
import com.foxinmy.weixin4j.model.paging.Pageable;
import com.foxinmy.weixin4j.qy.model.Callback;
import com.foxinmy.weixin4j.qy.model.Party;
import com.foxinmy.weixin4j.qy.model.User;
import com.foxinmy.weixin4j.token.TokenManager;
import com.foxinmy.weixin4j.tuple.MpArticle;
import com.foxinmy.weixin4j.type.MediaType;
import com.foxinmy.weixin4j.util.Consts;
import com.foxinmy.weixin4j.util.FileUtil;
import com.foxinmy.weixin4j.util.IOUtil;
import com.foxinmy.weixin4j.util.ObjectId;
@ -110,7 +110,7 @@ public class MediaApi extends QyApi {
* @param fileName
* 文件名
* @return 上传到微信服务器返回的媒体标识
* @see com.foxinmy.weixin4j.model.MediaUploadResult
* @see com.foxinmy.weixin4j.model.media.MediaUploadResult
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">上传临时素材文件说明</a>
* @see <a href=
@ -179,7 +179,7 @@ public class MediaApi extends QyApi {
* @param mediaId
* 媒体ID
* @return 媒体下载结果
* @see com.foxinmy.weixin4j.model.MediaDownloadResult
* @see com.foxinmy.weixin4j.model.media.MediaDownloadResult
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">获取临时媒体说明</a>
* @see <a href=
@ -332,7 +332,7 @@ public class MediaApi extends QyApi {
* 企业应用id
* @return 总数对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.model.MediaCounter
* @see com.foxinmy.weixin4j.model.media.MediaCounter
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E6%80%BB%E6%95%B0">获取素材总数</a>
*/
@ -358,11 +358,11 @@ public class MediaApi extends QyApi {
* 分页数据
* @return 媒体素材的记录对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.model.MediaRecord
* @see com.foxinmy.weixin4j.model.media.MediaRecord
* @see com.foxinmy.weixin4j.type.MediaType
* @see com.foxinmy.weixin4j.model.MediaItem
* @see com.foxinmy.weixin4j.model.Pageable
* @see com.foxinmy.weixin4j.model.Pagedata
* @see com.foxinmy.weixin4j.model.media.MediaItem
* @see com.foxinmy.weixin4j.model.paging.Pageable
* @see com.foxinmy.weixin4j.model.paging.Pagedata
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E5%88%97%E8%A1%A8">获取素材列表</a>
*/

Some files were not shown because too many files have changed in this diff Show More