xingzai 6 meses atrás
pai
commit
1c393016a8

+ 13 - 0
models/admin.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_web_mfyx/utils"
 	"time"
 )
 
@@ -110,3 +111,15 @@ func GetSysAdminByMobile(mobile string) (item *Admin, err error) {
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 }
+
+// 根据多个ID获取管理员列表信息
+func GetAdminByAdminIds(adminId []int) (items []*AdminMobileResp, err error) {
+	lenArr := len(adminId)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT mobile  FROM admin  WHERE admin_id  IN (` + utils.GetOrmInReplace(lenArr) + `)`
+	_, err = o.Raw(sql, adminId).QueryRows(&items)
+	return
+}

+ 82 - 0
models/company/company_product.go

@@ -0,0 +1,82 @@
+package company
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CompanyProduct struct {
+	CompanyProductId    int       `orm:"column(company_product_id);pk" description:"客户产品id"`
+	CompanyId           int       `description:"客户id"`
+	ProductId           int       `description:"产品id"`
+	ProductName         string    `description:"产品名称"`
+	CompanyName         string    `description:"客户名称"`
+	Source              string    `description:"来源"`
+	Reasons             string    `description:"新增理由"`
+	Status              string    `description:"客户状态"`
+	IndustryId          int       `description:"行业id"`
+	IndustryName        string    `description:"行业名称"`
+	SellerId            int       `description:"销售id"`
+	SellerName          string    `description:"销售名称"`
+	GroupId             int       `description:"销售分组id"`
+	DepartmentId        int       `description:"销售部门id"`
+	IsSuspend           int       `description:"1:暂停,0:启用"`
+	SuspendTime         time.Time `description:"暂停启用时间"`
+	TryOutTime          time.Time `description:"正式转试用时间"`
+	RenewalReason       string    `description:"正式转试用后的续约情况说明"`
+	RenewalTodo         string    `description:"未续约说明中的待办事项说明"`
+	LastDescriptionTime time.Time `description:"上次添加说明时间"`
+	RenewalIntention    int       `description:"是否勾选无续约意向,1:确认,0:未确认"`
+	ApproveStatus       string    `description:"审批状态:'审批中','通过','驳回'"`
+	FreezeTime          time.Time `description:"冻结时间"`
+	FreezeReason        time.Time `description:"冻结理由"`
+	Remark              string    `description:"备注信息"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"修改时间"`
+	StartDate           string    `description:"开始日期"`
+	EndDate             string    `description:"结束日期"`
+	ContractEndDate     time.Time `description:"合同结束日期"`
+	LoseReason          string    `description:"流失原因"`
+	LossTime            time.Time `description:"流失时间"`
+	CompanyType         string    `description:"客户类型"`
+	OpenCode            string    `description:"开放给第三方的编码,不让第三方定位我们的客户信息"`
+	Scale               string    `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。"`
+	ViewTotal           int       `description:"总阅读次数"`
+	RoadShowTotal       int       `description:"累计路演次数"`
+	LastViewTime        time.Time `description:"最后一次阅读时间"`
+	PackageType         int       `description:"套餐类型"`
+	IsFormal            int       `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
+	TodoStatus          string    `description:"任务处理状态;枚举值:'无任务','未完成','已完成'"`
+	TodoCreateTime      time.Time `description:"任务创建时间"`
+	TodoApproveTime     time.Time `description:"任务审批时间"`
+	TryStage            int       `description:"试用客户子标签:1未分类、2  推进、3 跟踪、4 预备"`
+	TryOutDayTotal      int       `description:"客户总试用天数"`
+	CloseReason         string    `description:"关闭原因"`
+	CloseTime           time.Time `description:"关闭时间"`
+	OverseasLabel       int       `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
+	IsOverseas          int       `description:"是否显示在海外客户0:显示,1:不显示"`
+	ShareSellerId       int       `description:"共享销售员id"`
+}
+
+func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *CompanyProduct, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT b.* FROM company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			WHERE a.company_id=? AND b.product_id=? LIMIT 1 `
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	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
+}
+
+func GetCompanyProductDetailByCompanyId(companyId, productId int) (item *CompanyProduct, err error) {
+	sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	return
+}

+ 18 - 3
services/activity.go

@@ -1830,12 +1830,19 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 		sourceMsg = "活动报名"
 	}
 
+	sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+	if e != nil {
+		err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+		return
+	}
+	sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
 	var keyword1 string
 	var keyword2 string
 	keyword1 = activityDetail.ActivityName
 	keyword2 = fmt.Sprint("互动:", sourceMsg, ",", user.RealName, "--", user.CompanyName)
 	//SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
-	openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 	if e != nil {
 		err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 		return err
@@ -1844,7 +1851,7 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 	SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
 
 	// 类目模版买方研选
-	openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+	openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 	if e != nil {
 		err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 		return err
@@ -1884,7 +1891,15 @@ func ActivityVideoUserRmind(user *models.WxUserItem, activityId, fileType int) (
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 7 - 1
services/activity_special_trip.go

@@ -376,7 +376,13 @@ func ActivitySpecialUserRmind(user *models.WxUserItem, activityId, TripStatus in
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 31 - 0
services/admin.go

@@ -4,6 +4,7 @@ import (
 	"errors"
 	"fmt"
 	"hongze/hongze_web_mfyx/models"
+	"hongze/hongze_web_mfyx/models/company"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
 	"strings"
@@ -166,3 +167,33 @@ func GetSelleridWhichGroup(companyId, productId int, mobile string) (adminIds st
 	}
 	return
 }
+
+// 根据公司ID获取权益销售、共享销售手机号
+func GetCompanySellerAndShareMobileByRai(companyId int) (mobiles []string, err error) {
+	productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
+	if e != nil {
+		err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
+		return
+	}
+
+	var adminIds []int
+	adminIds = append(adminIds, productDetail.SellerId)
+	if productDetail.ShareSellerId > 0 {
+		adminIds = append(adminIds, productDetail.ShareSellerId)
+	}
+
+	listAdmin, e := models.GetAdminByAdminIds(adminIds)
+	if e != nil {
+		err = errors.New("GetAdminByAdminIds, Err: " + e.Error())
+		return
+	}
+
+	mobiles = make([]string, 0)
+	for _, v := range listAdmin {
+		if v.Mobile != "" {
+			mobiles = append(mobiles, v.Mobile)
+		}
+	}
+
+	return
+}

+ 9 - 1
services/article.go

@@ -537,7 +537,15 @@ func ArticleUserRemind(user *models.WxUserItem, articleDetail *models.ArticleDet
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, err := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, err := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if err != nil {
 			return err
 		}

+ 10 - 1
services/keyword.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
+	"strings"
 	"time"
 )
 
@@ -95,7 +96,15 @@ func SearchKeywordUserRmind(user *models.WxUserItem, keyWord string) (err error)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/micro_roadshow.go

@@ -655,7 +655,14 @@ func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err erro
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/minutes_summary.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -41,7 +42,13 @@ func MinutesSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/product_interior.go

@@ -195,7 +195,14 @@ func ProductInteriorHistoryUserRmind(user *models.WxUserItem, productInteriorId
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/research_summary.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -41,7 +42,13 @@ func ResearchSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (er
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
 			return

+ 14 - 2
services/wechat_send_category_template_msg.go

@@ -602,7 +602,13 @@ func SendWxCategoryMsgInteractive(user *models.WxUserItem, interactive string, a
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return
@@ -667,7 +673,13 @@ func SearchKeywordUserRmindCategoryMsg(user *models.WxUserItem, keyWord string)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return