Browse Source

no message

xingzai 7 months ago
parent
commit
9d45a36360
2 changed files with 44 additions and 5 deletions
  1. 14 0
      models/article_history_record_newpv.go
  2. 30 5
      models/company/company_product.go

+ 14 - 0
models/article_history_record_newpv.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/models/company"
 	"hongze/hongze_cygx/utils"
 	"strconv"
 	"time"
@@ -38,7 +39,15 @@ 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
+	}
 
 	//写入记录到总的统计表
 	record := new(CygxArticleHistoryRecordAll)
@@ -53,9 +62,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.Platfor = 1
 	lastId, err = o.Insert(record)
 
+	if err != nil {
+		return
+	}
 	// 软删除当天策略平台的文章阅读记录
 	if item.Mobile != "" {
 		sql := `UPDATE cygx_article_history_record_all 

+ 30 - 5
models/company/company_product.go

@@ -132,7 +132,7 @@ type CompanyProductUser struct {
 	Email       string `description:"邮箱"`
 }
 
-// 获取列表
+// 获取销售信息列表
 func GetCompanyProductListByMobiles(mobiles []string) (items []*CompanyProductUser, err error) {
 	lenArr := len(mobiles)
 	if lenArr == 0 {
@@ -141,18 +141,43 @@ func GetCompanyProductListByMobiles(mobiles []string) (items []*CompanyProductUs
 	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
-			company_product AS p
-			INNER JOIN company AS c ON c.company_id = p.company_id 
-			INNER JOIN wx_user AS u ON u.company_id = p.company_id 
-		WHERE u.mobile IN (` + utils.GetOrmInReplace(lenArr) + `) `
+			wx_user as u   
+			INNER JOIN company AS c ON c.company_id = u.company_id 
+			LEFT  JOIN company_product AS p ON p.company_id = u.company_id 
+		WHERE u.mobile IN (` + utils.GetOrmInReplace(lenArr) + `)  AND  p.product_id = 2 `
 	_, err = o.Raw(sql, mobiles).QueryRows(&items)
 	return
 }
 
+// 获取销售信息
+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
+}
+
 // 获取权益客户下的正式、试用、永续客户。
 func GetRaiCompanyProductCompanyids() (items []*CompanyProduct, err error) {
 	sql := ` SELECT  company_id  FROM  company_product WHERE  product_id = 2 AND status IN  ('正式','试用','永续') AND  company_id > 1  `