Browse Source

Merge branch 'yb/6.0' into debug

hsun 2 years ago
parent
commit
04bcb8a31a
1 changed files with 20 additions and 3 deletions
  1. 20 3
      services/price_driven/price_driven.go

+ 20 - 3
services/price_driven/price_driven.go

@@ -36,11 +36,28 @@ func GetPriceDrivenDetail(chartPermissionId int) (resp *response.PriceDrivenItem
 // SavePriceDrivenVisitLog 保存价格驱动访问记录
 func SavePriceDrivenVisitLog(priceDrivenId, sourceAgent int, userInfo user.UserInfo) (errMsg string, err error) {
 	companyInfo, e := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
-	if e != nil {
+	if e != nil && e != utils.ErrNoRow {
 		errMsg = "保存失败"
 		err = errors.New("获取客户信息失败, Err: " + e.Error())
 		return
 	}
+	var companyName, companyStatus string
+	if companyInfo != nil {
+		companyName = companyInfo.CompanyName
+		companyStatus = companyInfo.Status
+	} else {
+		// 是否是权益用户-视作潜在用户
+		equityCompany, e := company_product.GetByCompany2ProductId(userInfo.CompanyID, 2)
+		if e != nil && e != utils.ErrNoRow {
+			errMsg = "保存失败"
+			err = errors.New("获取客户权益信息失败, Err: " + e.Error())
+			return
+		}
+		if equityCompany != nil {
+			companyName = equityCompany.CompanyName
+			companyStatus = "潜在"
+		}
+	}
 	logItem := &yb_price_driven_visit_log.YbPriceDrivenVisitLog{
 		PriceDrivenID: priceDrivenId,
 		UserID:        int(userInfo.UserID),
@@ -48,8 +65,8 @@ func SavePriceDrivenVisitLog(priceDrivenId, sourceAgent int, userInfo user.UserI
 		RealName:      userInfo.RealName,
 		NickName:      userInfo.NickName,
 		CompanyID:     int(userInfo.CompanyID),
-		CompanyName:   companyInfo.CompanyName,
-		CompanyStatus: companyInfo.Status,
+		CompanyName:   companyName,
+		CompanyStatus: companyStatus,
 		SourceAgent:   sourceAgent,
 	}
 	if e := logItem.Create(); e != nil {