报价单接近完成

This commit is contained in:
eson
2023-06-27 18:09:56 +08:00
parent 116171dddd
commit 13c5a45a5e
15 changed files with 1274 additions and 39 deletions

View File

@@ -25,27 +25,30 @@ func QuotationDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
userinfo *auth.BackendUserInfo
)
// 解析JWT token,并对空用户进行判断
claims, err := svcCtx.ParseJwtToken(r)
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
if err != nil || claims == nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
Code: 401, // 返回401状态码,表示未授权
Message: "unauthorized", // 返回未授权信息
})
logx.Info("unauthorized:", err.Error()) // 记录错误日志
return
}
// claims, err := svcCtx.ParseJwtToken(r)
// // 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
// if err != nil || claims == nil {
// httpx.OkJsonCtx(r.Context(), w, &basic.Response{
// Code: 401, // 返回401状态码,表示未授权
// Message: "unauthorized", // 返回未授权信息
// })
// logx.Info("unauthorized:", err.Error()) // 记录错误日志
// return
// }
// 从token中获取对应的用户信息
userinfo, err = auth.GetBackendUserInfoFormMapClaims(claims)
// 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
// // 从token中获取对应的用户信息
// userinfo, err = auth.GetBackendUserInfoFormMapClaims(claims)
// // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
// if err != nil {
// httpx.OkJsonCtx(r.Context(), w, &basic.Response{
// Code: 401,
// Message: "unauthorized",
// })
// logx.Info("unauthorized:", err.Error())
// return
// }
if err != nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
Code: 401,
Message: "unauthorized",
})
logx.Info("unauthorized:", err.Error())
return
}
var req types.RequestQuotationId

View File

