xingzai 1 hete
szülő
commit
ab71b23c26

+ 10 - 0
models/article_history_record_newpv.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_web_mfyx/models/company"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
 	"time"
@@ -53,6 +54,10 @@ func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId
 			o.Rollback()
 		}
 	}()
+	userSeller, err := company.GetCompanyProductListByUserId(item.UserId)
+	if err != nil {
+		return
+	}
 	lastId, err = o.Insert(item)
 	if err != nil {
 		return
@@ -84,6 +89,9 @@ 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 {
@@ -123,6 +131,8 @@ type CygxArticleHistoryRecordAll struct {
 	Platfor          int       `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
 	IsDel            int       `description:"是否删除"`
 	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	CompanyStatus    string    `description:"公司状态"`
+	SellerName       string    `description:"所属销售"`
 }
 
 type EsUserInteraction struct {

+ 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
+}