diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java index 294fba85b..795c848b3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMerchantInvoiceService.java @@ -14,16 +14,26 @@ import me.chanjar.weixin.mp.bean.invoice.merchant.*; *
* 流程文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Vendor_and_Invoicing_Platform_Mode_Instruction.html * 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Vendor_API_List.html + * + * @author Mario Luo */ public interface WxMpMerchantInvoiceService { /** * 获取开票授权页链接 + * + * @param params the params + * @return the auth page url + * @throws WxErrorException the wx error exception */ InvoiceAuthPageResult getAuthPageUrl(InvoiceAuthPageRequest params) throws WxErrorException; /** * 获得用户授权数据 + * + * @param params the params + * @return the auth data + * @throws WxErrorException the wx error exception */ InvoiceAuthDataResult getAuthData(InvoiceAuthDataRequest params) throws WxErrorException; @@ -32,16 +42,25 @@ public interface WxMpMerchantInvoiceService { *
* 场景: 用户授权填写数据无效
* 结果: 用户会收到一条开票失败提示
+ *
+ * @param params the params
+ * @throws WxErrorException the wx error exception
*/
void rejectInvoice(InvoiceRejectRequest params) throws WxErrorException;
/**
* 开具电子发票
+ *
+ * @param params the params
+ * @throws WxErrorException the wx error exception
*/
void makeOutInvoice(MakeOutInvoiceRequest params) throws WxErrorException;
/**
* 发票冲红
+ *
+ * @param params the params
+ * @throws WxErrorException the wx error exception
*/
void clearOutInvoice(ClearOutInvoiceRequest params) throws WxErrorException;
@@ -50,36 +69,57 @@ public interface WxMpMerchantInvoiceService {
*
* @param fpqqlsh 发票请求流水号
* @param nsrsbh 纳税人识别号
+ * @return the invoice result
+ * @throws WxErrorException the wx error exception
*/
InvoiceResult queryInvoiceInfo(String fpqqlsh, String nsrsbh) throws WxErrorException;
/**
* 设置商户联系方式, 获取授权链接前需要设置商户联系信息
+ *
+ * @param contact the contact
+ * @throws WxErrorException the wx error exception
*/
void setMerchantContactInfo(MerchantContactInfo contact) throws WxErrorException;
/**
* 获取商户联系方式
+ *
+ * @return the merchant contact info
+ * @throws WxErrorException the wx error exception
*/
MerchantContactInfo getMerchantContactInfo() throws WxErrorException;
/**
* 配置授权页面字段
+ *
+ * @param authPageSetting the auth page setting
+ * @throws WxErrorException the wx error exception
*/
void setAuthPageSetting(InvoiceAuthPageSetting authPageSetting) throws WxErrorException;
/**
* 获取授权页面配置
+ *
+ * @return the auth page setting
+ * @throws WxErrorException the wx error exception
*/
InvoiceAuthPageSetting getAuthPageSetting() throws WxErrorException;
/**
* 设置商户开票平台信息
+ *
+ * @param merchantInvoicePlatformInfo the merchant invoice platform info
+ * @throws WxErrorException the wx error exception
*/
void setMerchantInvoicePlatform(MerchantInvoicePlatformInfo merchantInvoicePlatformInfo) throws WxErrorException;
/**
* 获取商户开票平台信息
+ *
+ * @param merchantInvoicePlatformInfo the merchant invoice platform info
+ * @return the merchant invoice platform
+ * @throws WxErrorException the wx error exception
*/
MerchantInvoicePlatformInfo getMerchantInvoicePlatform(MerchantInvoicePlatformInfo merchantInvoicePlatformInfo) throws WxErrorException;
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java
index ffae3ddf1..11883cded 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMerchantInvoiceServiceImpl.java
@@ -1,8 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
-import com.google.gson.FieldNamingPolicy;
+import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -11,96 +10,85 @@ import me.chanjar.weixin.mp.api.WxMpMerchantInvoiceService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.invoice.merchant.*;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
+import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
-import java.util.HashMap;
import java.util.Map;
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Invoice.*;
+/**
+ * @author Mario Luo
+ */
@AllArgsConstructor
public class WxMpMerchantInvoiceServiceImpl implements WxMpMerchantInvoiceService {
-
- private WxMpService wxMpService;
- private WxMpCardService wxMpCardService;
-
- private final static Gson gson;
-
- static {
- gson = new GsonBuilder()
- .disableHtmlEscaping()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
- .create();
- }
+ private final WxMpService wxMpService;
+ private final WxMpCardService wxMpCardService;
@Override
public InvoiceAuthPageResult getAuthPageUrl(InvoiceAuthPageRequest params) throws WxErrorException {
String ticket = wxMpCardService.getCardApiTicket();
params.setTicket(ticket);
- return doCommonInvoiceHttpPost(GET_AUTH_URL, params, InvoiceAuthPageResult.class);
+ return this.doCommonInvoiceHttpPost(GET_AUTH_URL, params, InvoiceAuthPageResult.class);
}
@Override
public InvoiceAuthDataResult getAuthData(InvoiceAuthDataRequest params) throws WxErrorException {
- return doCommonInvoiceHttpPost(GET_AUTH_DATA, params, InvoiceAuthDataResult.class);
+ return this.doCommonInvoiceHttpPost(GET_AUTH_DATA, params, InvoiceAuthDataResult.class);
}
@Override
public void rejectInvoice(InvoiceRejectRequest params) throws WxErrorException {
- doCommonInvoiceHttpPost(REJECT_INSERT, params, null);
+ this.doCommonInvoiceHttpPost(REJECT_INSERT, params, null);
}
@Override
public void makeOutInvoice(MakeOutInvoiceRequest params) throws WxErrorException {
- doCommonInvoiceHttpPost(MAKE_OUT_INVOICE, params, null);
+ this.doCommonInvoiceHttpPost(MAKE_OUT_INVOICE, params, null);
}
@Override
public void clearOutInvoice(ClearOutInvoiceRequest params) throws WxErrorException {
- doCommonInvoiceHttpPost(CLEAR_OUT_INVOICE, params, null);
+ this.doCommonInvoiceHttpPost(CLEAR_OUT_INVOICE, params, null);
}
@Override
public InvoiceResult queryInvoiceInfo(String fpqqlsh, String nsrsbh) throws WxErrorException {
- Map data = new HashMap();
- data.put("fpqqlsh", fpqqlsh);
- data.put("nsrsbh", nsrsbh);
- return doCommonInvoiceHttpPost(QUERY_INVOICE_INFO, data, InvoiceResult.class);
+ Map