mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-03 20:27:46 +08:00
🎨 统一抽取errcode常量,同步优化规范部分代码
This commit is contained in:
parent
54d1b92156
commit
0affa26790
@ -1,5 +1,7 @@
|
||||
package me.chanjar.weixin.common.api;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -12,6 +14,7 @@ import static me.chanjar.weixin.common.error.WxMpErrorMsgEnum.*;
|
||||
*
|
||||
* @author Daniel Qian & binarywang & Wang_Wong
|
||||
*/
|
||||
@UtilityClass
|
||||
public class WxConsts {
|
||||
/**
|
||||
* access_token 相关错误代码
|
||||
@ -25,9 +28,15 @@ public class WxConsts {
|
||||
public static final List<Integer> ACCESS_TOKEN_ERROR_CODES = Arrays.asList(CODE_40001.getCode(),
|
||||
CODE_40014.getCode(), CODE_42001.getCode());
|
||||
|
||||
/**
|
||||
* 微信接口返回的参数errcode.
|
||||
*/
|
||||
public static final String ERR_CODE = "errcode";
|
||||
|
||||
/**
|
||||
* 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class XmlMsgType {
|
||||
public static final String TEXT = "text";
|
||||
public static final String IMAGE = "image";
|
||||
@ -51,6 +60,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 主动发送消息(即客服消息)的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class KefuMsgType {
|
||||
/**
|
||||
* 文本消息.
|
||||
@ -137,6 +147,7 @@ public class WxConsts {
|
||||
* 发送「学校通知」类型
|
||||
* https://developer.work.weixin.qq.com/document/path/92321
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class SchoolContactMsgType {
|
||||
|
||||
/**
|
||||
@ -184,6 +195,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 企业微信模板卡片消息的卡片类型
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class TemplateCardType {
|
||||
/**
|
||||
* 文本通知型卡片
|
||||
@ -210,6 +222,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 表示是否是保密消息,0表示否,1表示是,默认0.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class KefuMsgSafe {
|
||||
public static final String NO = "0";
|
||||
public static final String YES = "1";
|
||||
@ -218,6 +231,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 群发消息的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class MassMsgType {
|
||||
public static final String MPNEWS = "mpnews";
|
||||
public static final String TEXT = "text";
|
||||
@ -230,6 +244,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 群发消息后微信端推送给服务器的反馈消息.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class MassMsgStatus {
|
||||
public static final String SEND_SUCCESS = "send success";
|
||||
public static final String SEND_FAIL = "send fail";
|
||||
@ -277,6 +292,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 微信端推送过来的事件类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class EventType {
|
||||
public static final String SUBSCRIBE = "subscribe";
|
||||
public static final String UNSUBSCRIBE = "unsubscribe";
|
||||
@ -417,7 +433,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 小程序自定义交易组件支付通知
|
||||
*/
|
||||
public static final String OPEN_PRODUCT_ORDER_PAY = "open_product_order_pay";
|
||||
public static final String OPEN_PRODUCT_ORDER_PAY = "open_product_order_pay";
|
||||
/**
|
||||
* 点击菜单跳转小程序的事件推送
|
||||
*/
|
||||
@ -453,6 +469,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 自定义菜单的按钮类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class MenuButtonType {
|
||||
/**
|
||||
* 点击推事件.
|
||||
@ -503,6 +520,7 @@ public class WxConsts {
|
||||
/**
|
||||
* oauth2网页授权的scope.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class OAuth2Scope {
|
||||
/**
|
||||
* 不弹出授权页面,直接跳转,只能获取用户openid.
|
||||
@ -523,6 +541,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 网页应用登录授权作用域.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class QrConnectScope {
|
||||
public static final String SNSAPI_LOGIN = "snsapi_login";
|
||||
}
|
||||
@ -530,6 +549,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 永久素材类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class MaterialType {
|
||||
public static final String NEWS = "news";
|
||||
public static final String VOICE = "voice";
|
||||
@ -541,6 +561,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 网络检测入参.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class NetCheckArgs {
|
||||
public static final String ACTIONDNS = "dns";
|
||||
public static final String ACTIONPING = "ping";
|
||||
@ -554,6 +575,7 @@ public class WxConsts {
|
||||
/**
|
||||
* appId 类型
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class AppIdType {
|
||||
/**
|
||||
* 公众号appId类型
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.common.bean.result;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -17,7 +18,7 @@ public class WxMinishopImageUploadCustomizeResult implements Serializable {
|
||||
public static WxMinishopImageUploadCustomizeResult fromJson(String json) {
|
||||
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
|
||||
WxMinishopImageUploadCustomizeResult result = new WxMinishopImageUploadCustomizeResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsNumber().toString());
|
||||
result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
|
||||
if (result.getErrcode().equals("0")) {
|
||||
WxMinishopPicFileCustomizeResult picFileResult = new WxMinishopPicFileCustomizeResult();
|
||||
JsonObject picObject = jsonObject.get("img_info").getAsJsonObject();
|
||||
|
@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -22,7 +23,7 @@ public class WxMinishopImageUploadResult implements Serializable {
|
||||
public static WxMinishopImageUploadResult fromJson(String json) {
|
||||
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
|
||||
WxMinishopImageUploadResult result = new WxMinishopImageUploadResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsNumber().toString());
|
||||
result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
|
||||
if (result.getErrcode().equals("0")) {
|
||||
WxMinishopPicFileResult picFileResult = new WxMinishopPicFileResult();
|
||||
JsonObject picObject = jsonObject.get("pic_file").getAsJsonObject();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.common.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@ -16,8 +17,8 @@ public class WxErrorAdapter implements JsonDeserializer<WxError> {
|
||||
WxError.WxErrorBuilder errorBuilder = WxError.builder();
|
||||
JsonObject wxErrorJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (wxErrorJsonObject.get("errcode") != null && !wxErrorJsonObject.get("errcode").isJsonNull()) {
|
||||
errorBuilder.errorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode")));
|
||||
if (wxErrorJsonObject.get(WxConsts.ERR_CODE) != null && !wxErrorJsonObject.get(WxConsts.ERR_CODE).isJsonNull()) {
|
||||
errorBuilder.errorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get(WxConsts.ERR_CODE)));
|
||||
}
|
||||
if (wxErrorJsonObject.get("errmsg") != null && !wxErrorJsonObject.get("errmsg").isJsonNull()) {
|
||||
errorBuilder.errorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg")));
|
||||
|
@ -3,6 +3,7 @@ package me.chanjar.weixin.cp.api.impl;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -46,7 +47,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_SET);
|
||||
String responseContent = this.mainService.post(url, agentInfo.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP));
|
||||
}
|
||||
}
|
||||
@ -56,7 +57,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_LIST);
|
||||
String responseContent = this.mainService.get(url, null);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP));
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
@ -163,7 +164,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
"type=agent_config&access_token=" + this.configStorage.getAccessToken(authCorpId), true);
|
||||
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get("errcode").getAsInt() == 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
String jsApiTicket = jsonObject.get("ticket").getAsString();
|
||||
int expiredInSeconds = jsonObject.get("expires_in").getAsInt();
|
||||
synchronized (globalJsApiTicketRefreshLock) {
|
||||
@ -193,7 +194,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
"access_token=" + this.configStorage.getAccessToken(authCorpId), true);
|
||||
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get("errcode").getAsInt() == 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
String jsApiTicket = jsonObject.get("ticket").getAsString();
|
||||
int expiredInSeconds = jsonObject.get("expires_in").getAsInt();
|
||||
|
||||
|
@ -4,7 +4,6 @@ import cn.binarywang.wx.miniapp.api.WxMaCloudService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.cloud.*;
|
||||
import cn.binarywang.wx.miniapp.bean.cloud.request.WxCloudSendSmsV2Request;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import cn.binarywang.wx.miniapp.util.JoinerUtils;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@ -14,6 +13,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
@ -65,7 +65,7 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
|
||||
|
||||
String responseContent = wxMaService.post(DATABASE_ADD_URL, params.toString());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent));
|
||||
}
|
||||
JsonArray idArray = jsonObject.getAsJsonArray("id_list");
|
||||
@ -89,7 +89,7 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
|
||||
|
||||
String responseContent = wxMaService.post(DATABASE_ADD_URL, params.toString());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent));
|
||||
}
|
||||
JsonArray idArray = jsonObject.getAsJsonArray("id_list");
|
||||
@ -120,7 +120,7 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
|
||||
|
||||
String responseContent = wxMaService.post(DATABASE_DELETE_URL, params.toString());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent));
|
||||
}
|
||||
return jsonObject.get("deleted").getAsInt();
|
||||
|
@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.device.WxMaDeviceTicketRequest;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -32,7 +33,7 @@ public class WxMaDeviceSubscribeServiceImpl implements WxMaDeviceSubscribeServic
|
||||
public String getSnTicket(WxMaDeviceTicketRequest deviceTicketRequest) throws WxErrorException {
|
||||
String responseContent = this.service.post(GET_SN_TICKET_URL, deviceTicketRequest.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
String snTicket = jsonObject.get("sn_ticket").getAsString();
|
||||
@ -43,7 +44,7 @@ public class WxMaDeviceSubscribeServiceImpl implements WxMaDeviceSubscribeServic
|
||||
public void sendDeviceSubscribeMsg(WxMaDeviceSubscribeMessageRequest deviceSubscribeMessageRequest) throws WxErrorException {
|
||||
String responseContent = this.service.post(SEND_DEVICE_SUBSCRIBE_MSG_URL, deviceSubscribeMessageRequest.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* 微信小程序即时配送服务.
|
||||
* <pre>
|
||||
@ -49,11 +51,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
@RequiredArgsConstructor
|
||||
public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliveryService {
|
||||
|
||||
/**
|
||||
* 微信响应码.
|
||||
*/
|
||||
public static final String ERR_CODE = "errcode";
|
||||
|
||||
/**
|
||||
* 顺丰同城响应码.
|
||||
*/
|
||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@ -30,7 +31,6 @@ import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Ro
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class WxMaLiveServiceImpl implements WxMaLiveService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private static final String ROOM_ID = "roomId";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
|
@ -10,6 +10,7 @@ import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -34,7 +35,7 @@ public class WxMaMsgServiceImpl implements WxMaMsgService {
|
||||
public void sendSubscribeMsg(WxMaSubscribeMessage subscribeMessage) throws WxErrorException {
|
||||
String responseContent = this.service.post(SUBSCRIBE_MSG_SEND_URL, subscribeMessage.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
}
|
||||
@ -43,7 +44,7 @@ public class WxMaMsgServiceImpl implements WxMaMsgService {
|
||||
public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException {
|
||||
String responseContent = this.service.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_GET_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_LISTING_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_UPDATE_URL;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaProductService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
@ -51,6 +52,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
@ -68,8 +70,6 @@ import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
@ -143,7 +143,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
result.setErrcode(respObj.get(ERR_CODE).getAsInt());
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
|
||||
resultData.setProductId(dataObj.get("product_id").getAsLong());
|
||||
@ -201,7 +201,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
result.setErrcode(respObj.get(ERR_CODE).getAsInt());
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
|
||||
resultData.setProductId(dataObj.get("product_id").getAsLong());
|
||||
@ -260,7 +260,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
|
||||
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
|
||||
resultData.setSkuId(dataObj.get("sku_id").getAsLong());
|
||||
@ -280,7 +280,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
}
|
||||
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
|
||||
JsonArray jsonArray = jsonObject.get("data").getAsJsonArray();
|
||||
List<WxMinishopAddGoodsSkuData> skuData = new ArrayList<>();
|
||||
for (JsonElement jsonElement : jsonArray) {
|
||||
@ -318,7 +318,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
|
||||
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
|
||||
WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
|
||||
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
|
||||
@ -340,7 +340,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
}
|
||||
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
|
||||
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
|
||||
WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
|
||||
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
|
||||
@ -362,7 +362,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
}
|
||||
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
result.setErrcode(jsonObject.get(ERR_CODE).getAsInt());
|
||||
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
|
||||
WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
|
||||
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
|
||||
|
@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankRespo
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -27,7 +28,7 @@ public class WxMaSafetyRiskControlServiceImpl implements WxMaSafetyRiskControlSe
|
||||
public WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException {
|
||||
String responseContent = this.service.post(GET_USER_RISK_RANK, wxMaUserSafetyRiskRankRequest.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaUserSafetyRiskRankResponse.fromJson(responseContent);
|
||||
|
@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -18,14 +19,13 @@ import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Scheme.GENER
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class WxMaSchemeServiceImpl implements WxMaSchemeService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public String generate(WxMaGenerateSchemeRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GENERATE_SCHEME_URL, request.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return jsonObject.get("openlink").getAsString();
|
||||
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.SecCheck.*;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@ -93,7 +93,7 @@ public class WxMaSecCheckServiceImpl implements WxMaSecCheckService {
|
||||
|
||||
private void parseErrorResponse(String response) throws WxErrorException {
|
||||
JsonObject jsonObject = GsonParser.parse(response);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -24,14 +25,13 @@ import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Account
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_CATEGORY_LIST, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetCategoryListResponse.class);
|
||||
@ -41,7 +41,7 @@ public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
|
||||
public WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_BRAND_LIST, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetBrandListResponse.class);
|
||||
@ -51,7 +51,7 @@ public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
|
||||
public WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(UPDATE_INFO, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
|
||||
@ -61,7 +61,7 @@ public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
|
||||
public WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_INFO, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetInfoResponse.class);
|
||||
|
@ -15,7 +15,7 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Aftersale.*;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* @author boris
|
||||
@ -38,7 +38,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
public WxMaShopAfterSaleAddResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(AFTERSALE_ADD, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleAddResponse.class);
|
||||
@ -55,7 +55,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
public WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(AFTERSALE_GET, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleGetResponse.class);
|
||||
@ -72,7 +72,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
public WxMaShopEcAfterSaleGetResponse get(WxMaShopEcAfterSaleGetRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(ECAFTERSALE_GET, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopEcAfterSaleGetResponse.class);
|
||||
@ -89,7 +89,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
public WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(AFTERSALE_UPDATE, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
|
||||
@ -99,7 +99,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
public WxMaShopBaseResponse update(WxMaShopEcAfterSaleUpdateRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(EC_AFTERSALE_UPDATE, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
|
||||
@ -120,7 +120,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
"aftersale_id", afterSaleId, "openid", openId);
|
||||
String resp = this.wxMaService.post(AFTERSALE_CANCEL, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -137,7 +137,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
throws WxErrorException {
|
||||
String resp = this.wxMaService.post(AFTERSALE_UPLOAD_RETURN_INFO, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -157,7 +157,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
"aftersale_id", afterSaleId);
|
||||
String resp = this.wxMaService.post(AFTERSALE_ACCEPT_REFUND, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -174,7 +174,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
throws WxErrorException {
|
||||
String resp = this.wxMaService.post(AFTERSALE_ACCEPT_RETURN, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -194,7 +194,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
"aftersale_id", afterSaleId);
|
||||
String resp = this.wxMaService.post(AFTERSALE_REJECT, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -211,7 +211,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
throws WxErrorException {
|
||||
String resp = this.wxMaService.post(AFTERSALE_UPLOAD_CERTIFICATES, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -233,7 +233,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
"order_id", orderId, "openid", openid, "after_sale_deadline", afterSaleDeadline);
|
||||
String resp = this.wxMaService.post(AFTERSALE_UPLOAD_DEADLINE, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
|
||||
@ -249,7 +249,7 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
|
||||
public WxMaShopAfterSaleListResponse list(WxMaShopAfterSaleListRequest request) throws WxErrorException {
|
||||
String resp = this.wxMaService.post(AFTERSALE_GET_LIST, request);
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopAfterSaleListResponse.class);
|
||||
|
@ -18,7 +18,7 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Audit.*;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* 小程序交易组件-接入商品前必需接口(审核相关接口)
|
||||
@ -42,7 +42,7 @@ public class WxMaShopAuditServiceImpl implements WxMaShopAuditService {
|
||||
public WxMaShopAuditBrandResponse auditBrand(WxMaShopAuditBrandRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(AUDIT_BRAND, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditBrandResponse.class);
|
||||
@ -59,7 +59,7 @@ public class WxMaShopAuditServiceImpl implements WxMaShopAuditService {
|
||||
public WxMaShopAuditCategoryResponse auditCategory(WxMaShopAuditCategoryRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(AUDIT_CATEGORY, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditCategoryResponse.class);
|
||||
@ -76,7 +76,7 @@ public class WxMaShopAuditServiceImpl implements WxMaShopAuditService {
|
||||
public WxMaShopAuditResultResponse getAuditResult(String auditId) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(AUDIT_RESULT, GsonHelper.buildJsonObject("audit_id", auditId));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditResultResponse.class);
|
||||
@ -93,7 +93,7 @@ public class WxMaShopAuditServiceImpl implements WxMaShopAuditService {
|
||||
public JsonObject getMiniappCertificate(int reqType) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_MINIAPP_CERTIFICATE, GsonHelper.buildJsonObject("req_type", reqType));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, JsonObject.class);
|
||||
|
@ -13,7 +13,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Cat.GET_CAT;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
@ -27,7 +27,7 @@ public class WxMaShopCatServiceImpl implements WxMaShopCatService {
|
||||
public WxMaShopCatGetResponse getCat() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_CAT, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCatGetResponse.class);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.api.impl.WxMaImmediateDeliveryServiceImpl.ERR_CODE;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopCouponService;
|
||||
@ -20,6 +19,8 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* @author leiin
|
||||
* created on 2022/7/1 2:49 下午
|
||||
@ -100,7 +101,7 @@ public class WxMaShopCouponServiceImpl implements WxMaShopCouponService {
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse addUserCoupon(String openid, String outUserCouponId,
|
||||
String outCouponId, Integer status, Long recvTime) throws WxErrorException {
|
||||
String outCouponId, Integer status, Long recvTime) throws WxErrorException {
|
||||
JsonObject userCoupon = GsonHelper.buildJsonObject("out_user_coupon_id", outUserCouponId,
|
||||
"out_coupon_id", outCouponId,
|
||||
"status", status);
|
||||
@ -129,7 +130,7 @@ public class WxMaShopCouponServiceImpl implements WxMaShopCouponService {
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse updateUserCoupon(String openid, String outUserCouponId,
|
||||
String outCouponId, Long useTime, Long recvTime) throws WxErrorException {
|
||||
String outCouponId, Long useTime, Long recvTime) throws WxErrorException {
|
||||
JsonObject extInfo = GsonHelper.buildJsonObject("use_time", useTime);
|
||||
|
||||
JsonObject userCoupon = GsonHelper.buildJsonObject("out_user_coupon_id", outUserCouponId,
|
||||
@ -148,7 +149,7 @@ public class WxMaShopCouponServiceImpl implements WxMaShopCouponService {
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse updateUserCouponStatus(String openid, String outUserCouponId,
|
||||
String outCouponId, Integer status) throws WxErrorException {
|
||||
String outCouponId, Integer status) throws WxErrorException {
|
||||
|
||||
JsonObject json = GsonHelper.buildJsonObject("openid", openid,
|
||||
"out_user_coupon_id", outUserCouponId,
|
||||
|
@ -16,7 +16,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Delivery.*;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* @author boris
|
||||
@ -37,7 +37,7 @@ public class WxMaShopDeliveryServiceImpl implements WxMaShopDeliveryService {
|
||||
public WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_COMPANY_LIST, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopDeliveryGetCompanyListResponse.class);
|
||||
@ -54,7 +54,7 @@ public class WxMaShopDeliveryServiceImpl implements WxMaShopDeliveryService {
|
||||
public WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(DELIVERY_SEND, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
|
||||
@ -71,7 +71,7 @@ public class WxMaShopDeliveryServiceImpl implements WxMaShopDeliveryService {
|
||||
public WxMaShopBaseResponse receive(WxMaShopDeliveryRecieveRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(DELIVERY_RECEIVE, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
|
||||
|
@ -20,6 +20,7 @@ import java.text.Format;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Order.*;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* @author boris
|
||||
@ -30,7 +31,6 @@ public class WxMaShopOrderServiceImpl implements WxMaShopOrderService {
|
||||
|
||||
private final Format dateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private static final String MATCH_KEY = "is_matched";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Sharer;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopSharerService;
|
||||
@ -28,7 +29,6 @@ import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopSharerServiceImpl implements WxMaShopSharerService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.*;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
||||
|
||||
/**
|
||||
* @author boris
|
||||
@ -27,8 +28,6 @@ import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.*;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopSpuServiceImpl implements WxMaShopSpuService {
|
||||
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package cn.binarywang.wx.miniapp.api.impl;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.subscribemsg.CategoryData;
|
||||
import me.chanjar.weixin.common.bean.subscribemsg.PubTemplateKeyword;
|
||||
import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
|
||||
@ -85,7 +86,7 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService {
|
||||
public void sendSubscribeMsg(WxMaSubscribeMessage subscribeMessage) throws WxErrorException {
|
||||
String responseContent = this.service.post(SUBSCRIBE_MSG_SEND_URL, subscribeMessage.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.binarywang.wx.miniapp.constant;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 小程序常量.
|
||||
@ -7,24 +9,19 @@ package cn.binarywang.wx.miniapp.constant;
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public abstract class WxMaConstants {
|
||||
private WxMaConstants() {
|
||||
}
|
||||
@UtilityClass
|
||||
public class WxMaConstants {
|
||||
|
||||
/**
|
||||
* 默认的env_version值
|
||||
*/
|
||||
public static final String DEFAULT_ENV_VERSION = "release";
|
||||
|
||||
/**
|
||||
* 微信接口返回的参数errcode.
|
||||
*/
|
||||
public static final String ERRCODE = "errcode";
|
||||
|
||||
/**
|
||||
* 素材类型.
|
||||
*/
|
||||
public abstract static class MediaType {
|
||||
@UtilityClass
|
||||
public static class MediaType {
|
||||
/**
|
||||
* 图片.
|
||||
*/
|
||||
@ -34,7 +31,8 @@ public abstract class WxMaConstants {
|
||||
/**
|
||||
* 消息格式.
|
||||
*/
|
||||
public abstract static class MsgDataFormat {
|
||||
@UtilityClass
|
||||
public static class MsgDataFormat {
|
||||
public static final String XML = "XML";
|
||||
public static final String JSON = "JSON";
|
||||
}
|
||||
@ -42,6 +40,7 @@ public abstract class WxMaConstants {
|
||||
/**
|
||||
* 客服消息的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class KefuMsgType {
|
||||
/**
|
||||
* 文本消息.
|
||||
@ -64,8 +63,8 @@ public abstract class WxMaConstants {
|
||||
/**
|
||||
* 内容安全检测的媒体类型
|
||||
*/
|
||||
@UtilityClass
|
||||
public static final class SecCheckMediaType {
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
@ -80,6 +79,7 @@ public abstract class WxMaConstants {
|
||||
/**
|
||||
* 快递账号绑定类型
|
||||
*/
|
||||
@UtilityClass
|
||||
public static final class BindAccountType {
|
||||
|
||||
/**
|
||||
@ -96,6 +96,7 @@ public abstract class WxMaConstants {
|
||||
/**
|
||||
* 快递下单订单来源
|
||||
*/
|
||||
@UtilityClass
|
||||
public static final class OrderAddSource {
|
||||
|
||||
/**
|
||||
@ -112,11 +113,8 @@ public abstract class WxMaConstants {
|
||||
/**
|
||||
* 快递下单保价
|
||||
*/
|
||||
@UtilityClass
|
||||
public static final class OrderAddInsured {
|
||||
private OrderAddInsured() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 不保价
|
||||
*/
|
||||
@ -138,10 +136,8 @@ public abstract class WxMaConstants {
|
||||
* <p>
|
||||
* developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
*/
|
||||
@UtilityClass
|
||||
public static final class MiniProgramState {
|
||||
private MiniProgramState() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 开发版
|
||||
*/
|
||||
@ -163,10 +159,8 @@ public abstract class WxMaConstants {
|
||||
* 进入小程序查看的语言类型
|
||||
* 支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN
|
||||
*/
|
||||
@UtilityClass
|
||||
public static final class MiniProgramLang {
|
||||
private MiniProgramLang() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 简体中文
|
||||
*/
|
||||
|
@ -161,7 +161,7 @@ public class WxMpCardServiceImpl implements WxMpCardService {
|
||||
|
||||
// 判断返回值
|
||||
JsonObject json = GsonParser.parse(responseContent);
|
||||
String errcode = json.get("errcode").getAsString();
|
||||
String errcode = json.get(WxConsts.ERR_CODE).getAsString();
|
||||
if (!"0".equals(errcode)) {
|
||||
String errmsg = json.get("errmsg").getAsString();
|
||||
throw new WxErrorException(WxError.builder()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
@ -27,7 +28,6 @@ public class WxMpDraftServiceImpl implements WxMpDraftService {
|
||||
|
||||
private static final String MEDIA_ID = "media_id";
|
||||
private static final String ERRCODE_SUCCESS = "0";
|
||||
private static final String ERRCODE = "errcode";
|
||||
private final WxMpService mpService;
|
||||
|
||||
@Override
|
||||
@ -49,7 +49,7 @@ public class WxMpDraftServiceImpl implements WxMpDraftService {
|
||||
@Override
|
||||
public Boolean updateDraft(WxMpUpdateDraft updateDraftInfo) throws WxErrorException {
|
||||
String json = this.mpService.post(WxMpApiUrl.Draft.UPDATE_DRAFT, updateDraftInfo);
|
||||
return GsonParser.parse(json).get(ERRCODE).getAsString().equals(ERRCODE_SUCCESS);
|
||||
return GsonParser.parse(json).get(WxConsts.ERR_CODE).getAsString().equals(ERRCODE_SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public class WxMpDraftServiceImpl implements WxMpDraftService {
|
||||
public Boolean delDraft(String mediaId) throws WxErrorException {
|
||||
String json = this.mpService.post(WxMpApiUrl.Draft.DEL_DRAFT,
|
||||
GsonHelper.buildJsonObject(MEDIA_ID, mediaId));
|
||||
return GsonParser.parse(json).get(ERRCODE).getAsString().equals(ERRCODE_SUCCESS);
|
||||
return GsonParser.parse(json).get(WxConsts.ERR_CODE).getAsString().equals(ERRCODE_SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
@ -24,7 +25,6 @@ public class WxMpFreePublishServiceImpl implements WxMpFreePublishService {
|
||||
private static final String PUBLISH_ID = "publish_id";
|
||||
private static final String ARTICLE_ID = "article_id";
|
||||
private static final String ERRCODE_SUCCESS = "0";
|
||||
private static final String ERRCODE = "errcode";
|
||||
private final WxMpService mpService;
|
||||
|
||||
@Override
|
||||
@ -44,7 +44,7 @@ public class WxMpFreePublishServiceImpl implements WxMpFreePublishService {
|
||||
public Boolean deletePush(String articleId, Integer index) throws WxErrorException {
|
||||
String json = this.mpService.post(WxMpApiUrl.FreePublish.DEL_PUSH,
|
||||
GsonHelper.buildJsonObject(ARTICLE_ID, articleId, "index", index));
|
||||
return GsonParser.parse(json).get(ERRCODE).toString().equals(ERRCODE_SUCCESS);
|
||||
return GsonParser.parse(json).get(WxConsts.ERR_CODE).toString().equals(ERRCODE_SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,6 @@ import static me.chanjar.weixin.mp.enums.WxMpApiUrl.SubscribeMsg.*;
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMpService service;
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -25,15 +26,13 @@ import static me.chanjar.weixin.mp.enums.WxMpApiUrl.TemplateMsg.*;
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
|
||||
|
||||
|
||||
private final WxMpService wxMpService;
|
||||
|
||||
@Override
|
||||
public String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException {
|
||||
String responseContent = this.wxMpService.post(MESSAGE_TEMPLATE_SEND, templateMessage.toJson());
|
||||
final JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() == 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
return jsonObject.get("msgid").getAsString();
|
||||
}
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
||||
@ -62,7 +61,7 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
|
||||
jsonObject.addProperty("template_id_short", shortTemplateId);
|
||||
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
|
||||
final JsonObject result = GsonParser.parse(responseContent);
|
||||
if (result.get("errcode").getAsInt() == 0) {
|
||||
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
return result.get("template_id").getAsString();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.mp.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
|
||||
|
||||
@ -16,8 +17,8 @@ public class WxMpMassSendResultAdapter implements JsonDeserializer<WxMpMassSendR
|
||||
WxMpMassSendResult sendResult = new WxMpMassSendResult();
|
||||
JsonObject sendResultJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (sendResultJsonObject.get("errcode") != null && !sendResultJsonObject.get("errcode").isJsonNull()) {
|
||||
sendResult.setErrorCode(GsonHelper.getAsString(sendResultJsonObject.get("errcode")));
|
||||
if (sendResultJsonObject.get(WxConsts.ERR_CODE) != null && !sendResultJsonObject.get(WxConsts.ERR_CODE).isJsonNull()) {
|
||||
sendResult.setErrorCode(GsonHelper.getAsString(sendResultJsonObject.get(WxConsts.ERR_CODE)));
|
||||
}
|
||||
if (sendResultJsonObject.get("errmsg") != null && !sendResultJsonObject.get("errmsg").isJsonNull()) {
|
||||
sendResult.setErrorMsg(GsonHelper.getAsString(sendResultJsonObject.get("errmsg")));
|
||||
|
@ -22,7 +22,7 @@ public class WxMpMemberCardActivateTempInfoResultGsonAdapter implements JsonDese
|
||||
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
|
||||
result.setErrorCode(GsonHelper.getString(jsonObject, "errcode"));
|
||||
result.setErrorCode(GsonHelper.getString(jsonObject, WxConsts.ERR_CODE));
|
||||
result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));
|
||||
|
||||
JsonObject userInfoJsonObject = jsonObject.getAsJsonObject("info");
|
||||
|
@ -27,7 +27,7 @@ public class WxMpMemberCardUpdateResultGsonAdapter implements JsonDeserializer<W
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
|
||||
result.setOpenId(GsonHelper.getString(jsonObject, "openid"));
|
||||
result.setErrorCode(GsonHelper.getString(jsonObject, "errcode"));
|
||||
result.setErrorCode(GsonHelper.getString(jsonObject, WxConsts.ERR_CODE));
|
||||
result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));
|
||||
result.setResultBalance(GsonHelper.getDouble(jsonObject, "result_balance"));
|
||||
result.setResultBonus(GsonHelper.getInteger(jsonObject, "result_bonus"));
|
||||
|
@ -31,7 +31,7 @@ public class WxMpMemberCardUserInfoResultGsonAdapter implements JsonDeserializer
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
|
||||
result.setOpenId(getString(jsonObject, "openid"));
|
||||
result.setErrorCode(getString(jsonObject, "errcode"));
|
||||
result.setErrorCode(getString(jsonObject, WxConsts.ERR_CODE));
|
||||
result.setErrorMsg(getString(jsonObject, "errmsg"));
|
||||
result.setNickname(getString(jsonObject, "nickname"));
|
||||
result.setMembershipNumber(getString(jsonObject, "membership_number"));
|
||||
|
@ -1,9 +1,9 @@
|
||||
package me.chanjar.weixin.open.api;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.bean.minishopGoods.AddMinishopGoodsSPU;
|
||||
import me.chanjar.weixin.open.bean.minishopGoods.GoodsCatList;
|
||||
import me.chanjar.weixin.open.bean.minishopGoods.ParentCatId;
|
||||
import me.chanjar.weixin.open.bean.minishopgoods.AddMinishopGoodsSPU;
|
||||
import me.chanjar.weixin.open.bean.minishopgoods.GoodsCatList;
|
||||
import me.chanjar.weixin.open.bean.minishopgoods.ParentCatId;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
|
||||
/**
|
||||
|
@ -756,7 +756,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
log.info("response: " + response);
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
MinishopCategories categories = new MinishopCategories();
|
||||
categories.setErrcode(respJson.get("errcode").getAsInt());
|
||||
categories.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (categories.getErrcode() == 0) {
|
||||
JsonArray catListJson = respJson.getAsJsonArray("cat_list");
|
||||
if (catListJson != null || catListJson.size() > 0) {
|
||||
@ -786,7 +786,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
MinishopBrandList brandList = new MinishopBrandList();
|
||||
brandList.setErrcode(respJson.get("errcode").getAsInt());
|
||||
brandList.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (brandList.getErrcode() == 0) {
|
||||
JsonArray brandArrayJson = respJson.get("brands").getAsJsonArray();
|
||||
if (brandArrayJson.size() > 0) {
|
||||
@ -823,7 +823,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
MinishopDeliveryTemplateResult templateResult = new MinishopDeliveryTemplateResult();
|
||||
templateResult.setErrCode(respJson.get("errcode").getAsInt());
|
||||
templateResult.setErrCode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (templateResult.getErrCode() == 0) {
|
||||
JsonArray templateArrayJson = respJson.get("template_list").getAsJsonArray();
|
||||
if (templateArrayJson.size() > 0) {
|
||||
@ -856,7 +856,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
MinishopShopCatList shopCatList = new MinishopShopCatList();
|
||||
shopCatList.setErrcode(respJson.get("errcode").getAsInt());
|
||||
shopCatList.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (shopCatList.getErrcode() == 0) {
|
||||
JsonArray shopcatArrayJson = respJson.get("shopcat_list").getAsJsonArray();
|
||||
if (shopcatArrayJson.size() > 0) {
|
||||
@ -890,7 +890,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonArray companyArray = respObj.get("company_list").getAsJsonArray();
|
||||
List<WxMinishopDeliveryCompany> companies = new ArrayList<>();
|
||||
@ -915,7 +915,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
Integer couponId = -1;
|
||||
if (respJson.get("errcode").getAsInt() == 0) {
|
||||
if (respJson.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
JsonObject dataJson = respJson.get("data").getAsJsonObject();
|
||||
couponId = dataJson.get("coupon_id").getAsInt();
|
||||
}
|
||||
@ -949,7 +949,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
Integer couponId = -1;
|
||||
if (respJson.get("errcode").getAsInt() == 0) {
|
||||
if (respJson.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
JsonObject dataJson = respJson.get("data").getAsJsonObject();
|
||||
couponId = dataJson.get("coupon_id").getAsInt();
|
||||
}
|
||||
@ -978,7 +978,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
@ -1016,7 +1016,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
|
||||
@ -1066,7 +1066,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
|
||||
@ -1171,7 +1171,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
Integer taskId = 0;
|
||||
if (respObj.get("errcode").getAsInt() == 0) {
|
||||
if (respObj.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
taskId = respObj.get("task_id").getAsInt();
|
||||
}
|
||||
return taskId;
|
||||
@ -1187,7 +1187,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
List<LimitDiscountGoods> limitDiscountGoodsList = new ArrayList<>();
|
||||
if (respObj.get("errcode").getAsInt() == 0) {
|
||||
if (respObj.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
//成功获取到秒杀活动列表
|
||||
|
||||
JsonArray jsonArray = respObj.get("limited_discount_list").getAsJsonArray();
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.chanjar.weixin.open.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.api.WxOpenMinishopGoodsService;
|
||||
import me.chanjar.weixin.open.bean.minishopGoods.AddMinishopGoodsSPU;
|
||||
import me.chanjar.weixin.open.bean.minishopGoods.GoodsCatList;
|
||||
import me.chanjar.weixin.open.bean.minishopGoods.ParentCatId;
|
||||
import me.chanjar.weixin.open.bean.minishopgoods.AddMinishopGoodsSPU;
|
||||
import me.chanjar.weixin.open.bean.minishopgoods.GoodsCatList;
|
||||
import me.chanjar.weixin.open.bean.minishopgoods.ParentCatId;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
|
||||
@Slf4j
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
@ -1,12 +1,16 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kelvenlaw
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GoodsCatList {
|
||||
@ -26,7 +30,7 @@ public class GoodsCatList {
|
||||
public JsonObject toJsonObject() {
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("errcode", errcode);
|
||||
jsonObject.addProperty(WxConsts.ERR_CODE, errcode);
|
||||
jsonObject.addProperty("errmsg", errmsg);
|
||||
jsonObject.addProperty("cat_list", gson.toJson(catList));
|
||||
return jsonObject;
|
@ -1,4 +1,4 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
@ -1,11 +1,10 @@
|
||||
package me.chanjar.weixin.open.bean.minishopGoods;
|
||||
package me.chanjar.weixin.open.bean.minishopgoods;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
Loading…
Reference in New Issue
Block a user