zhangchuanxing 2 mesi fa
parent
commit
042001871d
3 ha cambiato i file con 167 aggiunte e 0 eliminazioni
  1. 36 0
      models/chart_record.go
  2. 66 0
      services/rai_company_user_bill.go
  3. 65 0
      services/rai_serve_count.go

+ 36 - 0
models/chart_record.go

@@ -24,3 +24,39 @@ func AddCygxChartRecord(item *CygxChartRecord) (lastId int64, err error) {
 	lastId, err = o.Insert(item)
 	return
 }
+
+type CygxChartRecordResp struct {
+	ChartId          int    `description:"图表ID"`
+	Title            string `description:"标题"`
+	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 GetCygxChartRecordListNoLimit(condition string, pars []interface{}) (items []*CygxChartRecordResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.title,
+			a.ctag_id,
+			b.user_id,
+			b.real_name,
+			b.mobile,
+			b.email,
+			b.company_id,
+			b.company_name,
+			b.create_time 
+		FROM
+			cygx_chart AS a
+			INNER JOIN cygx_chart_record AS b ON a.chart_id = b.chart_id    WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 66 - 0
services/rai_company_user_bill.go

@@ -560,6 +560,72 @@ func UpdateCygxRaiCompanyUserBill() (err error) {
 		}
 	}
 	//交流反馈 end
+
+	//图表浏览记录
+	{
+		condition = " AND  b.company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND b.create_time > ?  GROUP BY  b.record_id   "
+		userChartRecordList, e := models.GetCygxChartRecordListNoLimit(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxChartRecordListNoLimit, Err: " + e.Error())
+			return
+		}
+
+		//图表浏览记录明细
+		var conditionBill string
+		var parsBill []interface{}
+		conditionBill = " AND source = 'newchart' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		parsBill = append(parsBill, companyIds, startWeekDate)
+		listBillByuserFeedback, 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 listBillByuserFeedback {
+			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userChartRecordList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ChartId)] = true
+		}
+		for _, v := range listBillByuserFeedback {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range userChartRecordList {
+			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ChartId)] { // 如果内容存在就不插入
+				continue
+			}
+			item := new(rai_serve.CygxRaiCompanyUserBill)
+			item.Content = v.Title
+			item.ServeTypeId = 7
+			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.ChartId
+			item.Source = utils.CYGX_OBJ_NEWCHART
+			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 {

+ 65 - 0
services/rai_serve_count.go

@@ -943,6 +943,71 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 	}
 	//交流反馈 end
 
+	//图表浏览记录
+	{
+		condition = " AND  b.company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND b.create_time > ?  GROUP BY  b.record_id   "
+		userChartRecordList, e := models.GetCygxChartRecordListNoLimit(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxChartRecordListNoLimit, Err: " + e.Error())
+			return
+		}
+
+		//图表浏览记录明细
+		var conditionBill string
+		var parsBill []interface{}
+		conditionBill = " AND source = 'newchart' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		parsBill = append(parsBill, companyIds, startWeekDate)
+		listBillByuserFeedback, 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 listBillByuserFeedback {
+			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userChartRecordList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ChartId)] = true
+		}
+		for _, v := range listBillByuserFeedback {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range userChartRecordList {
+			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ChartId)] { // 如果内容存在就不插入
+				continue
+			}
+			item := new(rai_serve.CygxRaiServeBill)
+			item.Content = v.Title
+			item.ServeTypeId = 7
+			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.ChartId
+			item.Source = utils.CYGX_OBJ_NEWCHART
+			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 {