Parcourir la source

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

xingzai il y a 1 an
Parent
commit
ef11974248

+ 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)

+ 167 - 34
controllers/activity_sign.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -70,6 +71,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 +92,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.Mobile != "" || user.Email != "") && (applyCount > 0 || user.CompanyId > 1) {
 		err = models.AddCygxActivitySignin(item)
 		if err != nil {
 			br.Msg = "签到失败"
@@ -126,17 +136,36 @@ func (this *ActivitySignCoAntroller) Detail() {
 
 		//后期扫码签到,处理是否爽约限制
 		services.CygxActivityRestrictSignupByuid(user.UserId, activityId)
-	}
 
-	if user.Mobile != "" || total > 0 {
+		//线下调研活动扫码签到给对应销售发模版消息
+		services.SendActivitieSignTemplateMsg(user, activityInfo)
+	}
+	//1,没有签到记录不为潜在客户
+	//2,没有签到记录,手机号不为空,没有申请记录
+	//3,已经有签到记录的
+	if total == 0 && user.CompanyId > 1 || ((user.Mobile != "" || user.Email != "") && applyCount > 0) || total > 0 {
 		resp.IsBindingMobile = true
 	}
 	if user.CompanyId == 1 {
 		detail.IsNewUser = true
 	}
+
+	//潜在客户提交过申请的显示提交时候的公司
+	if applyCount > 0 && (user.Mobile != "" || user.Email != "") && user.CompanyId == 1 {
+		detail, err := models.GetCygxApplyRecordByMobile(user.Mobile)
+		if err != nil {
+			br.Msg = "签到失败"
+			br.ErrMsg = "GetCygxApplyRecordByMobile,Err:" + err.Error()
+			return
+		}
+		user.CompanyName = detail.CompanyName
+	}
 	detail.ActivityId = activityId
 	detail.ActivityName = activityInfo.ActivityName
 	detail.Mobile = user.Mobile
+	if user.Mobile == "" {
+		detail.Mobile = user.Email
+	}
 	detail.RealName = user.RealName
 	detail.CompanyName = user.CompanyName
 
@@ -154,6 +183,9 @@ func (this *ActivitySignCoAntroller) Detail() {
 		if signinDetail != nil {
 			detail.BusinessCard = signinDetail.BusinessCard
 			detail.Mobile = signinDetail.Mobile
+			if signinDetail.Mobile == "" {
+				detail.Mobile = signinDetail.Email
+			}
 			detail.RealName = signinDetail.RealName
 			detail.CompanyName = signinDetail.CompanyName
 			detail.IsNewUser = true
@@ -236,44 +268,61 @@ func (this *ActivitySignCoAntroller) ByHand() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	if signinType == 1 {
-		if req.Mobile == "" {
-			br.Msg = "参数错误"
-			br.ErrMsg = "参数错误,手机号为空 为空"
-			return
-		}
-		itemMsgCode, err := models.GetMsgCode(req.Mobile, req.VCode)
-		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
-				br.Msg = "验证码错误,请重新输入"
-				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+	if user.Mobile == "" && user.Email == "" {
+		if signinType == 1 {
+			if req.Mobile == "" {
+				br.Msg = "参数错误"
+				br.ErrMsg = "参数错误,手机号为空 为空"
 				return
-			} else {
+			}
+			itemMsgCode, err := models.GetMsgCode(req.Mobile, req.VCode)
+			if err != nil {
+				if err.Error() == utils.ErrNoRow() {
+					br.Msg = "验证码错误,请重新输入"
+					br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+					return
+				} else {
+					br.Msg = "验证码错误,请重新输入"
+					br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+					return
+				}
+			}
+			if itemMsgCode == nil {
 				br.Msg = "验证码错误,请重新输入"
-				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
 				return
 			}
-		}
-		if itemMsgCode == nil {
-			br.Msg = "验证码错误,请重新输入"
-			return
-		}
-		userMobile, err := models.GetWxUserItemByMobile(Mobile)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "签到失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		if userMobile != nil {
-			user = userMobile
+			userMobile, err := models.GetWxUserItemByMobile(Mobile)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "签到失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			if userMobile != nil {
+				user = userMobile
+			}
+		} else {
+			if BusinessCard == "" {
+				br.Msg = "签到失败"
+				br.ErrMsg = "签到失败名片地址为空,Err:"
+				return
+			}
+			item.BusinessCard = BusinessCard
 		}
 	} else {
-		if BusinessCard == "" {
-			br.Msg = "签到失败"
-			br.ErrMsg = "签到失败名片地址为空,Err:"
-			return
+		if signinType == 1 {
+			if CompanyName == "" {
+				br.Msg = "请输入公司名称"
+				return
+			}
+			if RealName == "" {
+				br.Msg = "请输入姓名"
+				return
+			}
 		}
-		item.BusinessCard = BusinessCard
+	}
+	//如果是用邮箱登录的,就把手机号置空
+	if strings.Contains(Mobile, "@") {
+		Mobile = ""
 	}
 	item.ActivityId = activityId
 	item.UserId = user.UserId
@@ -336,3 +385,87 @@ 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 do_fail_type = 0 AND activity_id  = ?`
+	pars = append(pars, activityId)
+
+	listSignup, err := models.GetActivitySignupList(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetOfflineMeetingListWithUser,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+	//获取对应销售所能查看的用户手机号
+	UserMobileMap, err := services.GetAdminCheckUserMobileMap(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetAdminCheckUserMobileMap,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+	//获取用户的签到时间
+	SigninTimeMap, err := services.GetUserActivitySigninTimeMap(activityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetUserActivitySigninTimeMap,activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	for _, v := range listSignup {
+		if _, ok := UserMobileMap[v.Mobile]; ok {
+			item := new(models.CygxActivitySignupResp)
+			item.RealName = v.RealName
+			item.CompanyName = v.CompanyName
+			if _, ok := SigninTimeMap[v.UserId]; ok {
+				item.IsMeeting = 1
+				item.SigninTime = SigninTimeMap[v.UserId]
+			}
+			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
+}

+ 98 - 13
controllers/report_selection.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
@@ -36,19 +37,21 @@ func (this *ReportSelectionController) Detail() {
 	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	isBestNew, _ := this.GetBool("IsBestNew")
-	isBestNew = true
-	if isBestNew {
-		tbdb := "cygx_report_selection"
-		condition := ` AND publish_status = 1  `
-		var pars []interface{}
-		list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		for _, v := range list {
-			articleId = v.ArticleId
+	if articleId == 0 || isBestNew {
+		isBestNew = true
+		if isBestNew {
+			tbdb := "cygx_report_selection"
+			condition := ` AND publish_status = 1  `
+			var pars []interface{}
+			list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			for _, v := range list {
+				articleId = v.ArticleId
+			}
 		}
 	}
 	if articleId < 1 {
@@ -307,3 +310,85 @@ func (this *ReportSelectionController) AddStopTime() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title 获取报告精选列表
+// @Description 获取报告精选列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.ReportSelectionLetailResp
+// @router /list [get]
+func (this *ReportSelectionController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.CygxReportSelectionListPublicRep)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	condition += ` AND art.publish_status = 1 AND article_id >= 16 `
+	total, err := models.GetCygxReportSelectionCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY art.publish_date  DESC "
+	list, err := models.GetReportSelectionList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	var articleIdArr []int
+	for _, v := range list {
+		v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+		articleIdArr = append(articleIdArr, v.ArticleId)
+	}
+
+	lenarticleIdArr := len(articleIdArr)
+	maplabel := make(map[int]string)
+	if lenarticleIdArr > 0 {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = ` AND is_new = 1  AND article_id IN (` + utils.GetOrmInReplace(lenarticleIdArr) + `)`
+		pars = append(pars, articleIdArr)
+		listLog, err := models.GetCygxReportSelectionLog(condition, pars, 0, 9999)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,GetCygxReportSelectionLogErr:" + err.Error()
+			return
+		}
+		for _, v := range listLog {
+			maplabel[v.ArticleId] += v.SubjectName + ","
+		}
+	}
+	for _, v := range list {
+		v.SubjectName = strings.TrimRight(maplabel[v.ArticleId], ",")
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 34 - 0
controllers/user.go

@@ -1779,3 +1779,37 @@ func (this *UserController) Tracking() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// @Title 未付费申请试用详情
+// @Description 未付费申请试用详情接口
+// @Param   ApplyRecordId    query   int true       "申请ID"
+// @Success 200 {object} models.ArticleCollectListResp
+// @Success 200
+// @router /apply/detail [get]
+func (this *UserController) ApplyDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.CygxApplyRecordResp)
+	applyRecordId, _ := this.GetInt("ApplyRecordId")
+	detail, err := models.GetCygxApplyRecordById(applyRecordId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp.Detail = detail
+	br.Msg = "申请成功!"
+	br.Ret = 200
+	br.Success = true
+	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
+}

+ 13 - 0
models/activity_signin.go

@@ -64,6 +64,19 @@ func GetCygxActivitySigninCount(condition string, pars []interface{}) (count int
 	return
 }
 
+// GetCygxActivitySigninList 获取签到列表信息
+func GetCygxActivitySigninList(condition string, pars []interface{}) (items []*CygxActivitySignin, err error) {
+	sql := `SELECT
+			*
+		FROM
+			cygx_activity_signin AS art
+		WHERE
+			1 = 1 	` + condition
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 func GetCygxActivitySigninDetail(condition string, pars []interface{}) (item *CygxActivitySignin, err error) {
 	sql := `SELECT *  FROM cygx_activity_signin as art WHERE 1= 1 `
 	if condition != "" {

+ 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
+}

+ 29 - 7
models/apply_record.go

@@ -6,13 +6,15 @@ import (
 )
 
 type CygxApplyRecord struct {
-	ApplyRecordId   int       `orm:"column(apply_record_id);pk" description:"申请试用id"`
-	BusinessCardUrl string    `description:"名片地址"`
-	RealName        string    `description:"姓名"`
-	CompanyName     string    `description:"公司名称"`
-	Mobile          string    `description:"手机号"`
-	CreateTime      time.Time `description:"创建时间"`
-	ApplyMethod     int       `description:"1:已付费客户申请试用,2:非客户申请试用"`
+	ApplyRecordId    int       `orm:"column(apply_record_id);pk" description:"申请试用id"`
+	BusinessCardUrl  string    `description:"名片地址"`
+	RealName         string    `description:"姓名"`
+	CompanyName      string    `description:"公司名称"`
+	CompanyNamePay   string    `description:"公司名称"`
+	Mobile           string    `description:"手机号"`
+	CreateTime       time.Time `description:"创建时间"`
+	ApplyMethod      int       `description:"1:已付费客户申请试用,2:非客户申请试用"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
 func AddApplyRecord(item *ApplyTryReq, mobile, companyNamePay string, userId, companyIdPay, CompanyIdType int) (err error) {
@@ -52,3 +54,23 @@ func GetApplyRecordCount(userId int) (count int, err error) {
 	err = o.Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+// 通过手机号获取详情
+func GetCygxApplyRecordByMobile(mobile string) (item *CygxApplyRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_apply_record   WHERE mobile=? AND status=0   ORDER BY apply_record_id DESC   LIMIT 1 `
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
+// 通过ID获取详情
+func GetCygxApplyRecordById(applyRecordId int) (item *CygxApplyRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_apply_record  WHERE apply_record_id=?  `
+	err = o.Raw(sql, applyRecordId).QueryRow(&item)
+	return
+}
+
+type CygxApplyRecordResp struct {
+	Detail *CygxApplyRecord
+}

+ 24 - 17
models/report_selection.go

@@ -3,7 +3,6 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
-	"time"
 )
 
 type CygxReportSelectionRep struct {
@@ -16,6 +15,7 @@ type CygxReportSelectionRep struct {
 	UpdateDescription string `description:"更新说明"`
 	IsRed             bool   `description:"是否标记红点"`
 	ReadNum           int    `description:"阅读次数"`
+	SubjectName       string `description:"标的名称"`
 }
 
 type CygxReportSelectionListPublicRep struct {
@@ -100,6 +100,29 @@ func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (c
 	return
 }
 
+// 获取数量
+func GetCygxReportSelectionCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_report_selection as art WHERE 1= 1 AND art.publish_status = 1   `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetReportSelectionList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  as art WHERE 1= 1 AND art.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 // 通过ID获取详情
 func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
@@ -140,22 +163,6 @@ func GetReportSelectionListHome(condition, tbdb string, pars []interface{}, star
 	return
 }
 
-type CygxReportSelectionLog struct {
-	ArticleSunId           int       `description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	PermissionName         string    `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    int       `description:"标的ID"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	SubjectName            string    `description:"标的名称"`
-	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
-	CompanyLabel           []string  `description:"公司标签"`
-	Label                  string    `description:"公司标签"`
-	OverviewArticleId      int       `description:"综述报告Id"`
-}
-
 // 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()

+ 34 - 0
models/report_selection_log.go

@@ -0,0 +1,34 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionLog struct {
+	ArticleSunId           int       `description:"子级报告id"`
+	ArticleId              int       `description:"父级报告Id"`
+	ChartPermissionId      int       `description:"行业ID"`
+	PermissionName         string    `description:"行业ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Body                   string    `description:"内容"`
+	IndustrialSubjectId    int       `description:"标的ID"`
+	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
+	SubjectName            string    `description:"标的名称"`
+	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel           []string  `description:"公司标签"`
+	Label                  string    `description:"公司标签"`
+	OverviewArticleId      int       `description:"综述报告Id"`
+}
+
+// 列表
+func GetCygxReportSelectionLog(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection_log as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 27 - 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",
@@ -1105,6 +1114,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
         beego.ControllerComments{
             Method: "ArticleHotList",
@@ -1285,6 +1303,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "ApplyDetail",
+            Router: `/apply/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "ApplyTryOut",

+ 27 - 0
services/activity_signin.go

@@ -179,3 +179,30 @@ func CygxActivityRestrictSignupByuid(uid, activityId int) (err error) {
 	}
 	return
 }
+
+// GetUserActivitySigninTimeMap  获取用户的签到时间
+func GetUserActivitySigninTimeMap(activityId int) (mapItem map[int]string, err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("扫码签到日志记录,失败,活动ID:"+strconv.Itoa(activityId)+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = "  AND activity_id = ?  "
+	pars = append(pars, activityId)
+	userList, e := models.GetCygxActivitySigninList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCygxActivitySigninList" + e.Error())
+		return
+	}
+	mapItem = make(map[int]string, 0)
+	for _, v := range userList {
+		if v.UserId == 0 {
+			continue
+		}
+		mapItem[v.UserId] = v.CreateTime.Format(utils.FormatDateTime)
+	}
+	return
+}

+ 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 != "release" {
+		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
+}

+ 11 - 0
services/wechat_send_msg.go

@@ -9,6 +9,7 @@ import (
 	"hongze/hongze_cygx/utils"
 	"io/ioutil"
 	"net/http"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -156,6 +157,16 @@ func SendPermissionApplyTemplateMsg(realName, companyName, mobile, applyMethod s
 	var keyword4 string
 	var remark string
 	var redirectUrl string
+
+	detail, e := models.GetCygxApplyRecordByMobile(mobile)
+	if e != nil {
+		err = errors.New("GetActivitySignupNomeetingCountList" + e.Error())
+		return
+	}
+	//如果是潜在客户就推送可查看详情的模版消息
+	if detail.ApplyMethod == 2 && utils.RunMode == "release" {
+		redirectUrl = utils.WX_MSG_PATH_APPLY_DETAIL + strconv.Itoa(detail.ApplyRecordId)
+	}
 	keyword1 = "权限申请:" + realName + "【" + companyName + "】"
 	keyword2 = mobile
 	keyword3 = time.Now().Format(utils.FormatDateTime)

+ 3 - 0
utils/config.go

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

+ 2 - 0
utils/constants.go

@@ -169,6 +169,8 @@ 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          = "pages-message/activityTemplate/activityTemplate?id="          //活动模板消息地址
+	WX_MSG_PATH_APPLY_DETAIL           = "pages-message/applyFor/applyFor?id="                          //潜在用户试用权限申请
 )
 
 //2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=