ソースを参照

价格驱动记录调整

hsun 2 年 前
コミット
47aaeb9586

+ 1 - 1
controller/price_driven/price_driven.go

@@ -52,7 +52,7 @@ func PriceDrivenVisitLog(c *gin.Context) {
 		return
 	}
 	userInfo := user.GetInfoByClaims(c)
-	errMsg, err := price_driven.SavePriceDrivenVisitLog(req.PriceDrivenId, req.SourceAgent, int(userInfo.UserID))
+	errMsg, err := price_driven.SavePriceDrivenVisitLog(req.PriceDrivenId, req.SourceAgent, userInfo)
 	if err != nil {
 		response.FailMsg(errMsg, "PriceDrivenVisitLog ErrMsg:"+err.Error(), c)
 		return

+ 18 - 0
models/tables/yb_price_driven_visit_log/entity.go

@@ -7,6 +7,12 @@ type YbPriceDrivenVisitLog struct {
 	ID            int       `gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null" json:"-"`
 	PriceDrivenID int       `gorm:"index:idx_price_driven_id;column:price_driven_id;type:int(10) unsigned;not null" json:"priceDrivenId"` // 价格驱动ID
 	UserID        int       `gorm:"index:idx_user_id;column:user_id;type:int(10) unsigned;not null;default:0" json:"userId"`              // 用户ID
+	Mobile        string    `gorm:"column:mobile;type:varchar(30);not null;default:''" json:"mobile"`                                     // 手机号
+	RealName      string    `gorm:"column:real_name;type:varchar(100);not null;default:''" json:"realName"`                               // 真实姓名
+	NickName      string    `gorm:"column:nick_name;type:varchar(100);not null;default:''" json:"nickName"`                               // 昵称
+	CompanyID     int       `gorm:"column:company_id;type:int(10) unsigned;not null;default:0" json:"companyId"`                          // 客户ID
+	CompanyName   string    `gorm:"column:company_name;type:varchar(100);not null;default:''" json:"companyName"`                         // 客户名称
+	CompanyStatus string    `gorm:"column:company_status;type:varchar(30);not null;default:''" json:"companyStatus"`                      // 客户状态
 	SourceAgent   int       `gorm:"column:source_agent;type:tinyint(4) unsigned;not null;default:1" json:"sourceAgent"`                   // 操作来源,1:小程序,2:小程序 pc 3:弘则研究公众号,4:web pc
 	CreateTime    time.Time `gorm:"column:create_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createTime"`                         // 创建时间
 }
@@ -21,12 +27,24 @@ var YbPriceDrivenVisitLogColumns = struct {
 	ID            string
 	PriceDrivenID string
 	UserID        string
+	Mobile        string
+	RealName      string
+	NickName      string
+	CompanyID     string
+	CompanyName   string
+	CompanyStatus string
 	SourceAgent   string
 	CreateTime    string
 }{
 	ID:            "id",
 	PriceDrivenID: "price_driven_id",
 	UserID:        "user_id",
+	Mobile:        "mobile",
+	RealName:      "real_name",
+	NickName:      "nick_name",
+	CompanyID:     "company_id",
+	CompanyName:   "company_name",
+	CompanyStatus: "company_status",
 	SourceAgent:   "source_agent",
 	CreateTime:    "create_time",
 }

+ 18 - 3
services/price_driven/price_driven.go

@@ -3,8 +3,10 @@ package price_driven
 import (
 	"errors"
 	"hongze/hongze_yb/models/response"
+	"hongze/hongze_yb/models/tables/company_product"
 	"hongze/hongze_yb/models/tables/yb_price_driven"
 	"hongze/hongze_yb/models/tables/yb_price_driven_visit_log"
+	"hongze/hongze_yb/services/user"
 	"hongze/hongze_yb/utils"
 )
 
@@ -32,14 +34,27 @@ func GetPriceDrivenDetail(chartPermissionId int) (resp *response.PriceDrivenItem
 }
 
 // SavePriceDrivenVisitLog 保存价格驱动访问记录
-func SavePriceDrivenVisitLog(priceDrivenId, sourceAgent, userId int) (errMsg string, err error) {
+func SavePriceDrivenVisitLog(priceDrivenId, sourceAgent int, userInfo user.UserInfo) (errMsg string, err error) {
+	companyInfo, e := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
+	if e != nil {
+		errMsg = "保存失败"
+		err = errors.New("获取客户信息失败, Err: " + e.Error())
+		return
+	}
 	logItem := &yb_price_driven_visit_log.YbPriceDrivenVisitLog{
 		PriceDrivenID: priceDrivenId,
-		UserID:        userId,
+		UserID:        int(userInfo.UserID),
+		Mobile:        userInfo.Mobile,
+		RealName:      userInfo.RealName,
+		NickName:      userInfo.NickName,
+		CompanyID:     int(userInfo.CompanyID),
+		CompanyName:   companyInfo.CompanyName,
+		CompanyStatus: companyInfo.Status,
 		SourceAgent:   sourceAgent,
 	}
 	if e := logItem.Create(); e != nil {
-		err = errors.New("保存失败")
+		errMsg = "保存失败"
+		err = errors.New("新增价格驱动访问记录失败, Err: " + e.Error())
 		return
 	}
 	return