Selaa lähdekoodia

PVUv 去重读

xingzai 3 vuotta sitten
vanhempi
commit
c9c1a4c1d3
3 muutettua tiedostoa jossa 60 lisäystä ja 25 poistoa
  1. 41 21
      controllers/article.go
  2. 5 4
      controllers/home.go
  3. 14 0
      controllers/tactics.go

+ 41 - 21
controllers/article.go

@@ -2,11 +2,11 @@ package controllers
 
 import (
 	"encoding/json"
-	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"html"
+	"regexp"
 	"strconv"
 	"strings"
 	"time"
@@ -132,25 +132,23 @@ func (this *ArticleController) Detail() {
 				articlePermissionPermissionName = detail.CategoryName
 			}
 
-			var detailNew *models.AddStopTimeNewRep
-			detailNew, _ = models.GetNewArticleHistoryRecord(uid, articleId)
-			if detailNew != nil {
-				if detailNew.StopTime != 0 {
-					if strings.Contains(companyPermission, articlePermissionPermissionName) {
-						hasPermission = 1
-						historyRecord := new(models.CygxArticleHistoryRecord)
-						historyRecord.UserId = uid
-						historyRecord.ArticleId = articleId
-						historyRecord.CreateTime = time.Now()
-						historyRecord.Mobile = user.Mobile
-						historyRecord.Email = user.Email
-						historyRecord.CompanyId = user.CompanyId
-						historyRecord.CompanyName = user.CompanyName
-						go models.AddCygxArticleHistoryRecord(historyRecord)
-					} else { //无该行业权限
-						hasPermission = 3
-					}
+			if strings.Contains(companyPermission, articlePermissionPermissionName) {
+				hasPermission = 1
+				var detailNew *models.AddStopTimeNewRep
+				detailNew, _ = models.GetNewArticleHistoryRecord(uid, articleId)
+				if detailNew == nil || detailNew.StopTime != 0 {
+					historyRecord := new(models.CygxArticleHistoryRecord)
+					historyRecord.UserId = uid
+					historyRecord.ArticleId = articleId
+					historyRecord.CreateTime = time.Now()
+					historyRecord.Mobile = user.Mobile
+					historyRecord.Email = user.Email
+					historyRecord.CompanyId = user.CompanyId
+					historyRecord.CompanyName = user.CompanyName
+					go models.AddCygxArticleHistoryRecord(historyRecord)
 				}
+			} else { //无该行业权限
+				hasPermission = 3
 			}
 
 			if hasPermission == 1 {
@@ -202,14 +200,23 @@ func (this *ArticleController) Detail() {
 			detail.SellerName = sellerItem.RealName
 		}
 		sellerList, err := models.GetSellerList(articleId)
-		fmt.Println(sellerList)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
 			return
 		}
 		if detail.ArticleId > 1000000 {
-			fmt.Println(detail.SellerAndMobile)
+			var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
+			match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
+			if match != nil {
+				for _, v := range match {
+					sellerAndMobile := &models.SellerRep{
+						SellerMobile: v,
+						SellerName:   strings.Replace(detail.SellerAndMobile, v, "", -1),
+					}
+					sellerList = append(sellerList, sellerAndMobile)
+				}
+			}
 		}
 		detail.SellerList = sellerList
 	} else { //潜在客户
@@ -442,6 +449,19 @@ func (this *ArticleCommonController) Detail() {
 		br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(detail.ArticleId)
 		return
 	}
+	if detail.ArticleId > 1000000 {
+		var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
+		match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
+		if match != nil {
+			for _, v := range match {
+				sellerAndMobile := &models.SellerRep{
+					SellerMobile: v,
+					SellerName:   strings.Replace(detail.SellerAndMobile, v, "", -1),
+				}
+				sellerList = append(sellerList, sellerAndMobile)
+			}
+		}
+	}
 	detail.SellerList = sellerList
 	resp.Detail = detail
 	br.Ret = 200

+ 5 - 4
controllers/home.go

@@ -43,7 +43,7 @@ func (this *HomeController) ListHome() {
 	var total int
 	resp := new(models.HomeListResp)
 	page := paging.GetPaging(currentIndex, pageSize, total)
-
+	condition += ` AND is_summary = 1  `
 	if chartPermissionId > 0 {
 		categoryId, err := models.GetCategoryId(chartPermissionId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -68,15 +68,16 @@ func (this *HomeController) ListHome() {
 		//	br.Data = resp
 		//	return
 		//}
+
 		if categoryId != "" {
-			condition = ` AND category_id IN(` + categoryId + `)`
-			condition += ` OR ( category_name = '` + categoryinfo.PermissionName + `' AND publish_status = 1 )`
+			condition += ` AND category_id IN(` + categoryId + `)`
+			condition += ` OR ( category_name = '` + categoryinfo.PermissionName + `' AND publish_status = 1 AND is_summary = 1 )`
 		} else {
 			condition += ` AND  category_name = '` + categoryinfo.PermissionName + `'`
 		}
 
 	}
-	condition += ` AND is_summary = 1  `
+
 	//condition = ` AND a.category_id NOT IN (85,71) `
 	fmt.Println(condition)
 	total, err := models.GetHomeCount(condition, pars)

+ 14 - 0
controllers/tactics.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_cygx/utils"
 	"html"
 	"rdluck_tools/paging"
+	"regexp"
 	"strconv"
 	"strings"
 	"time"
@@ -257,6 +258,19 @@ func (this *TacticsController) Detail() {
 			br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
 			return
 		}
+		if detail.ArticleId > 1000000 {
+			var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
+			match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
+			if match != nil {
+				for _, v := range match {
+					sellerAndMobile := &models.SellerRep{
+						SellerMobile: v,
+						SellerName:   strings.Replace(detail.SellerAndMobile, v, "", -1),
+					}
+					sellerList = append(sellerList, sellerAndMobile)
+				}
+			}
+		}
 		detail.SellerList = sellerList
 	} else { //潜在客户
 		if applyCount > 0 {