Browse Source

no message

xingzai 6 months ago
parent
commit
2a4ecc1d65
3 changed files with 76 additions and 0 deletions
  1. 6 0
      controllers/activity.go
  2. 5 0
      models/activity.go
  3. 65 0
      services/activity.go

+ 6 - 0
controllers/activity.go

@@ -567,6 +567,12 @@ func (this *ActivityCoAntroller) Detail() {
 			resp.SellerMobile = sellerMobile
 		}
 	}
+
+	//获取活动对应的封面图
+	mapUrl := services.GetActivityImgMap([]*models.ActivityDetail{activityInfo})
+	if mapUrl[activityId] != nil {
+		activityInfo.ImgUrl = mapUrl[activityId].ImgUrl
+	}
 	//处理按钮是否展示问题
 	resp.Detail = services.ActivityButtonShow(activityInfo)
 	collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)

+ 5 - 0
models/activity.go

@@ -246,6 +246,11 @@ type ListArticleActivity struct {
 	ArtleId int    `description:"产业id"`
 }
 
+type ActivityImgUrlMapResp struct {
+	ImgUrl     string `description:"图片链接"`
+	ImgUrlText string `description:"图片链接文字"`
+}
+
 type CygxActivityResp struct {
 	HaqveJurisdiction bool   `description:"是否有权限"`
 	OperationMode     string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`

+ 65 - 0
services/activity.go

@@ -3023,3 +3023,68 @@ func GetActivityTypeIdMap() (mapResp map[int]int) {
 	}
 	return
 }
+
+// 获取活动封面图片
+func GetActivityImgMap(items []*models.ActivityDetail) (mapResp map[int]*models.ActivityImgUrlMapResp) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取活动封面图片,失败,GetActivityImgMap:Err "+err.Error(), 2)
+		}
+	}()
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode city_img_url, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode chart_img_url , Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]*models.ActivityImgUrlMapResp, 0)
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+
+	for _, v := range items {
+		//if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
+		//	v.ImgUrlText = utils.YAN_XUAN_IMG
+		//}
+		if v.ActivityType == 0 {
+			if mapAddress[v.City] != "" {
+				v.ImgUrl = mapAddress[v.City]
+			} else {
+				v.ImgUrl = mapAddress["其它"]
+			}
+		} else {
+			if mapChart[v.ChartPermissionName] != "" {
+				v.ImgUrl = mapChart[v.ChartPermissionName]
+			}
+		}
+		item := new(models.ActivityImgUrlMapResp)
+		item.ImgUrl = v.ImgUrl
+		mapResp[v.ActivityId] = item
+	}
+
+	return
+
+}