hsun 2 years ago
parent
commit
29c437609b

+ 3 - 3
models/tables/yb_suncode_pars/query.go

@@ -10,9 +10,9 @@ func (item *YbSuncodePars) Create() (err error) {
 }
 
 // GetSceneByKey 获取太阳码参数
-func GetSceneByKey(marks string) (item *YbSuncodePars, err error) {
+func GetSceneByKey(key string) (item *YbSuncodePars, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbSuncodePars{}).
-		Where("marks = ?", marks).
+		Where("scene_key = ?", key).
 		First(&item).Error
 	return
-}
+}

+ 4 - 4
models/tables/yb_suncode_pars/yb_suncode_pars.go

@@ -7,8 +7,8 @@ import (
 // YbSuncodePars 小程序太阳码scene参数
 type YbSuncodePars struct {
 	ID         uint32    `gorm:"primaryKey;column:id;type:int(10) unsigned;not null" json:"-"`
-	Scene      string    `gorm:"column:scene;type:varchar(255);not null;default:''" json:"scene"` // scene参数
-	Key        string    `gorm:"column:key;type:varchar(32);not null;default:''" json:"key"`      // MD5值
+	Scene      string    `gorm:"column:scene;type:varchar(255);not null;default:''" json:"scene"`        // scene参数
+	SceneKey   string    `gorm:"column:scene_key;type:varchar(32);not null;default:''" json:"scene_key"` // MD5值
 	CreateTime time.Time `gorm:"column:create_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createTime"`
 }
 
@@ -20,12 +20,12 @@ func (m *YbSuncodePars) TableName() string {
 // YbSuncodeParsColumns get sql column name.获取数据库列名
 var YbSuncodeParsColumns = struct {
 	ID         string
-	Scene      string
+	SceneKey   string
 	Key        string
 	CreateTime string
 }{
 	ID:         "id",
-	Scene:      "scene",
+	SceneKey:   "scene_key",
 	Key:        "key",
 	CreateTime: "create_time",
 }

+ 33 - 0
services/oss.go

@@ -88,3 +88,36 @@ func UploadVideoAliyun(filename, filepath, savePath string) error {
 	//return path,err
 	return err
 }
+
+
+var (
+	Bucketname       string = "hzchart"
+	Endpoint         string = "oss-cn-shanghai.aliyuncs.com"
+	Imghost          string = "https://hzstatic.hzinsights.com/"
+	UploadDir		 string = "static/images/"
+	AccessKeyId      string = "LTAIFMZYQhS2BTvW"
+	AccessKeySecret  string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
+)
+
+// UploadAliyunToDir
+func UploadAliyunToDir(filename, filepath, fileDir string) (string, error) {
+	client, err := oss.New(Endpoint, AccessKeyId, AccessKeySecret)
+	if err != nil {
+		return "1", err
+	}
+	bucket, err := client.Bucket(Bucketname)
+	if err != nil {
+		return "2", err
+	}
+	if fileDir == "" {
+		fileDir = time.Now().Format("200601/20060102/")
+	}
+	path := UploadDir + fileDir
+	path += filename
+	err = bucket.PutObjectFromFile(path, filepath)
+	if err != nil {
+		return "3", err
+	}
+	path = Imghost + path
+	return path, err
+}

+ 31 - 16
services/share_poster.go

@@ -40,14 +40,17 @@ func CreatePosterFromSource(codePage, codeScene, source, version, pars string) (
 		return
 	}
 	path := fmt.Sprint(codePage, "?", codeScene)
-	// 获取海报, 无海报则生成
-	poster, err := yb_poster_resource.GetPosterByCondition(path, "poster", version)
-	if err != nil && err != utils.ErrNoRow {
-		return
-	}
-	if poster != nil && poster.ImgURL != "" {
-		imgUrl = poster.ImgURL
-		return
+	// 非列表来源获取历史图片,无则生成
+	if !strings.Contains(source, "list") {
+		poster, tmpErr := yb_poster_resource.GetPosterByCondition(path, "poster", version)
+		if tmpErr != nil && tmpErr != utils.ErrNoRow {
+			err = tmpErr
+			return
+		}
+		if poster != nil && poster.ImgURL != "" {
+			imgUrl = poster.ImgURL
+			return
+		}
 	}
 	// 图片长宽
 	heightMap := map[string]int{
@@ -207,7 +210,8 @@ func CreateAndUploadSunCode(page, scene, version string) (imgUrl string, err err
 		os.Remove(fpath)
 	}()
 	// 上传OSS
-	imgUrl, err = UploadAliyun(fileName, fpath)
+	fileDir := "yb/suncode/"
+	imgUrl, err = UploadAliyunToDir(fileName, fpath, fileDir)
 	if err != nil {
 		return
 	}
@@ -227,7 +231,7 @@ func CreateAndUploadSunCode(page, scene, version string) (imgUrl string, err err
 	if scene != "" {
 		newPars := &yb_suncode_pars.YbSuncodePars{
 			Scene:      scene,
-			Key:        sceneMD5,
+			SceneKey:   sceneMD5,
 			CreateTime: time.Now(),
 		}
 		err = newPars.Create()
@@ -282,6 +286,7 @@ func fillContent2Html(source string, pars, sunCodeUrl string) (contentStr string
 	}
 	contentStr = string(contentByte)
 	// 列表的动态内容不完整的用默认内容的填充
+	emptyTime := false
 	if strings.Contains(source, "list") {
 		if params.Title1 == "" || params.Title2 == "" {
 			defaultAvatar := "https://hzstatic.hzinsights.com/static/images/202112/20211210/wn6c3oYKTfT4NbTZgRGflRuIBZaa.png"
@@ -296,6 +301,9 @@ func fillContent2Html(source string, pars, sunCodeUrl string) (contentStr string
 				params.Title2 = "周度报告"
 				params.Speaker1 = "FICC研究员"
 				params.Speaker2 = "FICC研究员"
+				params.Time1 = "2022-5-10"
+				params.Time2 = "2022-5-10"
+				emptyTime = true
 			case "special_column_list":
 				params.Stage1 = "第1期"
 				params.Stage2 = "第2期"
@@ -380,14 +388,14 @@ func fillContent2Html(source string, pars, sunCodeUrl string) (contentStr string
 			"已结束": "none",
 		}
 		offlineMap := map[string]string{
-			"线上会议": "block",
-			"线下沙龙": "none",
-		}
-		onlineMap := map[string]string{
 			"线上会议": "none",
 			"线下沙龙": "block",
 		}
-		contentStr = strings.Replace(contentStr, "{{LIST_TITLE}}", params.ListTitle, 1)
+		onlineMap := map[string]string{
+			"线上会议": "block",
+			"线下沙龙": "none",
+		}
+		contentStr = strings.Replace(contentStr, "{{LIST_TITLE}}", "弘则FICC周度电话会安排", 1)
 		contentStr = strings.Replace(contentStr, "{{BG_COLORE_1}}", bgColorMap[params.Status1], 1)
 		contentStr = strings.Replace(contentStr, "{{STATUS_1}}", params.Status1, 1)
 		contentStr = strings.Replace(contentStr, "{{AVATAR_1}}", params.Avatar1, 1)
@@ -404,8 +412,15 @@ func fillContent2Html(source string, pars, sunCodeUrl string) (contentStr string
 		contentStr = strings.Replace(contentStr, "{{SPEAKER_2}}", params.Speaker2, 1)
 		contentStr = strings.Replace(contentStr, "{{TIME_2}}", params.Time2, 1)
 		contentStr = strings.Replace(contentStr, "{{SHOW_ITEM_2}}", statusItemMap[params.Status2], 1)
-		contentStr = strings.Replace(contentStr, "{{SHOW_OFFLINE_2}}", statusItemMap[params.ListTitle], 1)
+		contentStr = strings.Replace(contentStr, "{{SHOW_OFFLINE_2}}", offlineMap[params.ListTitle], 1)
 		contentStr = strings.Replace(contentStr, "{{SHOW_ONLINE_2}}", onlineMap[params.ListTitle], 1)
+		if emptyTime {
+			contentStr = strings.Replace(contentStr, "{{TIME_COLOR_1}}", "#fff", 1)
+			contentStr = strings.Replace(contentStr, "{{TIME_COLOR_2}}", "#fff", 1)
+		} else {
+			contentStr = strings.Replace(contentStr, "{{TIME_COLOR_1}}", "#999", 1)
+			contentStr = strings.Replace(contentStr, "{{TIME_COLOR_2}}", "#999", 1)
+		}
 	}
 	contentStr = strings.Replace(contentStr, "{{SUN_CODE}}", sunCodeUrl, 1)
 	return

+ 6 - 6
static/htm2img/activity_list.html

@@ -113,15 +113,15 @@
                     <div class="item-con">
                         <div class="text-one name">{{TITLE_1}}</div>
                         <div style="color: #666;font-size: 48px;">主讲:{{SPEAKER_1}}</div>
-                        <div style="font-size: 40px;color: #999;margin-top: 20px;">{{TIME_1}}</div>
+                        <div style="font-size: 40px;color: #999;margin-top: 20px;color: {{TIME_COLOR_1}};">{{TIME_1}}</div>
                     </div>
                 </div>
                 <!-- 如果非预告则下面style 加上 display:none -->
                 <div style="display: {{SHOW_ITEM_1}}" >
                     <!-- 如果是线下沙龙则设置 display:none -->
-                    <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;display: {{SHOW_OFFLINE_1}};">会议提醒</div>
+                    <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;display: {{SHOW_ONLINE_1}};">会议提醒</div>
                     <!-- 如果是线上会议则设置 display:none -->
-                    <div style="display: {{SHOW_ONLINE_1}}" >
+                    <div style="display: {{SHOW_OFFLINE_1}}" >
                         <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;float: left;width: 50%;border-right: 1px solid #EBEDF0;">会议提醒</div>
                         <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;float: left;width: 50%;">报名线下参会</div>
                     </div>
@@ -135,15 +135,15 @@
                     <div class="item-con">
                         <div class="text-one name">{{TITLE_2}}</div>
                         <div style="color: #666;font-size: 48px;">主讲:{{SPEAKER_2}}</div>
-                        <div style="font-size: 40px;color: #999;margin-top: 20px;">{{TIME_2}}</div>
+                        <div style="font-size: 40px;color: #999;margin-top: 20px;color: {{TIME_COLOR_2}};">{{TIME_2}}</div>
                     </div>
                 </div>
                 <!-- 如果非预告则下面style 加上 display:none -->
                 <div style="display: {{SHOW_ITEM_2}}" >
                     <!-- 如果是线下沙龙则设置 display:none -->
-                    <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;display: {{SHOW_OFFLINE_2}};">会议提醒</div>
+                    <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;display: {{SHOW_ONLINE_2}};">会议提醒</div>
                     <!-- 如果是线上会议则设置 display:none -->
-                    <div style="display: {{SHOW_ONLINE_2}}" >
+                    <div style="display: {{SHOW_OFFLINE_2}}" >
                         <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;float: left;width: 50%;border-right: 1px solid #EBEDF0;">会议提醒</div>
                         <div style="text-align: center;color: #E3B377;font-size: 44px;line-height: 112px;float: left;width: 50%;">报名线下参会</div>
                     </div>

+ 1 - 1
static/htm2img/chart_list.html

@@ -87,7 +87,7 @@
                 <img class="item-img" src="{{IMG_2}}" alt="">
             </div>
         </div>
-        <div style="text-align:center;font-size:14px;color:#999">长按图片分享</div>
+        <div style="text-align:center;font-size:56px;color:#999">长按图片分享</div>
         <div class="flex">
             <div style="float: left;">
                 <div>长按识别小程序码</div>

+ 15 - 6
static/htm2img/report_detail.html

@@ -53,14 +53,23 @@
             height: 256px;
             float: right;
         }
-        .content-box div{
-            font-size: 36px !important;
+        .content-box div {
+            font-size: 34px !important;
+            overflow: inherit !important;
+            line-height: 1.7 !important;
         }
-        .content-box span{
-            font-size: 36px !important;
+        .content-box span {
+            font-size: 34px !important;
+            line-height: 1.7 !important;
         }
-        .content-box p{
-            font-size: 36px !important;
+        .content-box p {
+            font-size: 34px !important;
+            overflow: inherit !important;
+            line-height: 1.7 !important;
+        }
+        .content-box section{
+            overflow: inherit !important;
+            line-height: 1.7 !important;
         }
     </style>
 </head>

+ 1 - 1
static/htm2img/report_list.html

@@ -125,7 +125,7 @@
                 <div>长按识别小程序码</div>
                 <div style="color:#999">查看更多</div>
             </div>
-            <img class="xcx-img" src="" alt="">
+            <img class="xcx-img" src="{{SUN_CODE}}" alt="">
         </div>
     </div>
 </body>