ziwen 1 year ago
parent
commit
3ba7745618

+ 2 - 0
controllers/company.go

@@ -8597,6 +8597,8 @@ func (this *CompanyController) RemarkList() {
 		resp[i].Remark = remark.Remark
 		resp[i].ProductName = remark.ProductName
 		resp[i].CreateTime = createDate
+		resp[i].CompanyProductRemakrId = remark.CompanyProductRemakrId
+		resp[i].Mark = remark.Mark
 	}
 
 	br.Ret = 200

+ 48 - 0
controllers/company_share.go

@@ -734,3 +734,51 @@ func (this *CompanyController) CompanyShareAddRemark() {
 	br.Success = true
 	br.Msg = "编辑成功"
 }
+
+// CompanyShareMark
+// @Title 新增客户标记
+// @Description 新增客户标记
+// @Param	request	body company.RemarkReq true "type json string"
+// @Success 200 编辑成功
+// @router /share/mark [post]
+func (this *CompanyController) CompanyShareMark() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req company.CompanyMarkReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.CompanyProductRemakrId <= 0 {
+		br.Msg = "参数缺失"
+		br.ErrMsg = "参数缺失,备注ID未传!"
+		return
+	}
+	if req.CompanyProductRemakrId < 0 {
+		br.Msg = "参数异常"
+		br.ErrMsg = "参数异常,备注id错误!"
+		return
+	}
+	err = company.UpdateCompanyProductRemark(req.CompanyProductRemakrId, req.Status)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "新增共享客户备注失败, Err: " + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "编辑成功"
+}

+ 14 - 0
controllers/official_user.go

