Ver Fonte

no message

xingzai há 10 meses atrás
pai
commit
75148981e5

+ 7 - 0
models/company.go

@@ -214,3 +214,10 @@ func GetCompanyPermissionList(companyId int) (items []*PermissionItem, err error
 	_, err = o.Raw(sql, companyId).QueryRows(&items)
 	return
 }
+
+func GetCompanyProductCount(companyId, productId int) (count int, err error) {
+	sql := ` SELECT COUNT(1) AS count FROM  company_product WHERE company_id = ? AND product_id = ? `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}

+ 17 - 0
models/seller.go

@@ -90,3 +90,20 @@ func GetAdminListByGroupId(groupId int) (items []*Admin, err error) {
 	_, err = o.Raw(sql, groupId).QueryRows(&items)
 	return
 }
+
+// 获取权益销售信息
+func GetRaiSellerByCompanyId(companyId int) (item *AdminItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT
+     		b.admin_id,
+			b.real_name,
+			b.mobile 
+		FROM
+			company_product AS a
+			INNER JOIN admin AS b ON a.seller_id = b.admin_id 
+		WHERE
+			a.product_id = 2 
+			AND a.company_id = ?`
+	err = o.Raw(sql, companyId).QueryRow(&item)
+	return
+}

+ 2 - 12
services/cygx_yanxuan_special_company.go

@@ -77,17 +77,7 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	}()
 	var sellerName string
 	//获取销售信息
-	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
-		return
-	}
-	if sellerItem == nil {
-		err = nil
-		return
-	}
-	sellerName = sellerItem.RealName
-
+	sellerName, _ = GetSellerName(user)
 	if stopTime >= 3 {
 
 		//判断一个用户是否阅读过 某一篇研选专栏
@@ -169,7 +159,7 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	itemLog.RegisterPlatform = utils.REGISTER_PLATFORM
 	itemLog.YanxuanSpecialId = specialId
 	itemLog.StopTime = stopTime
-	_, e = models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
+	_, e := models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
 	if e != nil {
 		err = errors.New("AddCygxYanxuanSpecialRecordLog, Err: " + e.Error())
 		return

+ 36 - 0
services/user_permission.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"errors"
+	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 	"strings"
@@ -198,3 +199,38 @@ func GetUserRaiPermissionYanXuanInfo(user *models.WxUserItem) (hasPermission int
 	}
 	return
 }
+
+// 获取权益销售姓名
+func GetSellerName(user *models.WxUserItem) (sellerName string, sellerId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取权益销售姓名失败 GetSellerName, err:", err.Error()), 2)
+		}
+	}()
+	companyId := user.CompanyId
+	//潜在客户没有销售
+	if user.CompanyId <= 1 {
+		return
+	}
+	//权益客户
+	raiCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if e != nil {
+		err = errors.New("GetCompanyProductCount, Err: " + e.Error())
+		return
+	}
+	//仅开通FICC的客户不展示销售姓名
+	if raiCount == 0 {
+		return
+	}
+	sealldetail, e := models.GetRaiSellerByCompanyId(companyId)
+	if e != nil {
+		err = errors.New("GetRaiSellerByCompanyId, Err: " + e.Error())
+		return
+	}
+	sellerName = sealldetail.RealName
+	sellerId = sealldetail.AdminId
+	return
+
+}