|
|
@@ -92,13 +92,15 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
|
|
|
private final InvoiceService invoiceService;
|
|
|
|
|
|
+ private final InvoiceTitleService invoiceTitleService;
|
|
|
+
|
|
|
/**
|
|
|
* 微信支付专用,支持自动签名验签解密等
|
|
|
*/
|
|
|
private OkHttpClientAdapter wxHttpClient;
|
|
|
|
|
|
|
|
|
- public WxPayServiceImpl(WxPayConfig conf, WxFapiaoConfig fapiaoConfig, WalletDetailService walletDetailService, PayLogService payLogService, AccountService accountService, ChargeOrderService chargeOrderService, RefundLogService refundLogService, InvoiceService invoiceService) {
|
|
|
+ public WxPayServiceImpl(WxPayConfig conf, WxFapiaoConfig fapiaoConfig, WalletDetailService walletDetailService, PayLogService payLogService, AccountService accountService, ChargeOrderService chargeOrderService, RefundLogService refundLogService, InvoiceService invoiceService, InvoiceTitleService invoiceTitleService) {
|
|
|
this.conf = conf;
|
|
|
this.fapiaoConfig = fapiaoConfig;
|
|
|
this.walletDetailService = walletDetailService;
|
|
|
@@ -107,6 +109,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
this.chargeOrderService = chargeOrderService;
|
|
|
this.refundLogService = refundLogService;
|
|
|
this.invoiceService = invoiceService;
|
|
|
+ this.invoiceTitleService = invoiceTitleService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -572,11 +575,11 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
"fapiao_apply_id", invoice.getApplyId(),
|
|
|
"appid", conf.getAppid(),
|
|
|
"openid", invoice.getOpenid(),
|
|
|
- "total_amount", invoice.getTotalMoney(),
|
|
|
+ "total_amount", invoice.getInvoiceAmount(),
|
|
|
"source", "MINIPROGRAM"
|
|
|
);
|
|
|
headers.addHeader("Accept", "application/json");
|
|
|
- var res = wxHttpClient.get(headers, fapiaoConfig.getTitleUrl().concat(URLUtil.buildQuery(params, StandardCharsets.UTF_8)), TitleUrl.class);
|
|
|
+ var res = wxHttpClient.get(headers, fapiaoConfig.getTitleUrl().concat("?").concat(URLUtil.buildQuery(params, StandardCharsets.UTF_8)), TitleUrl.class);
|
|
|
return res.getServiceResponse();
|
|
|
}
|
|
|
|
|
|
@@ -591,24 +594,42 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
public void titleWriteNotice(HttpServletRequest request) {
|
|
|
var notifyRes = handleWxNotify(request);
|
|
|
try {
|
|
|
- // TODO: 2023-10-12 步骤 用户选择开票的订单,确定(数据库插入invoice数据)进入抬头填写页面,输入抬头确定开票,收到抬头填写完成通知后
|
|
|
- // 再获取用户抬头更新invoice抬头数据。后台审核人员进行开票操作
|
|
|
TitleWriteNotification titleWriteNotification = ((NotificationParser) notifyRes[1]).parse((RequestParam) notifyRes[0], TitleWriteNotification.class);
|
|
|
+
|
|
|
// 查询用户填写的抬头信息
|
|
|
var applyId = titleWriteNotification.getFapiaoApplyId();
|
|
|
var buyerInformation = userTitle(applyId);
|
|
|
+
|
|
|
// 更新invoice表数据
|
|
|
- invoiceService.lambdaUpdate()
|
|
|
- .eq(Invoice::getApplyId, applyId)
|
|
|
- .set(Invoice::getInvoiceType, buyerInformation.getType())
|
|
|
- .set(Invoice::getInvoiceTitle, buyerInformation.getName())
|
|
|
- .set(Invoice::getTaxId, buyerInformation.getTaxpayer_id())
|
|
|
- .set(Invoice::getAddress, buyerInformation.getAddress())
|
|
|
- .set(Invoice::getBankName, buyerInformation.getBank_name())
|
|
|
- .set(Invoice::getBankAccount, buyerInformation.getBank_account())
|
|
|
- .set(Invoice::getPhone, buyerInformation.getPhone())
|
|
|
- .set(Invoice::getEmail, buyerInformation.getEmail())
|
|
|
- .update();
|
|
|
+ var invoice = invoiceService.lambdaQuery().eq(Invoice::getApplyId, applyId).one();
|
|
|
+ invoice.setInvoiceType(buyerInformation.getType())
|
|
|
+ .setInvoiceTitle(buyerInformation.getName())
|
|
|
+ .setTaxId(buyerInformation.getTaxpayer_id())
|
|
|
+ .setAddress(buyerInformation.getAddress())
|
|
|
+ .setBankName(buyerInformation.getBank_name())
|
|
|
+ .setBankAccount(buyerInformation.getBank_account())
|
|
|
+ .setEmail(buyerInformation.getEmail())
|
|
|
+ .setPhone(buyerInformation.getPhone());
|
|
|
+ invoiceService.updateById(invoice);
|
|
|
+
|
|
|
+ // 将发票抬头写入用户抬头表
|
|
|
+ var invoiceTitle = new InvoiceTitle()
|
|
|
+ .setUserId(invoice.getUserId())
|
|
|
+ .setInvoiceType(buyerInformation.getType())
|
|
|
+ .setInvoiceTitle(buyerInformation.getName())
|
|
|
+ .setTaxId(buyerInformation.getTaxpayer_id())
|
|
|
+ .setAddress(buyerInformation.getAddress())
|
|
|
+ .setBankName(buyerInformation.getBank_name())
|
|
|
+ .setBankAccount(buyerInformation.getBank_account())
|
|
|
+ .setEmail(buyerInformation.getEmail())
|
|
|
+ .setPhone(buyerInformation.getPhone());
|
|
|
+ boolean exist = invoiceTitleService.lambdaQuery()
|
|
|
+ .eq(InvoiceTitle::getUserId, invoiceTitle.getUserId())
|
|
|
+ .eq(InvoiceTitle::getTaxId, invoiceTitle.getTaxId())
|
|
|
+ .exists();
|
|
|
+ if (!exist) {
|
|
|
+ invoiceTitleService.save(invoiceTitle);
|
|
|
+ }
|
|
|
// 运营后台财务操作开具发票
|
|
|
} catch (ValidationException e) {
|
|
|
// 签名验证失败,返回 401 UNAUTHORIZED 状态码
|
|
|
@@ -741,6 +762,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
|
|
|
/**
|
|
|
* 接收电子发票相关回调通知
|
|
|
+ *
|
|
|
* @param request
|
|
|
*/
|
|
|
@Override
|