* Created by Binary Wang on 2016/7/21. * 素材管理的相关接口,包括媒体管理的接口, * 即以https://api.weixin.qq.com/cgi-bin/material * 和 https://api.weixin.qq.com/cgi-bin/media开头的接口 + **/ public interface WxMpMaterialService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index 0db67cb7..72eabd08 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -1,10 +1,17 @@ package me.chanjar.weixin.mp.api; -import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.bean.result.*; - import java.util.Map; +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback; +import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult; +import me.chanjar.weixin.mp.bean.pay.WxMpPayResult; +import me.chanjar.weixin.mp.bean.pay.WxMpPrepayIdResult; +import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; +import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest; +import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest; +import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderResult; + /** * 微信支付相关接口 * Created by Binary Wang on 2016/7/28. @@ -12,77 +19,32 @@ import java.util.Map; */ public interface WxMpPayService { - - /** - * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) - * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" - * - * @param openId 支付人openId - * @param outTradeNo 商户端对应订单号 - * @param amt 金额(单位元) - * @param body 商品描述 - * @param tradeType 交易类型 JSAPI,NATIVE,APP,WAP - * @param ip 发起支付的客户端IP - * @param notifyUrl 通知地址 - * @deprecated Use me.chanjar.weixin.mp.api.WxMpService.getPrepayId(Map
- * 需要传入的必填参数如下: - * mch_billno//商户订单号 - * send_name//商户名称 - * re_openid//用户openid - * total_amount//红包总额 - * total_num//红包发放总人数 - * wishing//红包祝福语 - * client_ip//服务器Ip地址 - * act_name//活动名称 - * remark //备注 - * 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5 - *
- * 使用现金红包功能需要在xml配置文件中额外设置:
- *
+ * 文档详见: + * 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3 + * 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4 + **/ - WxRedpackResult sendRedpack(Map
+ * 创建门店 + * 接口说明 + * 创建门店接口是为商户提供创建自己门店数据的接口,门店数据字段越完整,商户页面展示越丰富,越能够吸引更多用户,并提高曝光度。 + * 创建门店接口调用成功后会返回errcode 0、errmsg ok,但不会实时返回poi_id。 + * 成功创建后,会生成poi_id,但该id不一定为最终id。门店信息会经过审核,审核通过后方可获取最终poi_id,该id为门店的唯一id,强烈建议自行存储审核通过后的最终poi_id,并为后续调用使用。 + * 详情请见: 微信门店接口 + * 接口格式: http://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN + *+ * + */ + void add(WxMpStoreBaseInfo request) throws WxErrorException; + + /** + *
+ * 查询门店列表(指定查询起始位置和个数) + * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。 + * 详情请见: 微信门店接口 + *+ * @param begin 开始位置,0 即为从第一条开始查询 + * @param limit 返回数据条数,最大允许50,默认为20 + * @throws WxErrorException + */ + WxMpStoreListResult list(int begin, int limit) throws WxErrorException; + + /** + *
+ * 查询门店列表(所有) + * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。 + * 详情请见: 微信门店接口 + *+ * @throws WxErrorException + */ + List
+ * 获取标签下粉丝列表 + * 详情请见:用户标签管理 + * 接口url格式: https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN + *+ * + */ + WxTagListUser tagListUser(Integer tagId, String nextOpenid) throws WxErrorException; + + /** + *
+ * 批量为用户打标签 + * 详情请见:用户标签管理 + * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN + *+ * + */ + boolean batchTagging(Integer tagId, String[] openids) throws WxErrorException; + + /** + *
+ * 批量为用户取消标签 + * 详情请见:用户标签管理 + * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN + *+ * + */ + boolean batchUntagging(Integer tagId, String[] openids) throws WxErrorException; + + + /** + *
+ * 获取用户身上的标签列表 + * 详情请见:用户标签管理 + * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN + *+ * + */ + List
* 请使用 @@ -46,6 +53,7 @@ public class WxMpCustomMessage implements Serializable { * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC} * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO} * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS} + * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_WXCARD} ** @param msgType */ @@ -94,24 +102,33 @@ public class WxMpCustomMessage implements Serializable { public void setHqMusicUrl(String hqMusicUrl) { this.hqMusicUrl = hqMusicUrl; } + + public String getCardId() { + return this.cardId; + } + + public void setCardId(String cardId) { + this.cardId = cardId; + } + public List
+ * 用法: WxMpCustomMessage m = WxMpCustomMessage.WXCARD().cardId(...).toUser(...).build(); + *+ * @author mgcnrx11 + * + */ +public final class WxCardBuilder extends BaseBuilder
* 查询订单支付状态返回的结果 @@ -13,9 +16,11 @@ import java.io.Serializable; * @author ukid */ public class WxMpPayResult implements Serializable { - /** - * - */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } + private static final long serialVersionUID = -570934170727777190L; private String return_code; @@ -41,6 +46,16 @@ public class WxMpPayResult implements Serializable { private String out_trade_no; private String attach; private String time_end; + /** + * 现金支付金额 cash_fee 是 Int 100 现金支付金额订单现金支付金额,详见支付金额 + */ + private String cash_fee; + + /** + * 现金支付货币类型 cash_fee_type 否 + * + */ + private String cash_fee_type; public String getReturn_code() { return this.return_code; @@ -226,32 +241,19 @@ public class WxMpPayResult implements Serializable { this.trade_state_desc = trade_state_desc; } - @Override - public String toString() { - return "WxMpPayResult{" + - "return_code=" + this.return_code + - ", return_msg='" + this.return_msg + '\'' + - ", appid='" + this.appid + '\'' + - ", mch_id='" + this.mch_id + '\'' + - ", nonce_str='" + this.nonce_str + '\'' + - ", sign='" + this.sign + '\'' + - ", result_code='" + this.result_code + '\'' + - ", err_code='" + this.err_code + '\'' + - ", err_code_des='" + this.err_code_des + '\'' + - ", trade_state=" + this.trade_state + - ", trade_state_desc=" + this.trade_state_desc + - ", device_info='" + this.device_info + '\'' + - ", openid='" + this.openid + '\'' + - ", is_subscribe='" + this.is_subscribe + '\'' + - ", trade_type='" + this.trade_type + '\'' + - ", bank_type='" + this.bank_type + '\'' + - ", total_fee='" + this.total_fee + '\'' + - ", coupon_fee='" + this.coupon_fee + '\'' + - ", fee_type='" + this.fee_type + '\'' + - ", transaction_id='" + this.transaction_id + '\'' + - ", out_trade_no='" + this.out_trade_no + '\'' + - ", attach='" + this.attach + '\'' + - ", time_end='" + this.time_end + '\'' + - '}'; + public String getCash_fee() { + return this.cash_fee; + } + + public void setCash_fee(String cash_fee) { + this.cash_fee = cash_fee; + } + + public String getCash_fee_type() { + return this.cash_fee_type; + } + + public void setCash_fee_type(String cash_fee_type) { + this.cash_fee_type = cash_fee_type; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java new file mode 100644 index 00000000..cff9d787 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java @@ -0,0 +1,124 @@ +package me.chanjar.weixin.mp.bean.pay; + +import java.io.Serializable; + +/** + *+ * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果 + * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) + *+ * + * @author chanjarster + */ +@Deprecated +public class WxMpPrepayIdResult implements Serializable { + private static final long serialVersionUID = -8970574397788396143L; + private String return_code; + private String return_msg; + private String appid; + private String mch_id; + private String nonce_str; + private String sign; + private String result_code; + private String prepay_id; + private String trade_type; + private String err_code; + private String err_code_des; + private String code_url; + + public String getReturn_code() { + return this.return_code; + } + + public void setReturn_code(String return_code) { + this.return_code = return_code; + } + + public String getReturn_msg() { + return this.return_msg; + } + + public void setReturn_msg(String return_msg) { + this.return_msg = return_msg; + } + + public String getAppid() { + return this.appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getMch_id() { + return this.mch_id; + } + + public void setMch_id(String mch_id) { + this.mch_id = mch_id; + } + + public String getNonce_str() { + return this.nonce_str; + } + + public void setNonce_str(String nonce_str) { + this.nonce_str = nonce_str; + } + + public String getSign() { + return this.sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getResult_code() { + return this.result_code; + } + + public void setResult_code(String result_code) { + this.result_code = result_code; + } + + public String getPrepay_id() { + return this.prepay_id; + } + + public void setPrepay_id(String prepay_id) { + this.prepay_id = prepay_id; + } + + public String getTrade_type() { + return this.trade_type; + } + + public void setTrade_type(String trade_type) { + this.trade_type = trade_type; + } + + public String getErr_code() { + return this.err_code; + } + + public void setErr_code(String err_code) { + this.err_code = err_code; + } + + public String getErr_code_des() { + return this.err_code_des; + } + + public void setErr_code_des(String err_code_des) { + this.err_code_des = err_code_des; + } + + public String getCode_url() { + return this.code_url; + } + + public void setCode_url(String code_url) { + this.code_url = code_url; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxRedpackResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java similarity index 66% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxRedpackResult.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java index be328668..297e07d7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxRedpackResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java @@ -1,7 +1,10 @@ -package me.chanjar.weixin.mp.bean.result; +package me.chanjar.weixin.mp.bean.pay; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + import com.thoughtworks.xstream.annotations.XStreamAlias; /** @@ -13,38 +16,35 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; @XStreamAlias("xml") public class WxRedpackResult implements Serializable { - /** - * - */ private static final long serialVersionUID = -4837415036337132073L; @XStreamAlias("return_code") - String returnCode; + private String returnCode; @XStreamAlias("return_msg") - String returnMsg; + private String returnMsg; @XStreamAlias("sign") - String sign; + private String sign; @XStreamAlias("result_code") - String resultCode; + private String resultCode; @XStreamAlias("err_code") - String errCode; + private String errCode; @XStreamAlias("err_code_des") - String errCodeDes; + private String errCodeDes; @XStreamAlias("mch_billno") - String mchBillno; + private String mchBillno; @XStreamAlias("mch_id") - String mchId; + private String mchId; @XStreamAlias("wxappid") - String wxappid; + private String wxappid; @XStreamAlias("re_openid") - String reOpenid; + private String reOpenid; @XStreamAlias("total_amount") - int totalAmount; + private int totalAmount; @XStreamAlias("send_time") - String sendTime; + private String sendTime; @XStreamAlias("send_listid") - String sendListid; + private String sendListid; public String getErrCode() { return this.errCode; @@ -100,19 +100,6 @@ public class WxRedpackResult implements Serializable { @Override public String toString() { - return "WxRedpackResult{" + - "returnCode=" + this.returnCode + - ", returnMsg=" + this.returnMsg + - ", sign=" + this.sign + - ", errCode=" + this.errCode + - ", errCodeDes=" + this.errCodeDes + - ", mchBillno=" + this.mchBillno + - ", mchId=" + this.mchId + - ", wxappid=" + this.wxappid + - ", reOpenid=" + this.reOpenid + - ", totalAmount=" + this.totalAmount + - ", sendTime=" + this.sendTime + - ", sendListid=" + this.sendListid + - '}'; + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequest.java new file mode 100644 index 00000000..abe0d68f --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequest.java @@ -0,0 +1,296 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + * 发送红包请求参数对象 + * Created by Binary Wang on 2016/9/24. + * @author binarywang (https://github.com/binarywang) + */ +@XStreamAlias("xml") +public class WxSendRedpackRequest { + /** + * mch_billno + * 商户订单号(每个订单号必须唯一) 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。 + */ + @XStreamAlias("mch_billno") + private String mchBillno; + + /** + * send_name + * 商户名称 + * 红包发送者名称 + */ + @XStreamAlias("send_name") + private String sendName; + + /** + * re_openid + * 接受红包的用户 用户在wxappid下的openid + */ + @XStreamAlias("re_openid") + private String reOpenid; + + /** + * total_amount + * 红包总额 + */ + @XStreamAlias("total_amount") + private Integer totalAmount; + + /** + * total_num + * 红包发放总人数 + */ + @XStreamAlias("total_num") + private Integer totalNum; + + /** + * amt_type + * 红包金额设置方式 + * ALL_RAND—全部随机,商户指定总金额和红包发放总人数,由微信支付随机计算出各红包金额 + * 裂变红包必填 + */ + @XStreamAlias("amt_type") + private String amtType; + + /** + * wishing + * 红包祝福语 + */ + @XStreamAlias("wishing") + private String wishing; + + /** + * client_ip + * 服务器Ip地址 + * 调用接口的机器Ip地址 + */ + @XStreamAlias("client_ip") + private String clientIp; + + /** + * act_name + * 活动名称 + */ + @XStreamAlias("act_name") + private String actName; + + /** + * remark + * 备注 + */ + @XStreamAlias("remark") + private String remark; + + /** + * wxappid + * 微信分配的公众账号ID(企业号corpid即为此appId)。接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),不能为APP的appid(在open.weixin.qq.com申请的) + */ + @XStreamAlias("wxappid") + private String wxAppid; + + /** + * mch_id + * 微信支付分配的商户号 + */ + @XStreamAlias("mch_id") + private String mchId; + + /** + * nonce_str + * 随机字符串,不长于32位 + */ + @XStreamAlias("nonce_str") + private String nonceStr; + + /** + * sign + * 详见签名生成算法 + */ + @XStreamAlias("sign") + private String sign; + + /** + *+ * scene_id + * 场景id + * PRODUCT_1:商品促销 + * PRODUCT_2:抽奖 + * PRODUCT_3:虚拟物品兑奖 + * PRODUCT_4:企业内部福利 + * PRODUCT_5:渠道分润 + * PRODUCT_6:保险回馈 + * PRODUCT_7:彩票派奖 + * PRODUCT_8:税务刮奖 + * 非必填字段 + *+ */ + @XStreamAlias("scene_id") + private String sceneId; + + /** + *+ * risk_info + * 活动信息 + * posttime:用户操作的时间戳 + * mobile:业务系统账号的手机号,国家代码-手机号。不需要+号 + * deviceid :mac 地址或者设备唯一标识 + * clientversion :用户操作的客户端版本 + * 把值为非空的信息用key=value进行拼接,再进行urlencode + * urlencode(posttime=xx&mobile=xx&deviceid=xx) + * 非必填字段 + *+ */ + @XStreamAlias("risk_info") + private String riskInfo; + + /** + *+ * consume_mch_id + * 资金授权商户号 + * 资金授权商户号 + * 服务商替特约商户发放时使用 + * 非必填字段 + *+ */ + @XStreamAlias("consume_mch_id") + private String consumeMchId; + + public String getMchBillno() { + return this.mchBillno; + } + + public void setMchBillno(String mchBillno) { + this.mchBillno = mchBillno; + } + + public String getSendName() { + return this.sendName; + } + + public void setSendName(String sendName) { + this.sendName = sendName; + } + + public String getReOpenid() { + return this.reOpenid; + } + + public void setReOpenid(String reOpenid) { + this.reOpenid = reOpenid; + } + + public Integer getTotalAmount() { + return this.totalAmount; + } + + public void setTotalAmount(Integer totalAmount) { + this.totalAmount = totalAmount; + } + + public Integer getTotalNum() { + return this.totalNum; + } + + public void setTotalNum(Integer totalNum) { + this.totalNum = totalNum; + } + + public String getAmtType() { + return this.amtType; + } + + public void setAmtType(String amtType) { + this.amtType = amtType; + } + + public String getWishing() { + return this.wishing; + } + + public void setWishing(String wishing) { + this.wishing = wishing; + } + + public String getClientIp() { + return this.clientIp; + } + + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } + + public String getActName() { + return this.actName; + } + + public void setActName(String actName) { + this.actName = actName; + } + + public String getRemark() { + return this.remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getWxAppid() { + return this.wxAppid; + } + + public void setWxAppid(String wxAppid) { + this.wxAppid = wxAppid; + } + + public String getMchId() { + return this.mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getNonceStr() { + return this.nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return this.sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getSceneId() { + return this.sceneId; + } + + public void setSceneId(String sceneId) { + this.sceneId = sceneId; + } + + public String getRiskInfo() { + return this.riskInfo; + } + + public void setRiskInfo(String riskInfo) { + this.riskInfo = riskInfo; + } + + public String getConsumeMchId() { + return this.consumeMchId; + } + + public void setConsumeMchId(String consumeMchId) { + this.consumeMchId = consumeMchId; + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java new file mode 100644 index 00000000..ccdfff90 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java @@ -0,0 +1,666 @@ +package me.chanjar.weixin.mp.bean.pay; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +import me.chanjar.weixin.common.annotation.Required; + +/** + *+ * 统一下单请求参数对象 + * 参考文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1 + * 每个字段描述对应如下: + *
+ * 公众账号ID + * appid + * 是 + * String(32) + * wxd678efh567hg6787 + * 微信分配的公众账号ID(企业号corpid即为此appId) + *+ */ + @XStreamAlias("appid") + private String appid; + + /** + *
+ * 商户号 + * mch_id + * 是 + * String(32) + * 1230000109 + * 微信支付分配的商户号 + *+ */ + @XStreamAlias("mch_id") + private String mchId; + + /** + *
+ * 设备号 + * device_info + * 否 + * String(32) + * 013467007045764 + * 终端设备号(门店号或收银设备Id),注意:PC网页或公众号内支付请传"WEB" + *+ */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
+ * 随机字符串 + * nonce_str + * 是 + * String(32) + * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS + * 随机字符串,不长于32位。推荐随机数生成算法 + *+ */ + @XStreamAlias("nonce_str") + private String nonceStr; + + /** + *
+ * 签名 + * sign + * 是 + * String(32) + * C380BEC2BFD727A4B6845133519F3AD6 + * 签名,详见签名生成算法 + *+ */ + @XStreamAlias("sign") + private String sign; + + /** + *
+ * 商品描述 + * body + * 是 + * String(128) + * 腾讯充值中心-QQ会员充值 + * 商品简单描述,该字段须严格按照规范传递,具体请见参数规定 + *+ */ + @Required + @XStreamAlias("body") + private String body; + + /** + *
+ * 商品详情 + * detail + * 否 + * String(6000) + * { "goods_detail":[ + { + "goods_id":"iphone6s_16G", + "wxpay_goods_id":"1001", + "goods_name":"iPhone6s 16G", + "goods_num":1, + "price":528800, + "goods_category":"123456", + "body":"苹果手机" + }, + { + "goods_id":"iphone6s_32G", + "wxpay_goods_id":"1002", + "goods_name":"iPhone6s 32G", + "quantity":1, + "price":608800, + "goods_category":"123789", + "body":"苹果手机" + } + ] + } + 商品详细列表,使用Json格式,传输签名前请务必使用CDATA标签将JSON文本串保护起来。 + goods_detail []: + └ goods_id String 必填 32 商品的编号 + └ wxpay_goods_id String 可选 32 微信支付定义的统一商品编号 + └ goods_name String 必填 256 商品名称 + └ goods_num Int 必填 商品数量 + └ price Int 必填 商品单价,单位为分 + └ goods_category String 可选 32 商品类目Id + └ body String 可选 1000 商品描述信息 + *+ */ + @XStreamAlias("detail") + private String detail; + + /** + *
+ * 附加数据 + * attach + * 否 + * String(127) + * 深圳分店 + * 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 + *+ */ + @XStreamAlias("attach") + private String attach; + + /** + *
+ * 商户订单号 + * out_trade_no + * 是 + * String(32) + * 20150806125346 + * 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 + *+ */ + @Required + @XStreamAlias("out_trade_no") + private String outTradeNo; + + /** + *
+ * 货币类型 + * fee_type + * 否 + * String(16) + * CNY + * 符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 + *+ */ + @XStreamAlias("fee_type") + private String feeType; + + /** + *
+ * 总金额 + * total_fee + * 是 + * Int + * 888 + * 订单总金额,单位为分,详见支付金额 + *+ */ + @Required + @XStreamAlias("total_fee") + private Integer totalFee; + + /** + *
+ * 终端IP + * spbill_create_ip + * 是 + * String(16) + * 123.12.12.123 + * APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。 + *+ */ + @Required + @XStreamAlias("spbill_create_ip") + private String spbillCreateIp; + + /** + *
+ * 交易起始时间 + * time_start + * 否 + * String(14) + * 20091225091010 + * 订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则 + *+ */ + @XStreamAlias("time_start") + private String timeStart; + + /** + *
+ * 交易结束时间 + * time_expire + * 否 + * String(14) + * 20091227091010 + * 订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则 + * 注意:最短失效时间间隔必须大于5分钟 + *+ */ + @XStreamAlias("time_expire") + private String timeExpire; + + /** + *
+ * 商品标记 + * goods_tag + * 否 + * String(32) + * WXG + * 商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠 + *+ */ + @XStreamAlias("goods_tag") + private String goodsTag; + + /** + *
+ * 通知地址 + * notify_url + * 是 + * String(256) + * http://www.weixin.qq.com/wxpay/pay.php + * 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。 + *+ */ + @Required + @XStreamAlias("notify_url") + private String notifyURL; + + /** + *
+ * 交易类型 + * trade_type + * 是 + * String(16) + * JSAPI + * 取值如下:JSAPI,NATIVE,APP,详细说明见参数规定: + * JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里 + *+ */ + @Required + @XStreamAlias("trade_type") + private String tradeType; + + /** + *
+ * 商品Id + * product_id + * 否 + * String(32) + * 12235413214070356458058 + * trade_type=NATIVE,此参数必传。此id为二维码中包含的商品Id,商户自行定义。 + *+ */ + @XStreamAlias("product_id") + private String productId; + + /** + *
+ * 指定支付方式 + * limit_pay + * 否 + * String(32) + * no_credit no_credit--指定不能使用信用卡支付 + *+ */ + @XStreamAlias("limit_pay") + private String limitPay; + + /** + *
+ * 用户标识 + * openid + * 否 + * String(128) + * oUpF8uMuAJO_M2pxb1Q9zNjWeS6o + * trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。 + * openid如何获取,可参考【获取openid】。 + * 企业号请使用【企业号OAuth2.0接口】获取企业号内成员userid,再调用【企业号userid转openid接口】进行转换 + *+ */ + @XStreamAlias("openid") + private String openid; + + public String getAppid() { + return this.appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getMchId() { + return this.mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getNonceStr() { + return this.nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return this.sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getBody() { + return this.body; + } + + public void setBody(String body) { + this.body = body; + } + + public String getDetail() { + return this.detail; + } + + public void setDetail(String detail) { + this.detail = detail; + } + + public String getAttach() { + return this.attach; + } + + public void setAttach(String attach) { + this.attach = attach; + } + + public String getOutTradeNo() { + return this.outTradeNo; + } + + public void setOutTradeNo(String outTradeNo) { + this.outTradeNo = outTradeNo; + } + + public String getFeeType() { + return this.feeType; + } + + public void setFeeType(String feeType) { + this.feeType = feeType; + } + + public Integer getTotalFee() { + return this.totalFee; + } + + public void setTotalFee(Integer totalFee) { + this.totalFee = totalFee; + } + + public String getSpbillCreateIp() { + return this.spbillCreateIp; + } + + public void setSpbillCreateIp(String spbillCreateIp) { + this.spbillCreateIp = spbillCreateIp; + } + + public String getTimeStart() { + return this.timeStart; + } + + public void setTimeStart(String timeStart) { + this.timeStart = timeStart; + } + + public String getTimeExpire() { + return this.timeExpire; + } + + public void setTimeExpire(String timeExpire) { + this.timeExpire = timeExpire; + } + + public String getGoodsTag() { + return this.goodsTag; + } + + public void setGoodsTag(String goodsTag) { + this.goodsTag = goodsTag; + } + + public String getNotifyURL() { + return this.notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + + public String getTradeType() { + return this.tradeType; + } + + public void setTradeType(String tradeType) { + this.tradeType = tradeType; + } + + public String getProductId() { + return this.productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public String getLimitPay() { + return this.limitPay; + } + + public void setLimitPay(String limitPay) { + this.limitPay = limitPay; + } + + public String getOpenid() { + return this.openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } + + public static WxUnifiedOrderRequestBuilder builder() { + return new WxUnifiedOrderRequestBuilder(); + } + + public static class WxUnifiedOrderRequestBuilder { + private String appid; + private String mchId; + private String deviceInfo; + private String nonceStr; + private String sign; + private String body; + private String detail; + private String attach; + private String outTradeNo; + private String feeType; + private Integer totalFee; + private String spbillCreateIp; + private String timeStart; + private String timeExpire; + private String goodsTag; + private String notifyURL; + private String tradeType; + private String productId; + private String limitPay; + private String openid; + + public WxUnifiedOrderRequestBuilder appid(String appid) { + this.appid = appid; + return this; + } + + public WxUnifiedOrderRequestBuilder mchId(String mchId) { + this.mchId = mchId; + return this; + } + + public WxUnifiedOrderRequestBuilder deviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + public WxUnifiedOrderRequestBuilder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public WxUnifiedOrderRequestBuilder sign(String sign) { + this.sign = sign; + return this; + } + + public WxUnifiedOrderRequestBuilder body(String body) { + this.body = body; + return this; + } + + public WxUnifiedOrderRequestBuilder detail(String detail) { + this.detail = detail; + return this; + } + + public WxUnifiedOrderRequestBuilder attach(String attach) { + this.attach = attach; + return this; + } + + public WxUnifiedOrderRequestBuilder outTradeNo(String outTradeNo) { + this.outTradeNo = outTradeNo; + return this; + } + + public WxUnifiedOrderRequestBuilder feeType(String feeType) { + this.feeType = feeType; + return this; + } + + public WxUnifiedOrderRequestBuilder totalFee(Integer totalFee) { + this.totalFee = totalFee; + return this; + } + + public WxUnifiedOrderRequestBuilder spbillCreateIp(String spbillCreateIp) { + this.spbillCreateIp = spbillCreateIp; + return this; + } + + public WxUnifiedOrderRequestBuilder timeStart(String timeStart) { + this.timeStart = timeStart; + return this; + } + + public WxUnifiedOrderRequestBuilder timeExpire(String timeExpire) { + this.timeExpire = timeExpire; + return this; + } + + public WxUnifiedOrderRequestBuilder goodsTag(String goodsTag) { + this.goodsTag = goodsTag; + return this; + } + + public WxUnifiedOrderRequestBuilder notifyURL(String notifyURL) { + this.notifyURL = notifyURL; + return this; + } + + public WxUnifiedOrderRequestBuilder tradeType(String tradeType) { + this.tradeType = tradeType; + return this; + } + + public WxUnifiedOrderRequestBuilder productId(String productId) { + this.productId = productId; + return this; + } + + public WxUnifiedOrderRequestBuilder limitPay(String limitPay) { + this.limitPay = limitPay; + return this; + } + + public WxUnifiedOrderRequestBuilder openid(String openid) { + this.openid = openid; + return this; + } + + public WxUnifiedOrderRequestBuilder from(WxUnifiedOrderRequest origin) { + this.appid(origin.appid); + this.mchId(origin.mchId); + this.deviceInfo(origin.deviceInfo); + this.nonceStr(origin.nonceStr); + this.sign(origin.sign); + this.body(origin.body); + this.detail(origin.detail); + this.attach(origin.attach); + this.outTradeNo(origin.outTradeNo); + this.feeType(origin.feeType); + this.totalFee(origin.totalFee); + this.spbillCreateIp(origin.spbillCreateIp); + this.timeStart(origin.timeStart); + this.timeExpire(origin.timeExpire); + this.goodsTag(origin.goodsTag); + this.notifyURL(origin.notifyURL); + this.tradeType(origin.tradeType); + this.productId(origin.productId); + this.limitPay(origin.limitPay); + this.openid(origin.openid); + return this; + } + + public WxUnifiedOrderRequest build() { + WxUnifiedOrderRequest m = new WxUnifiedOrderRequest(); + m.appid = this.appid; + m.mchId = this.mchId; + m.deviceInfo = this.deviceInfo; + m.nonceStr = this.nonceStr; + m.sign = this.sign; + m.body = this.body; + m.detail = this.detail; + m.attach = this.attach; + m.outTradeNo = this.outTradeNo; + m.feeType = this.feeType; + m.totalFee = this.totalFee; + m.spbillCreateIp = this.spbillCreateIp; + m.timeStart = this.timeStart; + m.timeExpire = this.timeExpire; + m.goodsTag = this.goodsTag; + m.notifyURL = this.notifyURL; + m.tradeType = this.tradeType; + m.productId = this.productId; + m.limitPay = this.limitPay; + m.openid = this.openid; + return m; + } + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java new file mode 100644 index 00000000..18817461 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java @@ -0,0 +1,155 @@ +package me.chanjar.weixin.mp.bean.pay; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + *
+ * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果 + * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) + *+ * + * @author chanjarster + */ +@XStreamAlias("xml") +public class WxUnifiedOrderResult { + + @XStreamAlias("return_code") + private String returnCode; + + @XStreamAlias("return_msg") + private String returnMsg; + + @XStreamAlias("appid") + private String appid; + + @XStreamAlias("mch_id") + private String mchId; + + @XStreamAlias("nonce_str") + private String nonceStr; + + @XStreamAlias("sign") + private String sign; + + @XStreamAlias("result_code") + private String resultCode; + + @XStreamAlias("prepay_id") + private String prepayId; + + @XStreamAlias("trade_type") + private String tradeType; + + @XStreamAlias("err_code") + private String errCode; + + @XStreamAlias("err_code_des") + private String errCodeDes; + + @XStreamAlias("code_url") + private String codeURL; + + public String getReturnCode() { + return this.returnCode; + } + + public void setReturnCode(String returnCode) { + this.returnCode = returnCode; + } + + public String getReturnMsg() { + return this.returnMsg; + } + + public void setReturnMsg(String returnMsg) { + this.returnMsg = returnMsg; + } + + public String getAppid() { + return this.appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getMchId() { + return this.mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getNonceStr() { + return this.nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return this.sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getResultCode() { + return this.resultCode; + } + + public void setResultCode(String resultCode) { + this.resultCode = resultCode; + } + + public String getPrepayId() { + return this.prepayId; + } + + public void setPrepayId(String prepayId) { + this.prepayId = prepayId; + } + + public String getTradeType() { + return this.tradeType; + } + + public void setTradeType(String tradeType) { + this.tradeType = tradeType; + } + + public String getErrCode() { + return this.errCode; + } + + public void setErrCode(String errCode) { + this.errCode = errCode; + } + + public String getErrCodeDes() { + return this.errCodeDes; + } + + public void setErrCodeDes(String errCodeDes) { + this.errCodeDes = errCodeDes; + } + + public String getCodeURL() { + return this.codeURL; + } + + public void setCodeURL(String codeURL) { + this.codeURL = codeURL; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpPrepayIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpPrepayIdResult.java deleted file mode 100644 index e930fc13..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpPrepayIdResult.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.chanjar.weixin.mp.bean.result; - -import java.io.Serializable; - -/** - *
- * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果 - * - * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) - * - *- * - * @author chanjarster - */ -public class WxMpPrepayIdResult implements Serializable { - /** - * - */ - private static final long serialVersionUID = -8970574397788396143L; - private String return_code; - private String return_msg; - private String appid; - private String mch_id; - private String nonce_str; - private String sign; - private String result_code; - private String prepay_id; - private String trade_type; - private String err_code; - private String err_code_des; - private String code_url; - - public String getReturn_code() { - return this.return_code; - } - - public void setReturn_code(String return_code) { - this.return_code = return_code; - } - - public String getReturn_msg() { - return this.return_msg; - } - - public void setReturn_msg(String return_msg) { - this.return_msg = return_msg; - } - - public String getAppid() { - return this.appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMch_id() { - return this.mch_id; - } - - public void setMch_id(String mch_id) { - this.mch_id = mch_id; - } - - public String getNonce_str() { - return this.nonce_str; - } - - public void setNonce_str(String nonce_str) { - this.nonce_str = nonce_str; - } - - public String getSign() { - return this.sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getResult_code() { - return this.result_code; - } - - public void setResult_code(String result_code) { - this.result_code = result_code; - } - - public String getPrepay_id() { - return this.prepay_id; - } - - public void setPrepay_id(String prepay_id) { - this.prepay_id = prepay_id; - } - - public String getTrade_type() { - return this.trade_type; - } - - public void setTrade_type(String trade_type) { - this.trade_type = trade_type; - } - - public String getErr_code() { - return this.err_code; - } - - public void setErr_code(String err_code) { - this.err_code = err_code; - } - - public String getErr_code_des() { - return this.err_code_des; - } - - public void setErr_code_des(String err_code_des) { - this.err_code_des = err_code_des; - } - - public String getCode_url() { - return this.code_url; - } - - public void setCode_url(String code_url) { - this.code_url = code_url; - } -} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java new file mode 100644 index 00000000..06a5b178 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java @@ -0,0 +1,560 @@ +package me.chanjar.weixin.mp.bean.store; + +import java.math.BigDecimal; +import java.util.List; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.annotations.SerializedName; + +import me.chanjar.weixin.common.annotation.Required; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +/** + * 门店基础信息 + * @author binarywang(https://github.com/binarywang) + * Created by Binary Wang on 2016-09-23. + */ +public class WxMpStoreBaseInfo { + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } + + public String toJson() { + JsonElement base_info = WxMpGsonBuilder.create().toJsonTree(this); + JsonObject jsonObject = new JsonObject(); + jsonObject.add("base_info", base_info); + JsonObject business = new JsonObject(); + business.add("business", jsonObject); + return business.toString(); + } + + public static class WxMpStorePhoto { + /** + * 照片url + */ + @SerializedName("photo_url") + private String photoUrl; + } + + /** + * sid + * 商户自己的id,用于后续审核通过收到poi_id 的通知时,做对应关系。请商户自己保证唯一识别性 + */ + @SerializedName("sid") + private String sid; + + /** + * business_name + * 门店名称(仅为商户名,如:国美、麦当劳,不应包含地区、地址、分店名等信息,错误示例:北京国美) + * 不能为空,15个汉字或30个英文字符内 + */ + @Required + @SerializedName("business_name") + private String businessName; + + /** + * branch_name + * 分店名称(不应包含地区信息,不应与门店名有重复,错误示例:北京王府井店) + * 10个字以内 + */ + @Required + @SerializedName("branch_name") + private String branchName; + + /** + * province + * 门店所在的省份(直辖市填城市名,如:北京市) + * 10个字以内 + */ + @Required + @SerializedName("province") + private String province; + + /** + * city + * 门店所在的城市 + * 10个字以内 + */ + @Required + @SerializedName("city") + private String city; + + /** + * district + * 门店所在地区 + * 10个字以内 + */ + @Required + @SerializedName("district") + private String district; + + /** + * address + * 门店所在的详细街道地址(不要填写省市信息) + * (东莞等没有“区”行政区划的城市,该字段可不必填写。其余城市必填。) + */ + @Required + @SerializedName("address") + private String address; + + /** + * telephone + * 门店的电话(纯数字,区号、分机号均由“-”隔开) + */ + @Required + @SerializedName("telephone") + private String telephone; + + /** + * categories + * 门店的类型(不同级分类用“,”隔开,如:美食,川菜,火锅。详细分类参见附件:微信门店类目表) + */ + @Required + @SerializedName("categories") + private String[] categories; + + /** + * offsetType + * 坐标类型,1 为火星坐标(目前只能选1) + */ + @Required + @SerializedName("offset_type") + private Integer offsetType = 1; + + /** + * longitude + * 门店所在地理位置的经度 + */ + @Required + @SerializedName("longitude") + private BigDecimal longitude; + + /** + * latitude + * 门店所在地理位置的纬度(经纬度均为火星坐标,最好选用腾讯地图标记的坐标) + */ + @Required + @SerializedName("latitude") + private BigDecimal latitude; + + /** + * photo_list + * 图片列表,url 形式,可以有多张图片,尺寸为 640*340px。必须为上一接口生成的url。 + * 图片内容不允许与门店不相关,不允许为二维码、员工合照(或模特肖像)、营业执照、无门店正门的街景、地图截图、公交地铁站牌、菜单截图等 + */ + @SerializedName("photo_list") + private List