浏览代码

no message

zhangchuanxing 3 天之前
父节点
当前提交
cd0b39c8e5
共有 4 个文件被更改,包括 83 次插入0 次删除
  1. 3 0
      controllers/company_user.go
  2. 1 0
      models/company/company_user.go
  3. 49 0
      models/company/user_product.go
  4. 30 0
      services/user.go

+ 3 - 0
controllers/company_user.go

@@ -1274,6 +1274,8 @@ func (this *CompanyUserController) List() {
 			return
 		}
 
+		mapRaiUserStatus := services.GetRaiUserStatus(userIds)
+
 		if isUserYanXuanButtonShow {
 			userYanxuanPermissionMap := cygxService.GetCygxUserYanxuanPermissionMapItem(userIds) // 如果是权益部门下的人,则展示研选相关的信息
 			userInteractionNumMap := cygxService.GetUserInteractionNumMap(userIds)               // 如果是权益部门下的人,展示互动量相关的信息
@@ -1327,6 +1329,7 @@ func (this *CompanyUserController) List() {
 				// 分产品阅读统计
 				//list[i].YbProductViewTotal = userYbViewsMap[int(item.UserId)]
 				list[i].MfyxInteractionNum = userInteractionNumMap[int(item.UserId)]
+				list[i].RaiUserStatus = mapRaiUserStatus[int(item.UserId)]
 				//权益销售查看用户研选的信息
 				if userYanxuanPermissionMap[int(item.UserId)] != nil {
 					mfyxItem := userYanxuanPermissionMap[int(item.UserId)]

+ 1 - 0
models/company/company_user.go

@@ -73,6 +73,7 @@ type CompanyUser struct {
 	MfyxStartDate            string    `description:"买方研选权限开始日期"`
 	MfyxEndDate              string    `description:"买方研选权限结束日期"`
 	MfyxStatus               string    `description:"买方研选状态'试用','未开通'"`
+	RaiUserStatus            string    `description:"用户权限状态"`
 	MfyxInteractionNum       int       `description:"互动量"`
 	MfyxIsBinding            bool      `description:"买方研选是否绑定"`
 	MfyxBindingTime          string    `description:"买方研选绑定时间"`

+ 49 - 0
models/company/user_product.go

@@ -0,0 +1,49 @@
+package company
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_crm_api/utils"
+	"time"
+)
+
+type UserProduct struct {
+	UserProductId   int       `orm:"column(user_product_id);pk" description:"用户产品id"`
+	CompanyId       int       `description:"客户id"`
+	ProductId       int       `description:"产品id"`
+	ProductName     string    `description:"产品名称"`
+	CompanyName     string    `description:"客户名称"`
+	Status          string    `description:"客户状态"`
+	IsSuspend       int       `description:"1:暂停,0:启用"`
+	SuspendTime     time.Time `description:"暂停启用时间"`
+	TryOutTime      time.Time `description:"正式转试用时间"`
+	CreateTime      time.Time `description:"创建时间"`
+	ModifyTime      time.Time `description:"修改时间"`
+	StartDate       string    `description:"开始日期"`
+	EndDate         string    `description:"结束日期"`
+	ContractEndDate time.Time `description:"合同结束日期"`
+	CloseReason     string    `description:"关闭原因"`
+	CloseTime       time.Time `description:"关闭时间"`
+	RealName        string    `description:"用户姓名"`
+	Mobile          string    `description:"手机号"`
+	Email           string    `description:"邮箱"`
+	UserId          int       `description:"用户ID"`
+}
+
+// 新增客户产品
+func AddUserProduct(item *UserProduct) (newId int64, err error) {
+	o := orm.NewOrm()
+	newId, err = o.Insert(item)
+	return
+}
+
+// 根据用户ID获取列表信息
+func GetUserProductByUserIds(userIds []int) (items []*UserProduct, err error) {
+	lenArr := len(userIds)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT * FROM user_product WHERE user_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
+	_, err = o.Raw(sql, userIds).QueryRows(&items)
+	return
+}

+ 30 - 0
services/user.go

@@ -473,3 +473,33 @@ func AddHzCompanyUser(mobile, realName string, adminId int, adminName string) {
 	})
 	return
 }
+
+// GetRaiUserStatus 新增弘则联系人
+func GetRaiUserStatus(userIds []int) (mapUserStatus map[int]string) {
+	var err error
+	mapUserStatus = make(map[int]string, 0)
+
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("自动添加弘则联系人失败, Err: "+err.Error(), 3)
+		}
+	}()
+	lenArr := len(userIds)
+	if lenArr == 0 {
+		return
+	}
+
+	for _, v := range userIds {
+		mapUserStatus[v] = "关闭"
+	}
+
+	listUserProduct, e := company.GetUserProductByUserIds(userIds)
+	if e != nil {
+		err = errors.New("GetUserProductByUserIds" + e.Error())
+		return
+	}
+	for _, v := range listUserProduct {
+		mapUserStatus[v.UserId] = v.Status
+	}
+	return
+}