Browse Source

no message

zhangchuanxing 1 month ago
parent
commit
0a72b489ba
3 changed files with 166 additions and 0 deletions
  1. 36 0
      models/product_interior_history.go
  2. 65 0
      services/rai_company_user_bill.go
  3. 65 0
      services/rai_serve_count.go

+ 36 - 0
models/product_interior_history.go

@@ -65,3 +65,39 @@ func GetCygxProductInteriorHistoryListPv(condition string, pars []interface{}) (
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+type ListProductInteriorResp struct {
+	ProductInteriorId 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 GetCygxProductInteriorHistoryListData(condition string, pars []interface{}) (items []*ListProductInteriorResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.product_interior_id,
+			a.title,
+			b.user_id,
+			b.real_name,
+			b.mobile,
+			b.email,
+			b.company_id,
+			b.company_name,
+			b.create_time 
+		FROM
+			cygx_product_interior AS a
+			INNER JOIN cygx_product_interior_history AS b ON a.product_interior_id = b.product_interior_id   WHERE 1= 1   `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 65 - 0
services/rai_company_user_bill.go

@@ -821,6 +821,71 @@ func UpdateCygxRaiCompanyUserBill() (err error) {
 	}
 	//报告精选阅读记录 end
 
+	//产品内测阅读记录
+	{
+		condition = " AND  b.company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND b.create_time > ?  GROUP BY  b.id   "
+		userProductInteriorList, e := models.GetCygxProductInteriorHistoryListData(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxChartRecordListNoLimit, Err: " + e.Error())
+			return
+		}
+
+		//产品内测阅读记录 明细
+		var conditionBill string
+		var parsBill []interface{}
+		conditionBill = " AND source = 'productinterior' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		parsBill = append(parsBill, companyIds, startWeekDate)
+		listBillProductInterior, 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 listBillProductInterior {
+			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userProductInteriorList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ProductInteriorId)] = true
+		}
+		for _, v := range listBillProductInterior {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range userProductInteriorList {
+			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ProductInteriorId)] { // 如果内容存在就不插入
+				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.ProductInteriorId
+			item.Source = utils.CYGX_OBJ_PRODUCTINTERIOR
+			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

@@ -1207,6 +1207,71 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 	}
 	//报告精选阅读记录 end
 
+	//产品内测阅读记录
+	{
+		condition = " AND  b.company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND b.create_time > ?  GROUP BY  b.id   "
+		userProductInteriorList, e := models.GetCygxProductInteriorHistoryListData(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxChartRecordListNoLimit, Err: " + e.Error())
+			return
+		}
+
+		//产品内测阅读记录 明细
+		var conditionBill string
+		var parsBill []interface{}
+		conditionBill = " AND source = 'productinterior' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
+		parsBill = append(parsBill, companyIds, startWeekDate)
+		listBillProductInterior, 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 listBillProductInterior {
+			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userProductInteriorList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ProductInteriorId)] = true
+		}
+		for _, v := range listBillProductInterior {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range userProductInteriorList {
+			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ProductInteriorId)] { // 如果内容存在就不插入
+				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.ProductInteriorId
+			item.Source = utils.CYGX_OBJ_PRODUCTINTERIOR
+			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 {