| | |
| | | import com.ruoyi.cwgl.service.IInvoiceBillDetailService; |
| | | import com.ruoyi.cwgl.service.IInvoiceBusinessService; |
| | | import com.ruoyi.system.service.ISystemDataNoService; |
| | | import lombok.NonNull; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | order.setInvoiceDetail(invoiceDetailList); |
| | | invoicingVo.setOrder(order); |
| | | String body = JSONObject.toJSONString(invoicingVo); |
| | | String urlString = invoicingAddress + "?businessType=" + businessType + "&returnUrl=" + returnAddress; |
| | | |
| | | // 根据业务类型动态设置回调地址 |
| | | String urlString = getString(businessType); |
| | | logger.info("请求body{}",body); |
| | | logger.info("请求地址{}",urlString); |
| | | String json = HttpUtil.post(urlString, body); |
| | |
| | | |
| | | |
| | | return AjaxResult.error("开票失败"); |
| | | } |
| | | |
| | | private @NonNull String getString(String businessType) { |
| | | String dynamicReturnAddress; |
| | | if ("FP_PAYABLE".equals(businessType)) { |
| | | dynamicReturnAddress = returnAddress + "/callback/receipt/payable"; |
| | | } else if ("FP_RECEIVABLE".equals(businessType)) { |
| | | dynamicReturnAddress = returnAddress + "/callback/receipt/receivable"; |
| | | } else { |
| | | dynamicReturnAddress = returnAddress + "/callback/receipt"; |
| | | } |
| | | |
| | | return invoicingAddress + "?businessType=" + businessType + "&returnUrl=" + dynamicReturnAddress; |
| | | } |
| | | |
| | | /** |
| | |
| | | int c_status = Integer.parseInt(jsonObject.getString("c_status")); |
| | | invoiceBusiness.setStatus(c_status); |
| | | if (c_status == 1) { |
| | | |
| | | |
| | | String invoiceNumStr = jsonObject.getString("c_fphm"); |
| | | |
| | | // 普通发票 - 更新invoice_manage表 |
| | | InvoiceManage invoiceManageUpdate = new InvoiceManage(); |
| | | invoiceManageUpdate.setInvoiceNo(invoiceNumStr); |
| | | invoiceManageUpdate.setId(invoiceBusiness.getId()); |
| | | invoiceManageUpdate.setStatus(2); |
| | | invoiceManageMapper.updateById(invoiceBusiness); |
| | | invoiceManageMapper.updateById(invoiceManageUpdate); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void invoicingSuccessPayable(CallbackReceiptDto callbackReceiptDto) { |
| | | InvoiceManage invoiceBusiness = invoiceManageMapper.selectInvoiceManageLogByOrderNo(callbackReceiptDto.getOrderno()); |
| | | if (invoiceBusiness == null) { |
| | | return; |
| | | } |
| | | String content = callbackReceiptDto.getContent(); |
| | | if (StringUtils.isEmpty(content)) { |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSONObject.parseObject(content); |
| | | |
| | | int c_status = Integer.parseInt(jsonObject.getString("c_status")); |
| | | invoiceBusiness.setStatus(c_status); |
| | | if (c_status == 1) { |
| | | String invoiceNumStr = jsonObject.getString("c_fphm"); |
| | | |
| | | // 应付账单 - 更新payable_invoice_business表 |
| | | PayableInvoiceBusiness payableInvoiceBusiness = payableInvoiceBusinessMapper.selectPayableInvoiceBusinessById(invoiceBusiness.getId()); |
| | | if (payableInvoiceBusiness != null) { |
| | | payableInvoiceBusiness.setInvoiceSerialNum(invoiceNumStr); |
| | | payableInvoiceBusiness.setStatus(2); |
| | | payableInvoiceBusinessMapper.updateById(payableInvoiceBusiness); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void invoicingSuccessReceivable(CallbackReceiptDto callbackReceiptDto) { |
| | | InvoiceManage invoiceBusiness = invoiceManageMapper.selectInvoiceManageLogByOrderNo(callbackReceiptDto.getOrderno()); |
| | | if (invoiceBusiness == null) { |
| | | return; |
| | | } |
| | | String content = callbackReceiptDto.getContent(); |
| | | if (StringUtils.isEmpty(content)) { |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSONObject.parseObject(content); |
| | | |
| | | int c_status = Integer.parseInt(jsonObject.getString("c_status")); |
| | | invoiceBusiness.setStatus(c_status); |
| | | if (c_status == 1) { |
| | | String invoiceNumStr = jsonObject.getString("c_fphm"); |
| | | |
| | | // 应收账单 - 更新receivable_invoice_business表 |
| | | ReceivableInvoiceBusiness receivableInvoiceBusiness = receivableInvoiceBusinessMapper.selectReceivableInvoiceBusinessById(invoiceBusiness.getId()); |
| | | if (receivableInvoiceBusiness != null) { |
| | | receivableInvoiceBusiness.setInvoiceSerialNum(invoiceNumStr); |
| | | receivableInvoiceBusiness.setStatus(2); |
| | | receivableInvoiceBusinessMapper.updateById(receivableInvoiceBusiness); |
| | | } |
| | | } |
| | | } |
| | | } |