mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-20 02:29:44 +08:00
#900 增加新增团购券、现金抵扣券、折扣券、兑换券以及普通优惠券的接口
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||
import me.chanjar.weixin.open.bean.WxOpenCreateResult;
|
||||
import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate;
|
||||
import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
|
||||
@@ -42,6 +43,8 @@ public interface WxOpenComponentService {
|
||||
|
||||
String MINIAPP_JSCODE_2_SESSION = "https://api.weixin.qq.com/sns/component/jscode2session?appid=%s&js_code=%s&grant_type=authorization_code&component_appid=%s";
|
||||
|
||||
String CREATE_OPEN_URL= "https://api.weixin.qq.com/cgi-bin/open/create";
|
||||
|
||||
WxMpService getWxMpServiceByAppid(String appid);
|
||||
|
||||
/**
|
||||
@@ -168,4 +171,15 @@ public interface WxOpenComponentService {
|
||||
* @see #getTemplateList
|
||||
*/
|
||||
void deleteTemplate(long templateId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1498704199_1bcax&token=6df5e3650041eff2cd3ec3662425ad8d7beec8d9&lang=zh_CN
|
||||
* 创建 开放平台帐号并绑定公众号/小程序
|
||||
*
|
||||
* https://api.weixin.qq.com/cgi-bin/open/create
|
||||
*
|
||||
* @param appId 公众号/小程序的appId
|
||||
* @return
|
||||
*/
|
||||
WxOpenCreateResult createOpenAccount(String appId) throws WxErrorException;
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import me.chanjar.weixin.open.api.WxOpenMaService;
|
||||
import me.chanjar.weixin.open.api.WxOpenService;
|
||||
import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
|
||||
import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
|
||||
import me.chanjar.weixin.open.bean.WxOpenCreateResult;
|
||||
import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate;
|
||||
import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
|
||||
import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
|
||||
@@ -387,4 +388,14 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
param.addProperty("template_id", templateId);
|
||||
post(DELETE_TEMPLATE_URL, param.toString(), "access_token");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenCreateResult createOpenAccount(String appId) throws WxErrorException {
|
||||
JsonObject param = new JsonObject();
|
||||
param.addProperty("appid", appId);
|
||||
|
||||
String json = post(CREATE_OPEN_URL, param.toString(), "access_token");
|
||||
|
||||
return WxOpenCreateResult.fromJson(json);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,36 @@
|
||||
package me.chanjar.weixin.open.bean;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* code换取session_key接口的响应
|
||||
* 文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-login.html#wxloginobject
|
||||
* 微信返回报文:{"session_key":"nzoqhc3OnwHzeTxJs+inbQ==","openid":"oVBkZ0aYgDMDIywRdgPW8-joxXc4"}
|
||||
* </pre>
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class WxOpenCreateResult implements Serializable {
|
||||
|
||||
@SerializedName("open_appid")
|
||||
private String openAppid;
|
||||
|
||||
@SerializedName("errcode")
|
||||
private String errcode;
|
||||
|
||||
@SerializedName("errmsg")
|
||||
private String errmsg;
|
||||
|
||||
public static WxOpenCreateResult fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxOpenCreateResult.class);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user