feat: 发票时间调整
This commit is contained in:
@@ -5,4 +5,7 @@ ALTER TABLE `wfc_user_db`.`u_bill`
|
||||
ADD COLUMN `invoice_number` varchar(64) NULL COMMENT '发票编号' AFTER `status`,
|
||||
ADD COLUMN `invoice_file` varchar(255) NULL COMMENT '发票文件' AFTER `invoice_number`
|
||||
|
||||
ALTER TABLE `wfc_user_db`.`u_bill`
|
||||
ADD COLUMN `invoice_time` datetime NULL COMMENT '发票时间' AFTER `invoice_file`
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class UOrderController extends BaseController {
|
||||
continue;
|
||||
}
|
||||
UPackage uPackage = uPackageService.getById(uOrder.getPackageId());
|
||||
if (ObjectUtil.isNotNull(uPackage.getRateLimitId())) {
|
||||
if (ObjectUtil.isNotNull(uPackage) && ObjectUtil.isNotNull(uPackage.getRateLimitId())) {
|
||||
uPackage.setRateLimits(uRateLimitService.getById(uPackage.getRateLimitId()));
|
||||
}
|
||||
uOrder.setUPackage(uPackage);
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Setter;
|
||||
import org.wfc.common.mybatis.domain.BaseData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -44,4 +45,7 @@ public class UBill extends BaseData {
|
||||
|
||||
@Schema(description = "发票文件")
|
||||
private String invoiceFile;
|
||||
|
||||
@Schema(description = "发票文件")
|
||||
private Date invoiceTime;
|
||||
}
|
||||
|
||||
@@ -37,4 +37,8 @@ public class UInvoiceTemplateBo {
|
||||
private String clientsNumber;
|
||||
|
||||
private String billingCycle;
|
||||
|
||||
private String currencySymbol;
|
||||
|
||||
private Long now;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class UInvoiceBillVo {
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "发票日期")
|
||||
private Date invoiceDate;
|
||||
private Date invoiceTime;
|
||||
|
||||
@Schema(description = "发票编号")
|
||||
private String invoiceFile;
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.wfc.user.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description: invoice vo
|
||||
* @author: cyc
|
||||
@@ -14,4 +16,5 @@ public class UInvoiceGenVo {
|
||||
|
||||
private String invoiceFile;
|
||||
|
||||
private Date invoiceTime;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,8 @@ import java.io.IOException;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -111,13 +110,14 @@ public class UBillServiceImpl extends ServiceImpl<UBillMapper, UBill> implements
|
||||
.isNotNull(UBill::getInvoiceNumber)
|
||||
.orderByDesc(BaseData::getCreateTime).last("limit 1"), false);
|
||||
|
||||
LocalDateTime dateTime = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String dateStr = dateTime.format(formatter);
|
||||
Date date = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dateStr = simpleDateFormat.format(date);
|
||||
String oldInvoiceNumber = StrUtil.EMPTY;
|
||||
if (bill != null) {
|
||||
oldInvoiceNumber = bill.getInvoiceNumber();
|
||||
}
|
||||
invoiceBo.setNow(date.getTime());
|
||||
invoiceBo.setInvoiceNumber(genInvoiceNumber(dateStr, oldInvoiceNumber));
|
||||
invoiceBo.setInvoiceDate(dateStr);
|
||||
|
||||
@@ -168,6 +168,7 @@ public class UBillServiceImpl extends ServiceImpl<UBillMapper, UBill> implements
|
||||
invoiceBo.setHasDetails(false);
|
||||
invoiceBo.setItemName(OrderTypeEnum.RECHARGE.getDesc());
|
||||
}
|
||||
invoiceBo.setCurrencySymbol(currencySymbol);
|
||||
invoiceBo.setUnitPrice(currencySymbol + order.getOrderAmount().setScale(2, RoundingMode.HALF_UP));
|
||||
invoiceBo.setTotal(currencySymbol + order.getOrderAmount().setScale(2, RoundingMode.HALF_UP));
|
||||
// 填充发票模版
|
||||
@@ -204,13 +205,14 @@ public class UBillServiceImpl extends ServiceImpl<UBillMapper, UBill> implements
|
||||
}
|
||||
MailUtils.sendHtml(invoiceBo.getEmail(), subject, htmlStr, uploadFile);
|
||||
|
||||
FileUtil.del(uploadFile);
|
||||
// FileUtil.del(uploadFile);
|
||||
} catch (Exception e) {
|
||||
log.error("email invoice send failed => {}", e.getMessage());
|
||||
}
|
||||
UInvoiceGenVo invoiceGenVo = new UInvoiceGenVo();
|
||||
invoiceGenVo.setInvoiceNumber(invoiceBo.getInvoiceNumber());
|
||||
invoiceGenVo.setInvoiceFile(url);
|
||||
invoiceGenVo.setInvoiceTime(date);
|
||||
return invoiceGenVo;
|
||||
}
|
||||
|
||||
@@ -230,6 +232,8 @@ public class UBillServiceImpl extends ServiceImpl<UBillMapper, UBill> implements
|
||||
context.setVariable("speedCap", invoiceBo.getSpeedCap());
|
||||
context.setVariable("clientsNumber", invoiceBo.getClientsNumber());
|
||||
context.setVariable("billingCycle", invoiceBo.getBillingCycle());
|
||||
context.setVariable("currencySymbol", invoiceBo.getCurrencySymbol());
|
||||
context.setVariable("now", invoiceBo.getNow());
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
// 设置发票编号和发票文件地址
|
||||
bill.setInvoiceNumber(invoiceGenVo.getInvoiceNumber());
|
||||
bill.setInvoiceFile(invoiceGenVo.getInvoiceFile());
|
||||
bill.setInvoiceTime(invoiceGenVo.getInvoiceTime());
|
||||
}
|
||||
|
||||
billMapper.insert(bill);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
b.invoice_number,
|
||||
b.invoice_file,
|
||||
b.amount,
|
||||
b.create_time invoice_date,
|
||||
b.invoice_time,
|
||||
b.`type`
|
||||
FROM
|
||||
u_bill b
|
||||
|
||||
Reference in New Issue
Block a user