Browse Source

Merge branch 'cygx_3.2' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 năm trước cách đây
mục cha
commit
d447c93d3e

+ 2 - 1
controllers/activity.go

@@ -542,8 +542,9 @@ func (this *ActivityCoAntroller) Detail() {
 		} else {
 			activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
 		}
-		if (activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6) && services.GetBelongingRai(user.Mobile) {
+		if (activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6) && services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" {
 			activityInfo.IsShowSigninButton = true
+			activityInfo.IsShowSignUpDetail = true
 		}
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)

+ 87 - 2
controllers/activity_sign.go

@@ -70,6 +70,15 @@ func (this *ActivitySignCoAntroller) Detail() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+
 	item := new(models.CygxActivitySignin)
 	item.ActivityId = activityId
 	item.UserId = user.UserId
@@ -82,7 +91,7 @@ func (this *ActivitySignCoAntroller) Detail() {
 	item.CountryCode = user.CountryCode
 	item.OpenId = user.OpenId
 	item.CreateTime = time.Now()
-	if total == 0 && user.Mobile != "" {
+	if total == 0 && user.CompanyId > 1 || (user.Mobile != "" && applyCount > 0) {
 		err = models.AddCygxActivitySignin(item)
 		if err != nil {
 			br.Msg = "签到失败"
@@ -126,9 +135,12 @@ func (this *ActivitySignCoAntroller) Detail() {
 
 		//后期扫码签到,处理是否爽约限制
 		services.CygxActivityRestrictSignupByuid(user.UserId, activityId)
+
+		//线下调研活动扫码签到给对应销售发模班消息
+		services.SendActivitieSignTemplateMsg(user, activityInfo)
 	}
 
-	if user.Mobile != "" || total > 0 {
+	if total == 0 && user.CompanyId > 1 || (user.Mobile != "" && applyCount > 0) {
 		resp.IsBindingMobile = true
 	}
 	if user.CompanyId == 1 {
@@ -336,3 +348,76 @@ func (this *ActivitySignCoAntroller) ByHand() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title  活动签到到会详情
+// @Description 活动签到到会详情接口
+// @Param   ActivityId   query   int  true       "活动ID"
+// @Success Ret=200 {object} models.CygxActivityResp
+// @router /signup/detail [get]
+func (this *ActivitySignCoAntroller) SignupDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	activityId, _ := this.GetInt("ActivityId")
+	if activityId < 1 {
+		br.Msg = "请输入活动ID"
+		return
+	}
+	resp := new(models.CygxActivityOfflineMeetingDetailResp)
+	activityInfo, err := models.GetAddActivityInfoById(activityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
+		return
+	}
+	if !services.GetBelongingRai(user.Mobile) {
+		br.Msg = "你暂无查看权限"
+		br.ErrMsg = "你暂无查看权限,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = `  AND activity_id = ? `
+	pars = append(pars, activityId)
+	listOfflineMeeting, err := models.GetOfflineMeetingListWithUser(condition, pars)
+
+	UserMobileMap, err := services.GetAdminCheckUserMobileMap(user)
+	if err != nil {
+		br.Msg = "你暂无查看权限"
+		br.ErrMsg = "你暂无查看权限,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+
+	for _, v := range listOfflineMeeting {
+		if _, ok := UserMobileMap[v.Mobile]; !ok {
+			item := new(models.CygxActivitySignupResp)
+			item.RealName = v.RealName
+			item.CompanyName = v.CompanyName
+			item.IsMeeting = v.IsMeeting
+			if v.IsMeeting == 1 {
+				item.SigninTime = v.SigninTime
+			}
+			resp.List = append(resp.List, item)
+		}
+	}
+	if len(resp.List) == 0 {
+		resp.List = make([]*models.CygxActivitySignupResp, 0)
+	}
+	resp.ActivityId = activityId
+	resp.ActivityName = activityInfo.ActivityName
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
models/activity.go

@@ -206,6 +206,7 @@ type ActivityDetail struct {
 	TencentConferenceNumber string                     `description:"腾讯会议号"`
 	YidongActivityIdByCygx  string                     `description:"通过查研观向建会易董返回的活动ID"`
 	IsShowSigninButton      bool                       `description:"是否展示签到码按钮"`
+	IsShowSignUpDetail      bool                       `description:"是否展示报名详情按钮"`
 	SigninImg               string                     `description:"签到码图片"`
 }
 type ListArticleActivity struct {

+ 17 - 0
models/activity_offline_meeting_detail.go

@@ -72,3 +72,20 @@ func GetOfflineMeetingListByUser(meetingUids string, activityId int) (items []*C
 	_, err = o.Raw(sql, activityId).QueryRows(&items)
 	return
 }
+
+// 报名
+type CygxActivityOfflineMeetingDetailResp struct {
+	ActivityId   int    `description:"活动ID "`
+	ActivityName string `description:"活动名称"`
+	List         []*CygxActivitySignupResp
+}
+
+// 预约外呼列表
+func GetOfflineMeetingListWithUser(condition string, pars []interface{}) (items []*CygxActivitySignupList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT s.* , u.real_name
+			FROM cygx_activity_offline_meeting_detail  as s 
+			INNER JOIN wx_user as u ON u.user_id = s.user_id  WHERE 1 =1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 8 - 0
models/activity_signup.go

@@ -520,6 +520,14 @@ type CygxActivitySignupList struct {
 	Mobile      string `description:"手机号"`
 	Email       string `description:"邮箱"`
 	CompanyId   int    `description:"公司id"`
+	SigninTime  string `description:"签到时间"`
+}
+
+type CygxActivitySignupResp struct {
+	CompanyName string `description:"公司名称"`
+	RealName    string `description:"姓名"`
+	IsMeeting   int    `description:"是否到会 ,1是, 0否"`
+	SigninTime  string `description:"签到时间"`
 }
 
 // 获取用户报名列表

+ 19 - 0
models/admin.go

@@ -61,6 +61,13 @@ func GetSysAdminById(adminId int) (item *Admin, err error) {
 	return
 }
 
+func GetSysAdminByMobile(mobile string) (item *Admin, err error) {
+	sql := `SELECT * FROM admin WHERE mobile=? LIMIT 1 `
+	o := orm.NewOrm()
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
 // 获取权益内部人员手机号
 func GetRaiAdmin() (items []*AdminMobileResp, err error) {
 	o := orm.NewOrm()
@@ -78,3 +85,15 @@ WHERE
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+type GetSellerUserMobileResp struct {
+	Mobile string `description:"手机号"`
+}
+
+// 获取销售所能查看到的手机号
+func GetSellerUserMobile(adminId int) (items []*GetSellerUserMobileResp, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT mobile FROM user_seller_relation WHERE seller_id  = ? `
+	_, err = o.Raw(sql, adminId).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -250,6 +250,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"],
+        beego.ControllerComments{
+            Method: "SignupDetail",
+            Router: `/signup/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
         beego.ControllerComments{
             Method: "SpecialTripAdd",

+ 67 - 0
services/activity_wx_template_msg.go

@@ -83,3 +83,70 @@ func SendResearchActivitiesTemplateMsg(user *models.WxUserItem, activityDetail *
 	}
 	return
 }
+
+// SendActivitieSignTemplateMsg 线下调研活动扫码签到给对应销售发模班消息
+func SendActivitieSignTemplateMsg(user *models.WxUserItem, activityDetail *models.ActivityDetail) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("线下调研活动扫码签到给对应销售发模班消息推送失败Err:", err.Error(), "活动ID:", activityDetail.ActivityId, "手机号:", user.Mobile), 2)
+		}
+	}()
+	var mobiles []string
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if sellerItem != nil {
+		mobiles = append(mobiles, sellerItem.Mobile)
+	}
+
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	var redirectUrl string
+
+	first = ""
+	keyword1 = activityDetail.ActivityName
+	keyword2 = user.RealName + "——" + user.CompanyName
+	keyword3 = time.Now().Format(utils.FormatDateTime)
+	keyword4 = ""
+	remark = ""
+
+	openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
+	if e != nil {
+		err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
+		return
+	}
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	if utils.RunMode == "" {
+		redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityDetail.ActivityId)
+	} else {
+		redirectUrl = utils.WX_MSG_PATH_ACTIVITY_SIGN + strconv.Itoa(activityDetail.ActivityId)
+	}
+
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdActivitySign
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(activityDetail.ActivityId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_COMMENT
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}

+ 20 - 0
services/admin.go

@@ -64,3 +64,23 @@ func GetBelongingRai(mobile string) (isBelong bool) {
 	}
 	return
 }
+
+// GetAdminCheckUserMobileMap  获取对应销售所能查看的用户手机号
+func GetAdminCheckUserMobileMap(user *models.WxUserItem) (mapItem map[string]string, err error) {
+	admin, e := models.GetSysAdminByMobile(user.Mobile)
+	if e != nil {
+		err = e
+		return
+	}
+	userList, e := models.GetSellerUserMobile(admin.AdminId)
+	if e != nil {
+		err = e
+		return
+	}
+	mapMobile := make(map[string]string)
+	for _, v := range userList {
+		mapMobile[v.Mobile] = v.Mobile
+	}
+	mapItem = mapMobile
+	return
+}

+ 3 - 0
utils/config.go

@@ -44,6 +44,7 @@ var (
 	WxMsgTemplateIdArticleUserRemind      string //用户阅读报告通知-模板ID
 	WxMsgTemplateIdArticleUserRemindXzs   string //用户阅读报告通知-模板ID(小助手)
 	WxMsgTemplateIdActivityChangeApplyXzs string //查研观向活动变更通知-模板ID(小助手)
+	WxMsgTemplateIdActivitySign           string //查研观向活动签到通知-模板ID(小助手)
 )
 
 // 微信公众号配置信息
@@ -228,6 +229,7 @@ func init() {
 		WxMsgTemplateIdApplyCancelXzs = "UU_d7ks0XZBnWg2xFzxL9Heilm4kisX39K7dr4SDdO8"         ////预约取消提醒(小助手)
 		TemplateIdByProductXzs = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"                //产品运行报告通知-模板ID(小助手)
 		WxMsgTemplateIdActivityChangeApplyXzs = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM" //查研观向活动变更通知-模板ID(小助手)
+		WxMsgTemplateIdActivitySign = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"           //查研观向活动签到通知-模板ID(小助手)
 	} else {
 		//新的模板ID
 		WxPublicIdXzs = "wxb7cb8a15abad5b8e"                                                  //查研观向小助手
@@ -238,6 +240,7 @@ func init() {
 		WxMsgTemplateIdApplyCancelXzs = "gCSCAWNNhjkzE2V1cjbIV_Ex68R_8LM_u25qDlSKWyM"         ////预约取消提醒(小助手)
 		TemplateIdByProductXzs = "tNcCUiK_uUkuxaFF7M9NP2RwLkw8uHFjG-TDIxGUKxo"                //产品运行报告通知-模板ID(小助手)
 		WxMsgTemplateIdActivityChangeApplyXzs = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s" //查研观向活动变更通知-模板ID(小助手)
+		WxMsgTemplateIdActivitySign = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s"           //查研观向活动签到通知-模板ID(小助手)
 	}
 
 	//易董开放api配置

+ 1 - 0
utils/constants.go

@@ -170,6 +170,7 @@ const (
 	WX_MSG_PATH_LAST_WEEK_DETAIL       = "reportPages/reportSecretDetail/reportSecretDetail?type=3&id=" //上周纪要汇总详情模板消息地址
 	WX_MSG_PATH_KEY_COMPANY_DETAIL     = "reportPages/keyCompany/keyCompany"                            //重点公司详情模板消息地址
 	WX_MSG_PATH_RESEARCHTHEME_DETAIL   = "reportPages/researchTheme/researchTheme?id="                  //主题详情模板消息地址
+	WX_MSG_PATH_ACTIVITY_SIGN          = "activityPages/activityDetail/activityDetail?id="              //活动模板消息地址
 )
 
 //2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=