diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java index ee417b4..2ad8a4f 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java @@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.wfc.common.core.web.controller.BaseController; import org.wfc.common.core.web.page.TableDataInfo; -import org.wfc.user.domain.vo.UBillUserVo; +import org.wfc.user.domain.vo.UInvoiceBillVo; import org.wfc.user.service.IUBillService; import java.util.List; @@ -29,7 +29,7 @@ public class UBillController extends BaseController { @GetMapping("/page") public TableDataInfo page() { startPage(); - List list = uBillService.getBillByUser(); + List list = uBillService.getInvoiceByUser(); return getDataTable(list); } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java index e16350a..8fbff78 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java @@ -124,7 +124,7 @@ public class UOrderController extends BaseController { @InnerAuth @PostMapping("paySuccess/{id}") public AjaxResult paySuccess(@PathVariable("id") Long id) { - return toAjax(uOrderService.paySuccess(id)); + return toAjax(uOrderService.paySuccess(id, false)); } @PostMapping("payBalance/{id}") diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/InvoiceBean.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/InvoiceBean.java new file mode 100644 index 0000000..23ed27e --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/InvoiceBean.java @@ -0,0 +1,19 @@ +package org.wfc.user.domain; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * + *

invoice Bean

+ * + * @author cyc + */ +@Data +@Component +@ConfigurationProperties(prefix = "invoice") +public class InvoiceBean { + + private String path; +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UInvoiceBillVo.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UInvoiceBillVo.java new file mode 100644 index 0000000..fc6495f --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UInvoiceBillVo.java @@ -0,0 +1,30 @@ +package org.wfc.user.domain.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author: cyc + * @since: 2025-01-07 + */ +@Data +public class UInvoiceBillVo { + + @Schema(description = "发票编号") + private Long invoiceNumber; + + @Schema(description = "金额") + private BigDecimal amount; + + @Schema(description = "类型") + private Integer type; + + @Schema(description = "发票日期") + private Date invoiceDate; + + @Schema(description = "发票编号") + private String invoiceFile; +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UInvoiceGenVo.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UInvoiceGenVo.java new file mode 100644 index 0000000..b3786cd --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UInvoiceGenVo.java @@ -0,0 +1,17 @@ +package org.wfc.user.domain.vo; + +import lombok.Data; + +/** + * @description: invoice vo + * @author: cyc + * @since: 2025-06-11 + */ +@Data +public class UInvoiceGenVo { + + private String invoiceNumber; + + private String invoiceFile; + +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java index d0a07e3..857c367 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.wfc.user.domain.UBill; import org.wfc.user.domain.vo.UBillUserVo; +import org.wfc.user.domain.vo.UInvoiceBillVo; import java.util.List; @@ -17,4 +18,6 @@ import java.util.List; */ public interface UBillMapper extends BaseMapper { List getBillByUser(@Param("userId") Long userId); + + List getInvoiceByUser(@Param("userId") Long userId); } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java index 574c03a..6aacce3 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java @@ -18,4 +18,6 @@ public interface IUBillService extends IService { List getBillByUser(); + List getInvoiceByUser(); + } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java index dc7af6d..e401252 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java @@ -15,7 +15,7 @@ public interface IUOrderService extends IService { Long saveOrder(UOrder order); - boolean paySuccess(Long orderId); + boolean paySuccess(Long orderId, Boolean isBalancePay); boolean payByBalance(Long orderId); } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java index 852b02f..e20e932 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java @@ -282,7 +282,7 @@ public class UAccountServiceImpl extends ServiceImpl i bill.setCdrHistoryId(cdrHistoryId); bill.setType(OrderTypeEnum.RECHARGE.getCode()); bill.setStatus(OrderStatusEnum.PAID.getCode()); - billMapper.insert(bill); +// billMapper.insert(bill); account.setBalanceUsed(BigDecimal.ZERO); this.updateById(account); diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java index db48d1b..2c38ef2 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java @@ -27,6 +27,7 @@ import org.wfc.user.domain.URateLimit; import org.wfc.user.domain.constant.OrderStatusEnum; import org.wfc.user.domain.constant.OrderTypeEnum; import org.wfc.user.domain.constant.PeriodTypeEnum; +import org.wfc.user.domain.vo.UInvoiceGenVo; import org.wfc.user.mapper.UAccountPackageMapper; import org.wfc.user.mapper.UBillMapper; import org.wfc.user.mapper.UBillRuleMapper; @@ -80,7 +81,7 @@ public class UOrderServiceImpl extends ServiceImpl impleme @Override @Transactional(rollbackFor = Exception.class) - public boolean paySuccess(Long orderId) { + public boolean paySuccess(Long orderId, Boolean isBalancePay) { // 支付成功回调 // 更新当前订单状态为已支付 UOrder order = this.getById(orderId); @@ -96,6 +97,15 @@ public class UOrderServiceImpl extends ServiceImpl impleme bill.setUserId(order.getUserId()); bill.setType(order.getType()); bill.setStatus(OrderStatusEnum.PAID.getCode()); + + if (!isBalancePay) { + // 生成发票pdf文件 + UInvoiceGenVo invoiceGenVo = billService.genInvoice(order); + // 设置发票编号和发票文件地址 + bill.setInvoiceNumber(invoiceGenVo.getInvoiceNumber()); + bill.setInvoiceFile(invoiceGenVo.getInvoiceFile()); + } + billMapper.insert(bill); // 保存或更新账户信息 @@ -167,7 +177,7 @@ public class UOrderServiceImpl extends ServiceImpl impleme if (order.getOrderAmount().compareTo(balance) > 0) { throw new ServiceException("user.order.pay.amount.error"); } - if (paySuccess(orderId)) { + if (paySuccess(orderId, true)) { UAccount updateAccount = new UAccount(); updateAccount.setId(account.getId()); updateAccount.setBalance(account.getBalance().subtract(order.getOrderAmount())); diff --git a/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml b/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml index dc3c1db..7f980db 100644 --- a/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml +++ b/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml @@ -18,4 +18,18 @@ AND b.user_id = #{userId} order by b.create_time desc + +