|
@@ -21,6 +21,7 @@ import com.kym.entity.miniapp.RefundLog;
|
|
|
import com.kym.entity.miniapp.WalletDetail;
|
|
import com.kym.entity.miniapp.WalletDetail;
|
|
|
import com.kym.entity.wechat.FaPiao;
|
|
import com.kym.entity.wechat.FaPiao;
|
|
|
import com.kym.entity.wechat.InvoiceBaseInfo;
|
|
import com.kym.entity.wechat.InvoiceBaseInfo;
|
|
|
|
|
+import com.kym.entity.wechat.InvoiceNotification;
|
|
|
import com.kym.entity.wechat.TaxCodes;
|
|
import com.kym.entity.wechat.TaxCodes;
|
|
|
import com.kym.service.miniapp.*;
|
|
import com.kym.service.miniapp.*;
|
|
|
import com.kym.service.wechat.WxPayService;
|
|
import com.kym.service.wechat.WxPayService;
|
|
@@ -131,6 +132,15 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
refundService = new RefundService.Builder().config(config).build();
|
|
refundService = new RefundService.Builder().config(config).build();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理微信回调信息,验签解密
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return array[0] RequestParam 请求参数
|
|
|
|
|
+ * array[1] NotificationParser 通知解析器
|
|
|
|
|
+ * array[2] nonce 随机数
|
|
|
|
|
+ */
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
Object[] handleWxNotify(HttpServletRequest request) {
|
|
Object[] handleWxNotify(HttpServletRequest request) {
|
|
|
var no = RandomUtil.randomInt(1000, 9999);
|
|
var no = RandomUtil.randomInt(1000, 9999);
|
|
@@ -557,4 +567,25 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
var res = HttpUtil.post(url, JSONObject.toJSONString(fapiao), headers);
|
|
var res = HttpUtil.post(url, JSONObject.toJSONString(fapiao), headers);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 微信开票结果通知
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ void wxInvoiceNotify(HttpServletRequest request) {
|
|
|
|
|
+ var notifyRes = handleWxNotify(request);
|
|
|
|
|
+ try {
|
|
|
|
|
+ InvoiceNotification invoiceNotification = ((NotificationParser) notifyRes[1]).parse((RequestParam) notifyRes[0], InvoiceNotification.class);
|
|
|
|
|
+ LOGGER.info("微信开具发票结果通知回调{}:验签解密完毕,数据:\n{}", notifyRes[2], invoiceNotification);
|
|
|
|
|
+ // TODO: 2023-09-17 业务逻辑
|
|
|
|
|
+
|
|
|
|
|
+ } catch (ValidationException e) {
|
|
|
|
|
+ // 签名验证失败,返回 401 UNAUTHORIZED 状态码
|
|
|
|
|
+ LOGGER.error("微信开具发票结果通知验签失败", e);
|
|
|
|
|
+ throw new BusinessException("验签失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|