Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-10-18 12:21:19 +08:00
commit 4064cc8c2b
2 changed files with 23 additions and 24 deletions

View File

@ -196,7 +196,7 @@ const INVOICE_TEMPLATE_01 = `
const INVOICE_TEMPLATE_02 = `
<!-- information -->
<table class="information_warp" border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
<table class="information_warp width100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="information_td bill" align="left">Bill To:</td>
<td class="information_td right" align="right">Invoice No. #%v</td>
@ -221,7 +221,7 @@ const INVOICE_TEMPLATE_02 = `
`
const INVOICE_TEMPLATE_03 = `
<!-- bill -->
<table class="bill_warp" border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
<table class="bill_warp width100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="bill_td title" align="left">Product Name</td>
<td class="bill_td title" align="right">Price</td>
@ -242,7 +242,7 @@ const INVOICE_TEMPLATE_0301 = `
`
const INVOICE_TEMPLATE_04 = `
<!-- total -->
<table class="total_warp" border="0" align="right" cellpadding="0" cellspacing="0" width="50%">
<table class="total_warp width50" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td class="total_td" align="right">Subtotal</td>
<td class="total_td info" align="right">%v</td>
@ -271,7 +271,7 @@ const INVOICE_TEMPLATE_04 = `
`
const INVOICE_TEMPLATE_05 = `
<!-- notes -->
<table class="notes_warp" border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
<table class="notes_warp width100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="notes_td title" align="left">Payment Method:</td>
<td class="notes_td title" align="left">Notes:</td>
@ -287,7 +287,14 @@ const INVOICE_TEMPLATE_05 = `
`
const INVOICE_TEMPLATE_06 = `
</body>
<style>
.width50 {
width: 50%;
}
.width100 {
width: 100%;
}
</style>
</html>

View File

@ -365,11 +365,15 @@ func (d *defaultOrder) Invoice(ctx context.Context, in *InvoiceReq) (res *Invoic
var city string
var street string
var state string
var suite string
var zipCode string
if ress.OrderDetail.DeliveryAddress != nil {
name = fmt.Sprintf("%s %s", ress.OrderDetail.DeliveryAddress.FirstName, ress.OrderDetail.DeliveryAddress.LastName)
street = ress.OrderDetail.DeliveryAddress.Street
city = ress.OrderDetail.DeliveryAddress.City
state = ress.OrderDetail.DeliveryAddress.State
suite = ress.OrderDetail.DeliveryAddress.Suite
zipCode = ress.OrderDetail.DeliveryAddress.ZipCode
}
var products string
@ -380,7 +384,7 @@ func (d *defaultOrder) Invoice(ctx context.Context, in *InvoiceReq) (res *Invoic
var productsInfo = fmt.Sprintf(model00301, orderProduct.ProductName, price, orderProduct.PurchaseQuantity.Current, priceTotal)
products = products + productsInfo
}
model003 = fmt.Sprintf(constants.INVOICE_TEMPLATE_03, "", products)
model003 = fmt.Sprintf(constants.INVOICE_TEMPLATE_03, products)
var subtotal = fmt.Sprintf("%s%s", constants.OrderCurrencyMessage[constants.Currency(ress.OrderDetail.OrderAmount.Subtotal.Current.CurrentCurrency)], ress.OrderDetail.OrderAmount.Subtotal.Current.CurrentAmount.(string))
var taxStr = "0.00"
@ -396,22 +400,16 @@ func (d *defaultOrder) Invoice(ctx context.Context, in *InvoiceReq) (res *Invoic
// 生成收据发票--首款
if receiptSnsDeposit != "" {
v1 := receiptSnsDeposit
v2 := name
v3 := ctimeDate
v4 := street
v5 := city
v6 := state
model002 = fmt.Sprintf(constants.INVOICE_TEMPLATE_02, "", v1, v2, v3, v4, v5, v6)
model002 = fmt.Sprintf(constants.INVOICE_TEMPLATE_02, receiptSnsDeposit, name, ctimeDate, street+" "+suite, city, state+zipCode)
v7 := "Deposit Requested"
v8 := fmt.Sprintf("%s%s", constants.OrderCurrencyMessage[constants.Currency(ress.OrderDetail.OrderAmount.Deposit.PayAmount.Current.CurrentCurrency)], ress.OrderDetail.OrderAmount.Deposit.PayAmount.Current.CurrentAmount.(string))
v9 := "Deposit Due"
v10 := v8
model004 = fmt.Sprintf(constants.INVOICE_TEMPLATE_04, "", subtotal, tax, total, v7, v8, v9, v10)
model004 = fmt.Sprintf(constants.INVOICE_TEMPLATE_04, subtotal, tax, total, v7, v8, v9, v10)
cardSn := "****" + *orderTradeDeposit.CardSn
model005 = fmt.Sprintf(constants.INVOICE_TEMPLATE_05, "", *orderTradeDeposit.CardBrand, cardSn)
model005 = fmt.Sprintf(constants.INVOICE_TEMPLATE_05, *orderTradeDeposit.CardBrand, cardSn)
var content = model001 + model002 + model003 + model004 + model005 + model006
@ -456,22 +454,16 @@ func (d *defaultOrder) Invoice(ctx context.Context, in *InvoiceReq) (res *Invoic
// 生成收据发票--尾款
if receiptSnsFinal != "" {
v1 := receiptSnsFinal
v2 := name
v3 := ctimeDate
v4 := street
v5 := city
v6 := state
model002 = fmt.Sprintf(constants.INVOICE_TEMPLATE_02, "", v1, v2, v3, v4, v5, v6)
model002 = fmt.Sprintf(constants.INVOICE_TEMPLATE_02, receiptSnsDeposit, name, ctimeDate, street+" "+suite, city, state+zipCode)
v7 := "Balance Requested"
v8 := fmt.Sprintf("%s%s", constants.OrderCurrencyMessage[constants.Currency(ress.OrderDetail.OrderAmount.RemainingBalance.PayAmount.Current.CurrentCurrency)], ress.OrderDetail.OrderAmount.RemainingBalance.PayAmount.Current.CurrentAmount.(string))
v9 := "Balance Due"
v10 := v8
model004 = fmt.Sprintf(constants.INVOICE_TEMPLATE_04, "", subtotal, tax, total, v7, v8, v9, v10)
model004 = fmt.Sprintf(constants.INVOICE_TEMPLATE_04, subtotal, tax, total, v7, v8, v9, v10)
cardSn := "****" + *orderTradeFinal.CardSn
model005 = fmt.Sprintf(constants.INVOICE_TEMPLATE_05, "", *orderTradeDeposit.CardBrand, cardSn)
model005 = fmt.Sprintf(constants.INVOICE_TEMPLATE_05, *orderTradeDeposit.CardBrand, cardSn)
var content = model001 + model002 + model003 + model004 + model005 + model006
base64, err := pdf.HtmlToPdfBase64(content, "html")
if err != nil {