feat: 账单和发票
This commit is contained in:
@@ -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<UBillUserVo> list = uBillService.getBillByUser();
|
||||
List<UInvoiceBillVo> list = uBillService.getInvoiceByUser();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.wfc.user.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>invoice Bean</p>
|
||||
*
|
||||
* @author cyc
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "invoice")
|
||||
public class InvoiceBean {
|
||||
|
||||
private String path;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<UBill> {
|
||||
List<UBillUserVo> getBillByUser(@Param("userId") Long userId);
|
||||
|
||||
List<UInvoiceBillVo> getInvoiceByUser(@Param("userId") Long userId);
|
||||
}
|
||||
|
||||
@@ -18,4 +18,6 @@ public interface IUBillService extends IService<UBill> {
|
||||
|
||||
List<UBillUserVo> getBillByUser();
|
||||
|
||||
List<UInvoiceBillVo> getInvoiceByUser();
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IUOrderService extends IService<UOrder> {
|
||||
|
||||
Long saveOrder(UOrder order);
|
||||
|
||||
boolean paySuccess(Long orderId);
|
||||
boolean paySuccess(Long orderId, Boolean isBalancePay);
|
||||
|
||||
boolean payByBalance(Long orderId);
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> 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);
|
||||
|
||||
@@ -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<UOrderMapper, UOrder> 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<UOrderMapper, UOrder> 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<UOrderMapper, UOrder> 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()));
|
||||
|
||||
@@ -18,4 +18,18 @@
|
||||
AND b.user_id = #{userId}
|
||||
order by b.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="getInvoiceByUser" resultType="org.wfc.user.domain.vo.UInvoiceBillVo">
|
||||
SELECT
|
||||
b.invoice_number,
|
||||
b.invoice_file,
|
||||
b.amount,
|
||||
b.create_time invoice_date,
|
||||
b.`type`
|
||||
FROM
|
||||
u_bill b
|
||||
WHERE b.del_flag = 0
|
||||
AND b.user_id = #{userId}
|
||||
order by b.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user