Pārlūkot izejas kodu

Merge branch 'CRM_14.5' into debug

# Conflicts:
#	services/cygx/activity_ocr.go
zwxi 1 gadu atpakaļ
vecāks
revīzija
d11b27ea00

+ 49 - 0
controllers/company_user.go

@@ -5927,3 +5927,52 @@ func (this *CompanyUserController) ImportListMatchDownload() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// Follow
+// @Title 关注联系人
+// @Description 关注联系人
+// @Param	request	body request.ApplyMarkReq true "type json string"
+// @Success 200 {object} 标记处理成功
+// @router /follow [post]
+func (this *CompanyUserController) Follow() {
+	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.FollowReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.UserId <= 0  {
+		br.Msg = "用户ID异常"
+		br.ErrMsg = "用户ID异常"
+		return
+	}
+
+	// 查公司里有多少已关注,上限三个
+
+
+	// 关注或取关
+	err = models.SetUserFollow(req.UserId, req.Type)
+	if err != nil {
+		br.Msg = "操作失败! "
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 2 - 1
controllers/cygx/activity_meet.go

@@ -1788,7 +1788,8 @@ func (this *ActivityMeetCoAntroller) MatchingByHand() {
 			}
 			go cygxService.AddCygxActivityRestrictSignupByAdmin(activityId)
 			go cygx.AddCygxActivityMeetDetailLogOnline(needAddAttendanc, activityId)
-			go cygxService.ActivityUserLabelLogAdd(activityId, userIdArr)
+			go cygxService.ActivityUserLabelLogAdd(activityId, userIdArr)                 //添加用户活动到会标签到Redis
+			go cygxService.AddctivitySignupDetailListByHand(needAddAttendanc, activityId) //手动匹配进门财经信息
 		} else {
 			br.Msg = "手动归类失败"
 			br.ErrMsg = "暂未找到匹配数据!"

+ 7 - 0
models/company_user/request/follow.go

@@ -0,0 +1,7 @@
+package request
+
+
+type FollowReq struct {
+	UserId        int `description:"用户ID"`
+	Type         int `description:"类型 0取关 1关注"`
+}

+ 14 - 0
models/wx_user.go

@@ -585,3 +585,17 @@ func GetWxUserList(condition string, pars []interface{}) (items []*WxUser, err e
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+func SetUserFollow(userId, follow int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE wx_user SET is_follow=? WHERE user_id=? `
+	_, err = o.Raw(sql, follow, userId).Exec()
+	return
+}
+
+func GetCompanyFollowCount(companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT COUNT(1) FROM wx_user WHERE user_id=? `
+	_, err = o.Raw(sql, companyId).Exec()
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -9664,6 +9664,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
+        beego.ControllerComments{
+            Method: "Follow",
+            Router: `/follow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
         beego.ControllerComments{
             Method: "GetCompanySellerList",

+ 122 - 0
services/cygx/activity_meet.go

@@ -3,6 +3,7 @@ package cygx
 import (
 	"errors"
 	"fmt"
+	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/services/alarm_msg"
 	"hongze/hz_crm_api/utils"
@@ -225,3 +226,124 @@ func AddctivitySignupDetailList(itemsDetail []*cygx.CygxActivitySignupDetail, ac
 
 	return err
 }
+
+// AddctivitySignupDetailListByHand 手动匹配进门财经信息
+func AddctivitySignupDetailListByHand(itemsDetail []*cygx.CygxActivityAttendanceDetail, activityId int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg("通过进门财经添加用户参数信息失败 ErrMsg:"+err.Error(), 2)
+		}
+	}()
+
+	activityIds := make([]int, 0)
+	activityIds = append(activityIds, activityId)
+	actLen := len(activityIds)
+	var condition string
+	var pars []interface{}
+	if actLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(actLen) + `)`
+		pars = append(pars, activityIds)
+	}
+
+	signUpDetailList, err := cygx.GetSignupDetailList(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	mapsignUpDetai := make(map[string]string)
+	if len(signUpDetailList) > 0 {
+		for _, v := range signUpDetailList {
+			mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)] = v.Mobile
+		}
+	}
+
+	//获取当天已经结束了 活动的报名人数
+	signUpList, err := cygx.GetSignupDetailBySignup(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	//建立外呼号与手机号的绑定
+	mapsignUp := make(map[string]string)
+	if len(signUpList) > 0 {
+		for _, v := range signUpList {
+			mapsignUp[fmt.Sprint(v.OutboundMobile)] = v.Mobile
+		}
+	}
+
+	var itemsAdd []*cygx.CygxActivitySignupDetail
+	var itemsUpdate []*cygx.CygxActivitySignupDetail
+
+	var mobiles []string
+	mobileMap := make(map[string]bool)
+	mobileUserMap := make(map[string]int)
+	for _, v := range itemsDetail {
+		if !mobileMap[v.Mobile] {
+			mobiles = append(mobiles, v.Mobile)
+		}
+		mobileMap[v.Mobile] = true
+	}
+
+	//根据手机号获取这些用户的信息
+	listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
+	if e != nil {
+		err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range listUser {
+		mobileUserMap[v.Mobile] = int(v.UserId)
+	}
+
+	for _, v := range itemsDetail {
+		var item = new(cygx.CygxActivitySignupDetail)
+		item.ActivityId = v.ActivityId
+		//item.RealName = v.RealName
+		//如果手机号存在那么就是报名的,不存在就是直接参与的
+		if _, ok := mapsignUp[v.Mobile]; ok {
+			item.Mobile = mapsignUp[v.Mobile]
+		} else {
+			item.Mobile = v.Mobile
+		}
+		item.UserId = mobileUserMap[v.Mobile]
+		item.RealName = v.RealName
+		item.OutboundMobile = v.Mobile
+		item.CompanyName = v.CompanyName
+		item.CompanyId = v.CompanyId
+		item.SellerName = v.SellerName
+		item.FirstMeetingTime = v.FirstMeetingTime
+		item.LastMeetingTime = v.LastMeetingTime
+		item.Duration = v.Duration
+		item.MeetingTypeStr = v.MeetingTypeStr
+		item.MeetingAuthentication = v.MeetingAuthentication
+		item.MeetingStatusStr = v.MeetingStatusStr
+		item.CreateTime = v.CreateTime
+		item.Position = v.Position
+		item.IsMeeting = 1
+		item.UseridEntity = v.UseridEntity
+		item.ActivityTime = v.ActivityTime
+		item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
+
+		if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", item.Mobile)]; !ok {
+			itemsAdd = append(itemsAdd, item)
+		} else {
+			itemsUpdate = append(itemsUpdate, item)
+		}
+	}
+	//return err
+	if len(itemsAdd) > 0 {
+		err = cygx.AddCygxActivitySignupDetail(itemsAdd)
+		if err != nil {
+			return
+		}
+	}
+
+	if len(itemsUpdate) > 0 {
+		err = cygx.UpdateActivitySignupDetailMulti(itemsUpdate)
+		if err != nil {
+			return
+		}
+	}
+
+	return err
+}