Browse Source

Merge branch 'crm/crm_16.5' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 2 months ago
parent
commit
90d67bf585

+ 2 - 1
controllers/cygx/user.go

@@ -205,7 +205,8 @@ func (this *UserController) List() {
 		}
 	}
 	if label != "" {
-		usercondition += ` AND u.user_label LIKE '%` + label + `%'`
+		//usercondition += ` AND u.user_label LIKE '%` + label + `%'`
+		usercondition += ` AND u.user_id IN ( SELECT user_id  FROM ` + utils.GetCygxDatabase() + `.wx_user_rai_label WHERE label LIKE '%` + label + `%' ) `
 	}
 	//
 	usercondition += ` AND cp.product_id = 2  	AND sr.product_id = 2  `

+ 9 - 8
controllers/cygx/user_rai_label.go

@@ -161,7 +161,7 @@ func (this *UserRaiLabelController) Detail() {
 			br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 			return
 		}
-		activitySignupDetai, _ := cygx.GetCygxActivitySignupDetailDetailLast(sourceId, detail.UserId)
+		activitySignupDetai, _ := cygx.GetCygxActivitySignupDetailDetailLast(sourceId, detail.Mobile)
 		item.ActivityName = activityInfo.ActivityName
 		item.ActivityTypeName = activityInfo.ActivityTypeName
 		item.ActivityTime = activityInfo.ActivityTime
@@ -213,12 +213,13 @@ func (this *UserRaiLabelController) Detail() {
 				br.ErrMsg = "操作失败,Err:" + err.Error()
 				return
 			}
-			historyDetail, err := cygx.GetCygxArticleHistoryRecordAllDetailLast(sourceId, detail.UserId)
-			if err != nil {
-				br.Msg = "内容不存在"
-				br.ErrMsg = "操作失败,Err:" + err.Error()
-				return
+			historyDetail := new(cygx.CygxArticleHistoryRecordAll)
+			if detail.Mobile != "" {
+				historyDetail, err = cygx.GetCygxArticleHistoryRecordAllDetailLastByMobile(sourceId, detail.Mobile)
+			} else {
+				historyDetail, err = cygx.GetCygxArticleHistoryRecordAllDetailLast(sourceId, detail.UserId)
 			}
+
 			item.Title = detailArticle.Title
 			item.PublishDate = detailArticle.PublishDate.Format(utils.FormatDateTime)
 			item.CreateTime = detail.CreateTime.Format(utils.FormatDateTime)
@@ -233,7 +234,7 @@ func (this *UserRaiLabelController) Detail() {
 				br.ErrMsg = "操作失败,Err:" + err.Error()
 				return
 			}
-			historyDetail, err := cygx.GetCygxReportHistoryRecordDetailLast(sourceId, detail.UserId, "bgjx")
+			historyDetail, err := cygx.GetCygxReportHistoryRecordDetailLast(sourceId, detail.Mobile, "bgjx")
 			if err != nil {
 				br.Msg = "内容不存在"
 				br.ErrMsg = "操作失败,Err:" + err.Error()
@@ -253,7 +254,7 @@ func (this *UserRaiLabelController) Detail() {
 				br.ErrMsg = "操作失败,Err:" + err.Error()
 				return
 			}
-			historyDetail, err := cygx.GetCygxReportHistoryRecordDetailLast(sourceId, detail.UserId, "bzyjhz")
+			historyDetail, err := cygx.GetCygxReportHistoryRecordDetailLast(sourceId, detail.Mobile, "bzyjhz")
 			if err != nil {
 				br.Msg = "内容不存在"
 				br.ErrMsg = "操作失败,Err:" + err.Error()

+ 3 - 3
models/cygx/activity_signup_detail.go

@@ -158,9 +158,9 @@ func UpdateActivitySignupDetailMultiByYiDong(items []*CygxActivitySignupDetail)
 }
 
 // 根据用户ID,文章ID获取用户最新一条参会记录
-func GetCygxActivitySignupDetailDetailLast(articleId, userId int) (item *CygxActivitySignupDetail, err error) {
+func GetCygxActivitySignupDetailDetailLast(articleId int, mobile string) (item *CygxActivitySignupDetail, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_activity_signup_detail WHERE   activity_id = ?  AND user_id = ?     ORDER BY id DESC    LIMIT 1 `
-	err = o.Raw(sql, articleId, userId).QueryRow(&item)
+	sql := `SELECT * FROM cygx_activity_signup_detail WHERE   activity_id = ?  AND mobile = ?     ORDER BY id DESC    LIMIT 1 `
+	err = o.Raw(sql, articleId, mobile).QueryRow(&item)
 	return
 }

+ 8 - 0
models/cygx/askserie_video_history_record.go

@@ -106,3 +106,11 @@ func GetCygxArticleHistoryRecordAllDetailLast(articleId, userId int) (item *Cygx
 	err = o.Raw(sql, articleId, userId).QueryRow(&item)
 	return
 }
+
+// 根据用户ID,文章ID获取用户最新一条阅读记录
+func GetCygxArticleHistoryRecordAllDetailLastByMobile(articleId int, mobile string) (item *CygxArticleHistoryRecordAll, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_article_history_record_all WHERE   article_id = ?  AND mobile = ?   AND is_del = 0  ORDER BY id DESC    LIMIT 1 `
+	err = o.Raw(sql, articleId, mobile).QueryRow(&item)
+	return
+}

+ 3 - 3
models/cygx/report_history_record.go

@@ -24,9 +24,9 @@ type CygxReportHistoryRecord struct {
 }
 
 // 根据用户ID,文章ID获取用户最新一条阅读记录
-func GetCygxReportHistoryRecordDetailLast(articleId, userId int, reportType string) (item *CygxArticleHistoryRecordAll, err error) {
+func GetCygxReportHistoryRecordDetailLast(articleId int, mobile, reportType string) (item *CygxArticleHistoryRecordAll, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_report_history_record WHERE   article_id = ?  AND user_id = ?   AND report_type = ?    ORDER BY id DESC    LIMIT 1 `
-	err = o.Raw(sql, articleId, userId, reportType).QueryRow(&item)
+	sql := `SELECT * FROM cygx_report_history_record WHERE   article_id = ?  AND mobile = ?   AND report_type = ?    ORDER BY id DESC    LIMIT 1 `
+	err = o.Raw(sql, articleId, mobile, reportType).QueryRow(&item)
 	return
 }

+ 8 - 0
utils/constants.go

@@ -592,6 +592,14 @@ func GetWeeklyDatabase() (databaseName string) {
 	}
 	return
 }
+func GetCygxDatabase() (databaseName string) {
+	if RunMode == "release" {
+		databaseName = `hz_cygx`
+	} else {
+		databaseName = `test_hz_cygx`
+	}
+	return
+}
 
 const (
 	EnCompanyIdStep = 10000000