@@ -41,6 +41,9 @@ func (this *OfficialUserController) OfficialUserList() {
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	keyWord := this.GetString("KeyWord")
 	sourceType := this.GetString("SourceType")
+	markGroup := this.GetString("MarkGroup")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
 	if sourceType == "" {
 		br.Msg = "获取失败"
 		br.ErrMsg = "请选择类型"
@@ -67,6 +70,17 @@ func (this *OfficialUserController) OfficialUserList() {
 	if keyWord != "" {
 		condition += ` and (company_name LIKE '%` + keyWord + `%' OR phone LIKE '%` + keyWord + `%' OR email LIKE '%` + keyWord + `%' OR real_name LIKE '%` + keyWord + `%') `
 	}
+	if markGroup != "" {
+		condition += `AND mark_group = ` + markGroup
+	}
+	if startDate != "" {
+		startDate += " 00:00:00"
+		condition += ` AND y.create_time >= '` + startDate + `' `
+	}
+	if endDate != "" {
+		endDate += " 23:59:59"
+		condition += ` AND y.create_time <= '` + endDate + `' `
+	}
 
 	//获取总数据数
 	total, err := models.GetOfficialApplyUserListListCount(condition, pars)

+ 61 - 0
controllers/yb/apply_record.go

@@ -271,6 +271,9 @@ func (this *ApplyRecordController) UserApplyList() {
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
+	markGroup := this.GetString("MarkGroup")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
 	var startSize int
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
@@ -314,6 +317,17 @@ func (this *ApplyRecordController) UserApplyList() {
 		condition += " AND (a.real_name LIKE ? OR a.mobile LIKE ? OR a.email LIKE ? OR (a.company_id > 1 AND b.company_name LIKE ?) OR (a.company_id = 1 AND a.note LIKE ?))"
 		pars = append(pars, reqKeyword, reqKeyword, reqKeyword, reqKeyword, reqKeyword)
 	}
+	if markGroup != "" {
+		condition += `AND y.mark_group = `+"'"+markGroup+"'"
+	}
+	if startDate != "" {
+		startDate += " 00:00:00"
+		condition += ` AND a.report_last_view_time >= '` + startDate + `' `
+	}
+	if endDate != "" {
+		endDate += " 23:59:59"
+		condition += ` AND a.report_last_view_time <= '` + endDate + `' `
+	}
 
 	reqApplyStatus := this.GetString("ApplyStatus")
 	if reqApplyStatus != "" {
@@ -912,3 +926,50 @@ func (this *ApplyRecordController) DelPotentialUser() {
 	br.IsAddLog = true
 	return
 }
+
+// MarkGroup
+// @Title 标记分组
+// @Description 标记分组
+// @Param	request	body request.ApplyMarkReq true "type json string"
+// @Success 200 {object} 标记处理成功
+// @router /apply_record/mark_group [post]
+func (this *ApplyRecordController) MarkGroup() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req request.ApplyMarkGroupReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.ApplyRecordId <= 0 && req.GroupName != "" && req.UserId != 0 {
+		br.Msg = "申请记录ID或者分组名异常"
+		br.ErrMsg = "申请记录ID或者分组名异常"
+		return
+	}
+
+
+	// 标记处理
+	err = ybService.MarkGroupApplyRecord(req.ApplyRecordId, this.SysUser.AdminId, req.UserId, req.GroupName)
+	if err != nil {
+		br.Msg = "标记处理失败! "
+		br.ErrMsg = "标记处理失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "标记处理成功"
+}

+ 11 - 3
models/company/company.go

@@ -1541,9 +1541,11 @@ type RemarkReq struct {
 
 // RemarkResp 备注说明
 type RemarkResp struct {
-	Remark      string `description:"未续约说明"`
-	ProductName string `description:"客户产品:ficc:权益:"`
-	CreateTime  string `description:"添加时间"`
+	Remark                 string `description:"未续约说明"`
+	ProductName            string `description:"客户产品:ficc:权益:"`
+	CreateTime             string `description:"添加时间"`
+	CompanyProductRemakrId int
+	Mark                   int `description:"是否标记 0不是 1是"`
 }
 
 type RoadShowTotalSlice struct {
@@ -1879,3 +1881,9 @@ func Close2Loss(companyId, productId int) (err error) {
 	_, err = o.Raw(sql, companyId, productId).Exec()
 	return
 }
+
+// CompanyMarkReq 标记请求
+type CompanyMarkReq struct {
+	CompanyProductRemakrId int `description:"备注id"`
+	Status                 int `description:"0取消标记 1标记"`
+}

+ 9 - 0
models/company/company_product.go

@@ -351,6 +351,7 @@ type CompanyProductRemark struct {
 	ProductName            string    `description:"产品名称"`
 	Remark                 string    `description:"备注"`
 	CreateTime             time.Time `description:"创建时间"`
+	Mark                   int       `description:"是否标记 0不是 1是"`
 }
 
 func AddCompanyRemark(remark *CompanyProductRemark) (err error) {
@@ -375,6 +376,14 @@ func GetRemarkListByCompanyId(CompanyId string) (items []*CompanyProductRemark,
 	return
 }
 
+// 更新备注标记
+func UpdateCompanyProductRemark(remarkId, mark int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_product_remark SET mark=? AND modify_time=NOW() WHERE company_product_remark_id=? `
+	_, err = o.Raw(sql, mark, remarkId).Exec()
+	return
+}
+
 // 冻结客户
 //func FreezeCompany(productId, companyId, adminId int, remark, realName string) (msg, errMsg string){
 //	time.Sleep(time.Second)

+ 8 - 6
models/user_trial_apply.go

@@ -23,6 +23,7 @@ type UserTrialApply struct {
 	OpUserName  string    `orm:"size(64)";description:"操作用户名称"`
 	CreateTime  time.Time `description:"申请时间"`
 	ModifyTime  time.Time `description:"修改时间"`
+	MarkGroup   string    `description:"标记分组"`
 }
 
 type UserTrialApplyItem struct {
@@ -43,20 +44,21 @@ type UserTrialApplyItem struct {
 	CreateTimeStr string    `description:"申请时间字符串"`
 	ModifyTime    time.Time `description:"修改时间"`
 	ModifyTimeStr string    `description:"申请时间字符串"`
+	MarkGroup     string    `description:"标记分组"`
 }
 
-//列表数据
+// 列表数据
 type UserTrialApplyListResp struct {
 	List   []*UserTrialApplyItem
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
-//确认申请
+// 确认申请
 type UserTrialApplyConfirmReq struct {
 	Id int `description:"Id"`
 }
 
-//获取获取官网申请列表页数据的数据数
+// 获取获取官网申请列表页数据的数据数
 func GetOfficialApplyUserListListCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT 
@@ -70,7 +72,7 @@ func GetOfficialApplyUserListListCount(condition string, pars []interface{}) (co
 	return
 }
 
-//获取官网申请列表页数据
+// 获取官网申请列表页数据
 func GetOfficialApplyUserListList(condition string, pars []interface{}, startSize, pageSize int) (items []*UserTrialApplyItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * from user_trial_apply `
@@ -94,14 +96,14 @@ func GetOfficialApplyUserListListExport(condition string, pars []interface{}) (i
 	return
 }
 
-//获取申请记录信息
+// 获取申请记录信息
 func GetOfficialApplyUserById(id int) (item *UserTrialApply, err error) {
 	o := orm.NewOrm()
 	err = o.Raw(`SELECT * from user_trial_apply where id = ?`, id).QueryRow(&item)
 	return
 }
 
-//确认申请记录
+// 确认申请记录
 func ConfirmOfficialApplyUser(id int, opUserId int, opUserName string) (err error) {
 	sql := ` UPDATE user_trial_apply
 			SET

+ 4 - 1
models/yb/apply_record.go

@@ -25,6 +25,7 @@ type ApplyRecord struct {
 	CreateTime      time.Time `description:"创建时间"`
 	IsMove          int       `description:"是否已移动"`
 	Source          int       `description:"申请来源:1-我的 2-活动 3-图库"`
+	MarkGroup       string    `description:"标记分组"`
 }
 
 func (applyRecord *ApplyRecord) TableName() string {
@@ -81,6 +82,7 @@ type ApplyListV2 struct {
 	RegisterSource   int       `description:"注册来源"`
 	SourceStr        string    `description:"来源"`
 	DelBtn           bool      `description:"是否展示删除按钮,true展示,false隐藏"`
+	MarkGroup        string    `description:"标记分组"`
 }
 
 // GetApplyRecordList 获取申请记录列表
@@ -156,6 +158,7 @@ SELECT
 	y.is_move,
 	y.source,
 	y.from_page,
+	y.mark_group,
     y.company_name as user_company_name
     #bp.seller_id,
 	#bp.seller_name
@@ -280,7 +283,7 @@ func GetTotalByUserIds(userIdsStr string) (list []*UserApplyTotal, err error) {
 	return
 }
 
-//DelApplyRecordByUserId 根据用户id删除该用户的所有申请
+// DelApplyRecordByUserId 根据用户id删除该用户的所有申请
 func DelApplyRecordByUserId(userId int64) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE FROM yb_apply_record WHERE user_id=? `

+ 9 - 3
models/yb/request/apply_record.go

@@ -1,6 +1,12 @@
 package request
 
 type ApplyMarkReq struct {
-	ApplyRecordId	int		`description:"申请记录ID"`
-	UserId          int     `description:"用户ID"`
-}
+	ApplyRecordId int `description:"申请记录ID"`
+	UserId        int `description:"用户ID"`
+}
+
+type ApplyMarkGroupReq struct {
+	ApplyRecordId int    `description:"申请记录ID"`
+	GroupName     string `description:"分组名"`
+	UserId        int `description:"用户ID"`
+}

+ 18 - 0
routers/commentsRouter.go

@@ -7108,6 +7108,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"],
+        beego.ControllerComments{
+            Method: "MarkGroup",
+            Router: `/apply_record/mark_group`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"],
         beego.ControllerComments{
             Method: "MarkHandle",
@@ -8512,6 +8521,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"],
+        beego.ControllerComments{
+            Method: "CompanyShareMark",
+            Router: `/share/mark`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"],
         beego.ControllerComments{
             Method: "MoveShareSeller",

+ 73 - 0
services/yb/apply_record.go

@@ -258,3 +258,76 @@ func DeleteApplyUser(userId int64) (err error) {
 	}
 	return
 }
+
+// MarkGroupApplyRecord 标记申请记录和分组
+func MarkGroupApplyRecord(applyRecordId, adminId, userId int, groupName string) (err error) {
+	o := orm.NewOrm()
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+
+	if applyRecordId > 0 {
+		applyRecord, tErr := yb.GetApplyRecordById(applyRecordId)
+		if tErr != nil {
+			if tErr.Error() == utils.ErrNoRow() {
+				err = errors.New(fmt.Sprint("申请记录不存在:", err))
+			} else {
+				err = tErr
+			}
+			return
+		}
+		if applyRecord.OpStatus != 0 {
+			err = errors.New(fmt.Sprint("申请记录处理状态有误:", err))
+			return
+		}
+		if userId > 0 && userId != applyRecord.UserId {
+			err = errors.New(fmt.Sprint("申请记录ID与用户ID不匹配:", err))
+			return
+		}
+		userId = applyRecord.UserId
+		// 1.标记申请记录
+		applyRecord.OpStatus = 1
+		applyRecord.DealTime = time.Now()
+		applyRecord.SysUserId = adminId
+		applyRecord.MarkGroup = groupName
+		updateCols := make([]string, 0)
+		updateCols = append(updateCols, "OpStatus", "DealTime", "SysUserId","MarkGroup")
+		err = applyRecord.Update(updateCols)
+		if err != nil {
+			err = errors.New(fmt.Sprint("申请记录标记失败", err))
+			return
+		}
+	}
+
+	// 2.标记wx用户表
+	wxUser, err := models.GetWxUserByUserId(userId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			err = nil // 用户可能在潜在用户列表直接被删除,那么直接不标记
+			return
+		}
+		return
+	}
+	// 未处理过则进行标记
+	if wxUser.IsDeal == 0 {
+		wxUser.IsDeal = 1
+		wxUser.LastUpdatedTime = time.Now()
+		userUpdateCols := make([]string, 0)
+		userUpdateCols = append(userUpdateCols, "IsDeal", "LastUpdatedTime")
+		err = wxUser.Update(userUpdateCols)
+		if err != nil {
+			err = errors.New(fmt.Sprint("对应用户信息标记失败", err))
+			return
+		}
+	}
+
+	return
+}