This commit is contained in:
laodaming
2023-06-16 10:10:50 +08:00
parent 78c886f057
commit 9769698f22
3 changed files with 23 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ import (
func GetOrderInvoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
/*var (
var (
// 定义错误变量
err error
// 定义用户信息变量
@@ -51,7 +51,7 @@ func GetOrderInvoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
} else {
// 如果claims为nil,则认为用户身份为白板用户
userinfo = &auth.UserInfo{UserId: 0, GuestId: 0}
}*/
}
var req types.GetOrderInvoiceReq
// 如果端点有请求结构体则使用httpx.Parse方法从HTTP请求体中解析请求数据
@@ -65,7 +65,7 @@ func GetOrderInvoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
// 创建一个业务逻辑层实例
l := logic.NewGetOrderInvoiceLogic(r.Context(), svcCtx)
resp := l.GetOrderInvoice(&req, &auth.UserInfo{39, 0})
resp := l.GetOrderInvoice(&req, userinfo)
// 如果响应不为nil则使用httpx.OkJsonCtx方法返回JSON响应;
if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp)

View File

@@ -171,7 +171,7 @@ func (l *GetOrderInvoiceLogic) GetOrderInvoice(req *types.GetOrderInvoiceReq, us
mainHtml = strings.ReplaceAll(mainHtml, "{{name}}", userName)
mainHtml = strings.ReplaceAll(mainHtml, "{{first_style1}}", firstStyle1)
mainHtml = strings.ReplaceAll(mainHtml, "{{first_style2}}", firstStyle2)
mainHtml = strings.ReplaceAll(mainHtml, "{{h5Url}}", "http://www.baidu.com") // TODO ????????????
mainHtml = strings.ReplaceAll(mainHtml, "{{h5Url}}", constants.H5_URL)
mainHtml = strings.ReplaceAll(mainHtml, "{{order_expire_time}}", time.Unix(*orderInfo.Ctime, req.TimeZone*60).Format("02 Jan,2006"))
//html内容页面转pdf的base64
prfBase64, err := pdf.HtmlToPdfBase64(mainHtml, 2)