@@ -1,11 +1,16 @@
package logic
import (
"bytes"
"encoding/json"
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/collect"
"fusenapi/utils/format"
"log"
"strings"
"text/template"
"context"
@@ -44,6 +49,200 @@ func GetPrice(num int64, stepNum []int64, stepPrice []int64) int64 {
return 0
}
// GetDemoHtml 报价单
func (l *QuotationDetailLogic) GetDemoHtml(quot *gmodel.FsQuotation, quotationProduct []*gmodel.FsQuotationProduct) (htmlcontent string, err error) {
saler, err := l.svcCtx.AllModels.FsQuotationSaler.GetOne(l.ctx, quot.Id)
if err != nil {
return "", err
}
log.Println(saler)
// htmlContent := ""
priceHtml := ""
// productNum := len(quotationProduct)
// page := 3
// pageTotal := 3 + productNum
for _, quotProduct := range quotationProduct {
var priceInfo []map[string]interface{}
err := json.Unmarshal([]byte(*quotProduct.PriceInfo), &priceInfo)
if err != nil {
return "", err
}
priceHtmlTpl := `
{{range $i, $parr := .priceInfo}}
{{if lt $i 3}}
<div class="pr-card">
<p class="pr">${{$parr.price}}</p>
<p class="num">{{$parr.num}}<span> Units</span></p>
</div>
{{else}}
<div class="pr-card" style="margin-right: 8px;">
<p class="pr">${{$parr.price}}</p>
<p class="num">{{$parr.num}}<span> Units</span></p>
</div>
{{end}}
{{end}}`
tpl := template.Must(template.New("prCardTpl").Parse(priceHtmlTpl))
buf := &bytes.Buffer{}
err = tpl.Execute(buf, map[string]interface{}{
"priceInfo": priceInfo,
})
if err != nil {
log.Println(err)
return "", err
}
priceHtml = buf.String()
}
tplcontent := `
{{$product_num := len .products}}
{{$page := 3}}
{{$page_total := add $page $product_num}}
{{range $arr := .products}}
{{$price := json_decode $arr.price_info}}
{{$price_html := .priceHtml}}
{{$price_html}}
{{if gt $arr.is_gift 0 }}{{/* 赠品 */}}
<div class="box">
<div style="position: relative; margin-bottom: 30px;">
<p class="f-m" style="font-size: 39px; font-weight: 800; margin-bottom: 12px; line-height: 32px;">{{$arr.name}}</p>
<p class="f-b" style="font-size: 25px; font-weight: 800;line-height: 19px;">{{$arr.size}}</p>
<div class="logo">
<img src="https://fusenapi.kayue.cn:8010/storage/pdf/logo.svg" alt="logo">
</div>
</div>
<div class="img-box" style="height: 611px;margin-bottom: 32px; overflow: hidden;">
<div class="img" style="background-image: url({{$arr.img}});"></div>
</div>
<div>
<div class="pr-card big">
<p class="pr">FREE!</p>
<p class="num">{{$arr.num}}<span> Units</span></p>
</div>
<div>
<div class="card-box" style="display: inline-block;width: 183px;line-height: 36px;padding-left: 16px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">Lead Time</div>
<div class="card-box" style="display: inline-block;width: 183px;height: 52px; padding-left: 15px;margin-bottom: 8px;background-color: #E0E2EB; font-weight: 600;">
<span style="font-size: 35px;line-height: 52px;">{{$arr.cycle}}</span><span style="font-size: 26px;line-height: 52px;">Days</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Design</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Storage</span>
</div>
<div class="card-box more-card" style="margin-bottom: 0;">
<span class="free">FREE </span><span class="text">Shipping</span>
</div>
</div>
</div>
</div>
{{else}}{{/* 非赠品 */}}
{{if $arr.size}}
// 有尺寸的
<div class="box">
<div style="position: relative; margin-bottom: 30px;">
<p class="f-m" style="font-size: 39px; font-weight: 800; margin-bottom: 12px; line-height: 32px;">{{$arr.name}}</p>
<p class="f-b" style="font-size: 25px; font-weight: 800;line-height: 19px;">{{$arr.size}}</p>
<div class="logo">
<img src="https://fusenapi.kayue.cn:8010/storage/pdf/logo.svg" alt="logo">
</div>
</div>
<div class="img-box" style="height: 611px;margin-bottom: 32px; overflow: hidden;">
<div class="img"
style="background-image: url({{$arr.img}});"></div>
</div>
<div>
<div class="card-box"
style="float: left; width: 530px;line-height: 36px;padding-left: 19px;margin-right: 8px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">Unit Price (Tax included)</div>
<div class="card-box"
style="display: inline-block;width: 183px;line-height: 36px;padding-left: 16px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">
Lead Time</div>
{{$price_html}}
<div>
<div class="card-box"
style="display: inline-block;width: 183px;height: 52px; padding-left: 15px;margin-bottom: 8px;background-color: #E0E2EB; font-weight: 600;">
<span style="font-size: 35px;line-height: 52px;">{{$arr.cycle}}</span><span
style="font-size: 26px;line-height: 52px;">Days</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Design</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Storage</span>
</div>
<div class="card-box more-card" style="margin-bottom: 0;">
<span class="free">FREE </span><span class="text">Shipping</span>
</div>
</div>
</div>
</div>
{{else}}
<div class="box">
<div style="position: relative; margin-bottom: 32px;">
<p class="f-m" style="font-size: 39px; font-weight: 800; margin-bottom: 3px; line-height: 32px;">
{{$arr.name}}</p>
<div class="logo">
<img src="https://fusenapi.kayue.cn:8010/storage/pdf/logo.svg" alt="logo">
</div>
</div>
<div class="img-box" style="height: 641px;margin-bottom: 31px; overflow: hidden;">
<div class="img" style="background-image: url({{$arr.img}});">
</div>
</div>
<div>
<div class="card-box"
style="float: left;width: 530px;line-height: 36px;padding-left: 19px;margin-right: 8px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">
Unit Price (Tax included)</div>
<div class="card-box"
style="display: inline-block;width: 183px;line-height: 36px;padding-left: 16px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">
Lead Time</div>
{{$price_html}}
<div>
<div class="card-box"
style="display: inline-block;width: 183px;height: 52px; padding-left: 15px;margin-bottom: 8px;background-color: #E0E2EB; font-weight: 600;">
<span style="font-size: 35px;line-height: 52px;">{{$arr.cycle}}</span><span
style="font-size: 26px;line-height: 52px;">Days</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Design</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Storage</span>
</div>
<div class="card-box more-card" style="margin-bottom: 0;">
<span class="free">FREE </span><span class="text">Shipping</span>
</div>
</div>
</div>
</div>
{{end}}
{{end}}
<div class="page-box" style="background-color: rgba(125, 125, 125, 0.16);color: #000;text-align: center;height: 50px;line-height: 50px;margin-top: 30px;">{{$page}}/{{$page_total}}</div>
{{$page = add $page 1}}
{{end}} `
tpl := template.New("demo")
tpl = tpl.Funcs(format.TemplateFuncMap)
tpl = template.Must(tpl.Parse(tplcontent))
buf := bytes.NewBufferString("")
tpl.Execute(buf, map[string]interface{}{
"products": collect.StructSliceJson2Maps(quotationProduct),
"price_html": priceHtml,
})
htmlContent := buf.String()
log.Println(htmlContent)
return htmlContent, nil
}
func (l *QuotationDetailLogic) QuotationDetail(req *types.RequestQuotationId, userinfo *auth.BackendUserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
@@ -63,15 +262,15 @@ func (l *QuotationDetailLogic) QuotationDetail(req *types.RequestQuotationId, us
return resp.SetStatus(basic.CodeDbSqlErr)
}
quotation, err := l.svcCtx.AllModels.FsQuotationProduct.GetAllByQuotationIdOrderAsc(l.ctx, req.QuotationId)
quotationProduct, err := l.svcCtx.AllModels.FsQuotationProduct.GetAllByQuotationIdOrderAsc(l.ctx, req.QuotationId)
if err != nil {
if err != gorm.ErrRecordNotFound {
return resp.SetStatus(basic.CodeDbSqlErr)
}
}
var target any = quotation
if len(quotation) == 0 {
var target any = quotationProduct
if len(quotationProduct) == 0 {
target = CanteenProduct
}
@@ -83,26 +282,38 @@ func (l *QuotationDetailLogic) QuotationDetail(req *types.RequestQuotationId, us
list := gjson.ParseBytes(jdata)
qFlag := len(quotation) > 0
qFlag := len(quotationProduct) > 0
//获取备注模板
markList, err := l.svcCtx.AllModels.FsQuotationRemarkTemplate.GetAllSelectContent(l.ctx)
// markList, err := l.svcCtx.AllModels.FsQuotationRemarkTemplate.GetAllSelectContent(l.ctx)
var productIds = collect.ArrayColumnTag[int64](CanteenProduct, "product_id")
productList, err := l.svcCtx.AllModels.FsProduct.FindAllOnlyByIds(l.ctx, productIds)
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeDbSqlErr)
}
productListMap := collect.Array2MapByKeyTag[int64](productList, "id")
//获取size信息
var sizeIds = collect.ArrayColumnTag[int64](CanteenProduct, "size_id")
sizes, err := l.svcCtx.AllModels.FsProductSize.GetAllSelectIdAndCapacityByIds(l.ctx, sizeIds)
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeDbSqlErr)
}
sizesMap := collect.Array2MapByKeyTag[int64](sizes, "id")
//获取价格信息
productPrice, err := l.svcCtx.AllModels.FsProductPrice.GetAllSelectBySizeId(l.ctx, sizeIds)
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeDbSqlErr)
}
productPriceMap := collect.Array2MapByKeyTag[int64](productPrice, "size_id")
// product := []map[string]interface{}{}
product := []map[string]interface{}{}
products := []map[string]interface{}{}
for _, parr := range list.Array() {
var priceList []map[string]int64
@@ -195,7 +406,7 @@ func (l *QuotationDetailLogic) QuotationDetail(req *types.RequestQuotationId, us
num = 1
}
product = append(product, map[string]interface{}{
products = append(products, map[string]interface{}{
"id": Id,
"s_id": sid,
"is_gift": isGift,
@@ -210,5 +421,11 @@ func (l *QuotationDetailLogic) QuotationDetail(req *types.RequestQuotationId, us
}
htmlContent, err := l.GetDemoHtml(&quot, quotationProduct)
if err != nil {
panic(err)
}
log.Println(htmlContent)
return resp.SetStatus(basic.CodeOK)
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"fusenapi/server/backend/internal/config"
"net/http"
"time"
"fusenapi/initalize"
"fusenapi/model/gmodel"
@@ -21,11 +22,11 @@ type ServiceContext struct {
}
func NewServiceContext(c config.Config) *ServiceContext {
db := initalize.InitMysql(c.SourceMysql).Set("gorm:slow_query_time", time.Second*15)
return &ServiceContext{
Config: c,
MysqlConn: initalize.InitMysql(c.SourceMysql),
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
AllModels: gmodel.NewAllModels(db),
}
}

View File

@@ -0,0 +1,35 @@
package test
import (
"fmt"
"fusenapi/server/backend/internal/config"
"fusenapi/server/backend/internal/handler"
"fusenapi/server/backend/internal/svc"
"log"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
)
var testConfigFile = "../etc/backend.yaml"
var cnf config.Config
var gserver *rest.Server
func init() {
log.SetFlags(log.Llongfile)
gserver = GetTestServer()
}
func GetTestServer() *rest.Server {
conf.MustLoad(testConfigFile, &cnf)
server := rest.MustNewServer(cnf.RestConf)
defer server.Stop()
ctx := svc.NewServiceContext(cnf)
handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", cnf.Host, cnf.Port)
return server
}

View File

@@ -0,0 +1,29 @@
package test
import (
"fmt"
fstests "fusenapi/utils/tests"
"log"
"testing"
)
func TestCaseQuotationDetail(t *testing.T) {
ses := fstests.GetSesssionWithUserToken(t, gserver, cnf.Host, cnf.Port)
// 构建新增地址请求体
// addrReq := types.RequestQuotationId{
// QuotationId: 1003,
// }
// 向服务器发送 POST 请求,新增用户地址
tp := ses.Get(fmt.Sprintf("http://%s:%d//quotation/detail", cnf.Host, cnf.Port))
tp.QueryParam("id").Set(1003)
resp, err := tp.TestExecute(gserver)
log.Println(resp.Json())
if err != nil {
t.Error(err)
return
}
log.Println(resp.Json())
}

View File

@@ -0,0 +1,314 @@
package test
import (
"bytes"
"fusenapi/model/gmodel"
"fusenapi/utils/collect"
"fusenapi/utils/format"
"html/template"
"log"
"testing"
)
func TestCaseTpl(t *testing.T) {
priceInfo := []map[string]interface{}{
{"Price": "$10", "Num": 100},
{"Price": "$20", "Num": 200},
{"Price": "$30", "Num": 300},
{"Price": "$40", "Num": 400},
}
priceHtml := `
{{range $i, $parr := .}}
{{if lt $i 3}}
<div class="pr-card">
<p class="pr">${{$parr.Price}}</p>
<p class="num">{{$parr.Num}}<span> Units</span></p>
</div>
{{else}}
<div class="pr-card" style="margin-right: 8px;">
<p class="pr">${{$parr.Price}}</p>
<p class="num">{{$parr.Num}}<span> Units</span></p>
</div>
{{end}}
{{end}}`
tpl := template.Must(template.New("demoHtml").Parse(priceHtml))
buf := bytes.NewBufferString("")
tpl.Execute(buf, priceInfo)
html := buf.String()
log.Println(html)
}
func Randomproduct() []*gmodel.FsQuotationProduct {
var quotationId1 int64 = 1
name1 := "T恤"
size1 := "S,M,L,XL,XXL"
var cycle1 int64 = 7
var isGift1 int64 = 0
img1 := "https://xxx.jpg"
var status1 int64 = 1
var ctime1 int64 = 1623311101
var sort1 int64 = 1
sid1 := "abcd1234"
priceInfo1 := `[{"num":500,"price":0.1},{"num":1000,"price":0.06},{"num":1500,"price":0.06}]`
remark1 := ""
var num1 int64 = 100
var quotationId2 int64 = 1
name2 := "帽子"
size2 := "通用"
var cycle2 int64 = 3
var isGift2 int64 = 1
img2 := "https://xxx.jpg"
var status2 int64 = 1
var ctime2 int64 = 1623311102
var sort2 int64 = 2
sid2 := "abcd1235"
priceInfo2 := `[{"num":500,"price":0.1},{"num":1000,"price":0.06},{"num":1500,"price":0.06}]`
remark2 := ""
var num2 int64 = 50
var quotationId3 int64 = 2
name3 := "水壶"
size3 := "350ml,500ml,650ml"
var cycle3 int64 = 14
var isGift3 int64 = 0
img3 := "https://xxx.jpg"
var status3 int64 = 1
var ctime3 int64 = 1623311103
var sort3 int64 = 1
sid3 := "abcd1236"
priceInfo3 := `[{"num":500,"price":0.1},{"num":1000,"price":0.06},{"num":1500,"price":0.06}]`
remark3 := ""
var num3 int64 = 200
var quotationId4 int64 = 2
name4 := "手机壳"
size4 := "iPhoneX,iPhoneXS,iPhoneXR"
var cycle4 int64 = 5
var isGift4 int64 = 1
img4 := "https://xxx.jpg"
var status4 int64 = 1
var ctime4 int64 = 1623311104
var sort4 int64 = 2
sid4 := "abcd1237"
priceInfo4 := `[{"num":500,"price":0.1},{"num":1000,"price":0.06},{"num":1500,"price":0.06}]`
remark4 := "可定制颜料颜色"
var num4 int64 = 150
products := []*gmodel.FsQuotationProduct{
&gmodel.FsQuotationProduct{
Id: 1,
QuotationId: &quotationId1,
Name: &name1,
Size: &size1,
Cycle: &cycle1,
IsGift: &isGift1,
Img: &img1,
Status: &status1,
Ctime: &ctime1,
Sort: &sort1,
Sid: &sid1,
PriceInfo: &priceInfo1,
Remark: &remark1,
Num: &num1,
},
&gmodel.FsQuotationProduct{
Id: 2,
QuotationId: &quotationId2,
Name: &name2,
Size: &size2,
Cycle: &cycle2,
IsGift: &isGift2,
Img: &img2,
Status: &status2,
Ctime: &ctime2,
Sort: &sort2,
Sid: &sid2,
PriceInfo: &priceInfo2,
Remark: &remark2,
Num: &num2,
},
&gmodel.FsQuotationProduct{
Id: 3,
QuotationId: &quotationId3,
Name: &name3,
Size: &size3,
Cycle: &cycle3,
IsGift: &isGift3,
Img: &img3,
Status: &status3,
Ctime: &ctime3,
Sort: &sort3,
Sid: &sid3,
PriceInfo: &priceInfo3,
Remark: &remark3,
Num: &num3,
},
&gmodel.FsQuotationProduct{
Id: 4,
QuotationId: &quotationId4,
Name: &name4,
Size: &size4,
Cycle: &cycle4,
IsGift: &isGift4,
Img: &img4,
Status: &status4,
Ctime: &ctime4,
Sort: &sort4,
Sid: &sid4,
PriceInfo: &priceInfo4,
Remark: &remark4,
Num: &num4,
},
}
return products
}
func TestTpl2(t *testing.T) {
products := Randomproduct()
tplcontent := `
{{$product_num := len .products}}
{{$page := 3}}
{{$page_total := add $page $product_num}}
{{range $arr := .products}}
{{$price := json_decode $arr.price_info}}
{{$price_html := .priceHtml}}
{{$price_html}}
{{if gt $arr.is_gift 0 }}{{/* 赠品 */}}
// 赠品
<div class="box">
<div style="position: relative; margin-bottom: 30px;">
<p class="f-m" style="font-size: 39px; font-weight: 800; margin-bottom: 12px; line-height: 32px;">{{$arr.name}}</p>
<p class="f-b" style="font-size: 25px; font-weight: 800;line-height: 19px;">{{$arr.size}}</p>
<div class="logo">
<img src="https://fusenapi.kayue.cn:8010/storage/pdf/logo.svg" alt="logo">
</div>
</div>
<div class="img-box" style="height: 611px;margin-bottom: 32px; overflow: hidden;">
<div class="img" style="background-image: url({{$arr.img}});"></div>
</div>
<div>
<div class="pr-card big">
<p class="pr">FREE!</p>
<p class="num">{{$arr.num}}<span> Units</span></p>
</div>
<div>
<div class="card-box" style="display: inline-block;width: 183px;line-height: 36px;padding-left: 16px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">Lead Time</div>
<div class="card-box" style="display: inline-block;width: 183px;height: 52px; padding-left: 15px;margin-bottom: 8px;background-color: #E0E2EB; font-weight: 600;">
<span style="font-size: 35px;line-height: 52px;">{{$arr.cycle}}</span><span style="font-size: 26px;line-height: 52px;">Days</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Design</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Storage</span>
</div>
<div class="card-box more-card" style="margin-bottom: 0;">
<span class="free">FREE </span><span class="text">Shipping</span>
</div>
</div>
</div>
</div>
{{else}}{{/* 非赠品 */}}
{{if $arr.size}}
// 有尺寸的
<div class="box">
<div style="position: relative; margin-bottom: 30px;">
<p class="f-m" style="font-size: 39px; font-weight: 800; margin-bottom: 12px; line-height: 32px;">{{$arr.name}}</p>
<p class="f-b" style="font-size: 25px; font-weight: 800;line-height: 19px;">{{$arr.size}}</p>
<div class="logo">
<img src="https://fusenapi.kayue.cn:8010/storage/pdf/logo.svg" alt="logo">
</div>
</div>
<div class="img-box" style="height: 611px;margin-bottom: 32px; overflow: hidden;">
<div class="img"
style="background-image: url({{$arr.img}});"></div>
</div>
<div>
<div class="card-box"
style="float: left; width: 530px;line-height: 36px;padding-left: 19px;margin-right: 8px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">Unit Price (Tax included)</div>
<div class="card-box"
style="display: inline-block;width: 183px;line-height: 36px;padding-left: 16px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">
Lead Time</div>
{{$price_html}}
<div>
<div class="card-box"
style="display: inline-block;width: 183px;height: 52px; padding-left: 15px;margin-bottom: 8px;background-color: #E0E2EB; font-weight: 600;">
<span style="font-size: 35px;line-height: 52px;">{{$arr.cycle}}</span><span
style="font-size: 26px;line-height: 52px;">Days</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Design</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Storage</span>
</div>
<div class="card-box more-card" style="margin-bottom: 0;">
<span class="free">FREE </span><span class="text">Shipping</span>
</div>
</div>
</div>
</div>
{{else}}
<div class="box">
<div style="position: relative; margin-bottom: 32px;">
<p class="f-m" style="font-size: 39px; font-weight: 800; margin-bottom: 3px; line-height: 32px;">
{{$arr.name}}</p>
<div class="logo">
<img src="https://fusenapi.kayue.cn:8010/storage/pdf/logo.svg" alt="logo">
</div>
</div>
<div class="img-box" style="height: 641px;margin-bottom: 31px; overflow: hidden;">
<div class="img" style="background-image: url({{$arr.img}});">
</div>
</div>
<div>
<div class="card-box"
style="float: left;width: 530px;line-height: 36px;padding-left: 19px;margin-right: 8px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">
Unit Price (Tax included)</div>
<div class="card-box"
style="display: inline-block;width: 183px;line-height: 36px;padding-left: 16px;margin-bottom: 4px;background-color: #C2C5CB;font-size: 18px; font-weight: 500;">
Lead Time</div>
{{$price_html}}
<div>
<div class="card-box"
style="display: inline-block;width: 183px;height: 52px; padding-left: 15px;margin-bottom: 8px;background-color: #E0E2EB; font-weight: 600;">
<span style="font-size: 35px;line-height: 52px;">{{$arr.cycle}}</span><span
style="font-size: 26px;line-height: 52px;">Days</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Design</span>
</div>
<div class="card-box more-card">
<span class="free">FREE </span><span class="text">Storage</span>
</div>
<div class="card-box more-card" style="margin-bottom: 0;">
<span class="free">FREE </span><span class="text">Shipping</span>
</div>
</div>
</div>
</div>
{{end}}
{{end}}
<div class="page-box" style="background-color: rgba(125, 125, 125, 0.16);color: #000;text-align: center;height: 50px;line-height: 50px;margin-top: 30px;">{{$page}}/{{$page_total}}</div>
{{$page = add $page 1}}
{{end}} `
tpl := template.New("demo")
tpl.Funcs(format.TemplateFuncMap)
tpl = template.Must(tpl.Parse(tplcontent))
buf := bytes.NewBufferString("")
tpl.Execute(buf, map[string]interface{}{"products": collect.StructSliceJson2Maps(products)})
html := buf.String()
log.Println(html)
}