Browse Source

no message

zhangchuanxing 2 months ago
parent
commit
fea8f05407
3 changed files with 159 additions and 6 deletions
  1. 27 4
      models/report_history_record.go
  2. 66 1
      services/rai_company_user_bill.go
  3. 66 1
      services/rai_serve_count.go

+ 27 - 4
models/report_history_record.go

@@ -85,13 +85,36 @@ func GetWxUserRaiCygxReportHistoryRecordCrm16_5() (items []*CygxReportHistoryRec
 	return
 }
 
+type CygxReportSelectionHistoryRecordResp struct {
+	ArticleId        int    `description:"文章ID"`
+	UserId           int    `description:"用户ID"`
+	Mobile           string `description:"手机号"`
+	Email            string `description:"邮箱"`
+	CompanyId        int    `description:"公司id"`
+	CompanyName      string `description:"公司名称"`
+	RealName         string `description:"用户实际名称"`
+	CreateTime       string `description:"创建时间"`
+	RegisterPlatform int    `description:"来源 1小程序,2:网页"`
+}
+
 // 列表
-func GetWxUserRaiCygxReportHistoryRecordCrm16_5() (items []*CygxReportHistoryRecord, err error) {
+func GetCygxReportSelectionHistoryRecordRespLimit(condition string, pars []interface{}) (items []*CygxReportSelectionHistoryRecordResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			*
+			a.article_id,
+			b.user_id,
+			b.real_name,
+			b.mobile,
+			b.email,
+			b.company_id,
+			b.company_name,
+			b.create_time 
 		FROM
-			cygx_report_history_record  WHERE report_type IN('bgjx','bzyjhz')  `
-	_, err = o.Raw(sql).QueryRows(&items)
+			cygx_report_selection AS a
+			INNER JOIN cygx_report_history_record AS b ON a.article_id = b.article_id   WHERE 1= 1  AND report_type = 'bgjx'  `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 66 - 1
services/rai_company_user_bill.go

@@ -703,7 +703,7 @@ func UpdateCygxRaiCompanyUserBill() (err error) {
 		//图表浏览记录明细
 		var conditionBill string
 		var parsBill []interface{}
-		conditionBill = " AND source = 'activityvoice' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		conditionBill = " AND source = 'activityvideo' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
 		parsBill = append(parsBill, companyIds, startWeekDate)
 		listBillActivityVideo, e := rai_serve.GetCygxRaiCompanyUserBillListAll(conditionBill, parsBill)
 		if e != nil {
@@ -756,6 +756,71 @@ func UpdateCygxRaiCompanyUserBill() (err error) {
 	}
 	//活动视频记录 end
 
+	//报告精选阅读记录
+	{
+		condition = " AND  b.company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND b.create_time > ?  GROUP BY  b.id   "
+		userReportSelectionList, e := models.GetCygxReportSelectionHistoryRecordRespLimit(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxChartRecordListNoLimit, Err: " + e.Error())
+			return
+		}
+
+		//报告精选阅读记录 明细
+		var conditionBill string
+		var parsBill []interface{}
+		conditionBill = " AND source = 'reportselection' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		parsBill = append(parsBill, companyIds, startWeekDate)
+		listBillReportSelection, e := rai_serve.GetCygxRaiCompanyUserBillListAll(conditionBill, parsBill)
+		if e != nil {
+			err = errors.New("GetCygxRaiServeBillListAll, Err: " + e.Error())
+			return
+		}
+
+		mapRscalendarBill := make(map[string]bool)
+		for _, v := range listBillReportSelection {
+			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userReportSelectionList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ArticleId)] = true
+		}
+		for _, v := range listBillReportSelection {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range userReportSelectionList {
+			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ArticleId)] { // 如果内容存在就不插入
+				continue
+			}
+			item := new(rai_serve.CygxRaiCompanyUserBill)
+			item.Content = ""
+			item.ServeTypeId = 5
+			item.ServeTypeName = "阅读uv"
+			item.UserId = v.UserId
+			item.Mobile = v.Mobile
+			item.Email = v.Email
+			item.CompanyId = v.CompanyId
+			item.CompanyName = v.CompanyName
+			item.RealName = v.RealName
+			item.ServeCount = 0.5
+			if mapUserMaker[v.UserId] {
+				item.IsKp = 1
+				item.ServeCount = item.ServeCount * 3
+			}
+			item.SourceId = v.ArticleId
+			item.Source = utils.CYGX_OBJ_REPORTSELECTION
+			item.CreateTime = time.Now()
+			item.ViewTime = v.CreateTime
+			item.WeekStartDate, item.WeekEndDate = utils.GetMondayAndSundayByTimeString(item.ViewTime)
+			item.MonthStartDate, item.MonthEndDate = utils.GetFirstAndLastDayOfMonth(item.ViewTime)
+			items = append(items, item)
+		}
+	}
+	//报告精选阅读记录 end
+
 	//fmt.Println("items", len(items))
 	//return
 	if len(items) > 0 {

+ 66 - 1
services/rai_serve_count.go

@@ -1089,7 +1089,7 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 		//图表浏览记录明细
 		var conditionBill string
 		var parsBill []interface{}
-		conditionBill = " AND source = 'activityvoice' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		conditionBill = " AND source = 'activityvideo' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
 		parsBill = append(parsBill, companyIds, startWeekDate)
 		listBillActivityVideo, e := rai_serve.GetCygxRaiServeBillListAll(conditionBill, parsBill)
 		if e != nil {
@@ -1142,6 +1142,71 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 	}
 	//活动视频记录 end
 
+	//报告精选阅读记录
+	{
+		condition = " AND  b.company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND b.create_time > ?  GROUP BY  b.id   "
+		userReportSelectionList, e := models.GetCygxReportSelectionHistoryRecordRespLimit(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxChartRecordListNoLimit, Err: " + e.Error())
+			return
+		}
+
+		//报告精选阅读记录 明细
+		var conditionBill string
+		var parsBill []interface{}
+		conditionBill = " AND source = 'reportselection' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		parsBill = append(parsBill, companyIds, startWeekDate)
+		listBillReportSelection, e := rai_serve.GetCygxRaiServeBillListAll(conditionBill, parsBill)
+		if e != nil {
+			err = errors.New("GetCygxRaiServeBillListAll, Err: " + e.Error())
+			return
+		}
+
+		mapRscalendarBill := make(map[string]bool)
+		for _, v := range listBillReportSelection {
+			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userReportSelectionList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ArticleId)] = true
+		}
+		for _, v := range listBillReportSelection {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range userReportSelectionList {
+			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ArticleId)] { // 如果内容存在就不插入
+				continue
+			}
+			item := new(rai_serve.CygxRaiServeBill)
+			item.Content = ""
+			item.ServeTypeId = 5
+			item.ServeTypeName = "阅读uv"
+			item.UserId = v.UserId
+			item.Mobile = v.Mobile
+			item.Email = v.Email
+			item.CompanyId = v.CompanyId
+			item.CompanyName = v.CompanyName
+			item.RealName = v.RealName
+			item.ServeCount = 0.5
+			if mapUserMaker[v.UserId] {
+				item.IsKp = 1
+				item.ServeCount = item.ServeCount * 3
+			}
+			item.SourceId = v.ArticleId
+			item.Source = utils.CYGX_OBJ_REPORTSELECTION
+			item.CreateTime = time.Now()
+			item.ViewTime = v.CreateTime
+			item.WeekStartDate, item.WeekEndDate = utils.GetMondayAndSundayByTimeString(item.ViewTime)
+			item.MonthStartDate, item.MonthEndDate = utils.GetFirstAndLastDayOfMonth(item.ViewTime)
+			items = append(items, item)
+		}
+	}
+	//报告精选阅读记录 end
+
 	if len(items) > 0 {
 		var itemsAdd []*rai_serve.CygxRaiServeBill
 		for k, v := range items {