Browse Source

no message

xingzai 5 months ago
parent
commit
f06e352e82

+ 20 - 17
models/article_history_record_all.go

@@ -6,23 +6,26 @@ import (
 )
 
 type CygxArticleHistoryRecordAll struct {
-	Id             int `orm:"column(id);pk"`
-	ArticleId      int
-	UserId         int
-	CreateTime     string
-	ModifyTime     time.Time
-	Mobile         string    `description:"手机号"`
-	Email          string    `description:"邮箱"`
-	CompanyId      int       `description:"公司id"`
-	CompanyName    string    `description:"公司名称"`
-	StopTime       int       `description:"停留时间"`
-	OutType        int       `description:"退出方式,1正常退出,2强制关闭"`
-	Source         string    `description:"来源,MOBILE:手机端,PC:电脑端"`
-	RealName       string    `description:"用户实际名称"`
-	CreateDateApi  time.Time `description:"同步创建时间"`
-	CelueHistoryId int       `description:"策略平台记录的ID"`
-	Platfor        int       `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
-	IsDel          int       `description:"是否删除"`
+	Id               int `orm:"column(id);pk"`
+	ArticleId        int
+	UserId           int
+	CreateTime       string
+	ModifyTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	StopTime         int       `description:"停留时间"`
+	OutType          int       `description:"退出方式,1正常退出,2强制关闭"`
+	Source           string    `description:"来源,MOBILE:手机端,PC:电脑端"`
+	RealName         string    `description:"用户实际名称"`
+	CreateDateApi    time.Time `description:"同步创建时间"`
+	CelueHistoryId   int       `description:"策略平台记录的ID"`
+	Platfor          int       `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
+	IsDel            int       `description:"是否删除"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	CompanyStatus    string    `description:"公司状态"`
+	SellerName       string    `description:"所属销售"`
 }
 
 // 获取数量

+ 15 - 2
models/article_history_record_newpv.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mfyx/models/company"
 	"hongze/hongze_mfyx/utils"
 	"strconv"
 	"time"
@@ -38,8 +39,15 @@ func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId
 			o.Rollback()
 		}
 	}()
-	lastId, err = o.Insert(item)
 
+	userSeller, err := company.GetCompanyProductListByUserId(item.UserId)
+	if err != nil {
+		return
+	}
+	lastId, err = o.Insert(item)
+	if err != nil {
+		return
+	}
 	//写入记录到总的统计表
 	record := new(CygxArticleHistoryRecordAll)
 	record.UserId = item.UserId
@@ -53,9 +61,14 @@ func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId
 	record.StopTime = item.StopTime
 	record.OutType = item.OutType
 	record.Source = item.Source
+	record.CompanyStatus = userSeller.Status
+	record.SellerName = userSeller.SellerName
+	record.RegisterPlatform = utils.REGISTER_PLATFORM
 	record.Platfor = 1
 	lastId, err = o.Insert(record)
-
+	if err != nil {
+		return
+	}
 	// 软删除当天策略平台的文章阅读记录
 	if item.Mobile != "" {
 		sql := `UPDATE cygx_article_history_record_all 

+ 33 - 0
models/company/company_product.go

@@ -80,3 +80,36 @@ func GetCompanyProductDetailByCompanyId(companyId, productId int) (item *Company
 	err = o.Raw(sql, companyId, productId).QueryRow(&item)
 	return
 }
+
+type CompanyProductUser struct {
+	CompanyId   int    `description:"客户id"`
+	ProductId   int    `description:"产品id"`
+	CompanyName string `description:"客户名称"`
+	Status      string `description:"客户状态"`
+	SellerId    int    `description:"销售id"`
+	SellerName  string `description:"销售名称"`
+	Mobile      string `description:"手机号"`
+	UserId      int
+	RealName    string `description:"用户实际名称"`
+	Email       string `description:"邮箱"`
+}
+
+func GetCompanyProductListByUserId(userId int) (item *CompanyProductUser, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT
+			u.mobile,
+			u.user_id,
+			u.email,
+			u.real_name,
+			u.company_id,
+			p.seller_name,
+			p.status,
+			c.company_name
+		FROM
+			wx_user as u   
+			INNER JOIN company AS c ON c.company_id = u.company_id 
+			INNER JOIN company_product AS p ON p.company_id = u.company_id 
+		WHERE u.user_id = ?  AND  p.product_id = 2 `
+	err = o.Raw(sql, userId).QueryRow(&item)
+	return
+}