Эх сурвалжийг харах

Merge branch 'cygx_10.4' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 жил өмнө
parent
commit
3b12044009

+ 3 - 0
controllers/activity.go

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

+ 260 - 0
controllers/activity_sign.go

@@ -0,0 +1,260 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+// 活动
+type ActivitySignCoAntroller struct {
+	BaseAuthController
+}
+
+// @Title  活动扫码自动签到
+// @Description 活动扫码签到接口
+// @Param   ActivityId   query   int  true       "活动ID"
+// @Success Ret=200 {object} models.CygxActivityResp
+// @router /detail [get]
+func (this *ActivitySignCoAntroller) Detail() {
+	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
+	}
+	uid := user.UserId
+	activityId, _ := this.GetInt("ActivityId")
+	if activityId < 1 {
+		br.Msg = "请输入活动ID"
+		return
+	}
+	resp := new(models.CygxActivitySigninDetailResp)
+	activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
+		return
+	}
+	if activityInfo == nil {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	detail := new(models.CygxActivitySigninResp)
+	if totalMySuccess > 0 {
+		detail.IsSignup = true
+	}
+	var condition string
+	var pars []interface{}
+	condition = " AND  user_id = ?  AND activity_id = ?  "
+	pars = append(pars, uid, activityId)
+	total, err := models.GetCygxActivitySigninCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	item := new(models.CygxActivitySignin)
+	item.ActivityId = activityId
+	item.UserId = user.UserId
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.RealName = user.RealName
+	item.CompanyName = user.CompanyName
+	item.IsSignup = totalMySuccess
+	item.CountryCode = user.CountryCode
+	item.CreateTime = time.Now()
+	if total == 0 && user.Mobile != "" {
+		err = models.AddCygxActivitySignin(item)
+		if err != nil {
+			br.Msg = "签到失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+	}
+	//添加日志记录
+	go services.AddCygxActivitySigninLog(item)
+	if user.Mobile != "" {
+		resp.IsBindingMobile = true
+	}
+	if user.CompanyId == 1 {
+		detail.IsNewUser = true
+	}
+	detail.ActivityId = activityId
+	detail.ActivityName = activityInfo.ActivityName
+	detail.Mobile = user.Mobile
+	detail.RealName = user.RealName
+	detail.CompanyName = user.CompanyName
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title  活动扫码手动签到
+// @Description 活动扫码手动签到接口
+// @Param   ActivityId   query   int  true       "活动ID"
+// @Success Ret=200 {object} models.CygxActivityResp
+// @router /byHand [post]
+func (this *ActivitySignCoAntroller) ByHand() {
+	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
+	}
+	uid := user.UserId
+	resp := new(models.CygxActivitySigninDetailResp)
+	var req models.CygxActivitySigninReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	signinType := req.SigninType
+	activityId := req.ActivityId
+	CountryCode := req.CountryCode
+	Mobile := req.Mobile
+	CompanyName := req.CompanyName
+	BusinessCard := req.BusinessCard
+	RealName := req.RealName
+	if activityId < 1 {
+		br.Msg = "请输入活动ID"
+		return
+	}
+	user.RealName = RealName
+	user.CompanyName = CompanyName
+	activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
+		return
+	}
+	if activityInfo == nil {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	item := new(models.CygxActivitySignin)
+
+	var condition string
+	var pars []interface{}
+	condition = " AND  user_id = ?  AND activity_id = ?  "
+	pars = append(pars, uid, activityId)
+	total, err := models.GetCygxActivitySigninCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		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()
+				return
+			} else {
+				br.Msg = "验证码错误,请重新输入"
+				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+				return
+			}
+		}
+		if itemMsgCode == nil {
+			br.Msg = "验证码错误,请重新输入"
+			return
+		}
+		userMobile, err := models.GetWxUserItemByMobile(Mobile)
+		if err != nil {
+			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
+	}
+	item.ActivityId = activityId
+	item.UserId = user.UserId
+	item.Mobile = Mobile
+	item.CountryCode = CountryCode
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.RealName = user.RealName
+	item.CompanyName = user.CompanyName
+	item.IsSignup = totalMySuccess
+	item.BusinessCard = BusinessCard
+	item.CreateTime = time.Now()
+	if total == 0 {
+		err = models.AddCygxActivitySignin(item)
+		if err != nil {
+			br.Msg = "签到失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+	}
+	detail := new(models.CygxActivitySigninResp)
+	if totalMySuccess > 0 {
+		detail.IsSignup = true
+	}
+	item.RealName = RealName
+	item.CompanyName = CompanyName
+	//添加日志记录
+	go services.AddCygxActivitySigninLog(item)
+	if user.CompanyId == 1 {
+		detail.IsNewUser = true
+	}
+	detail.ActivityId = activityId
+	detail.ActivityName = activityInfo.ActivityName
+	detail.Mobile = Mobile
+	detail.RealName = user.RealName
+	detail.CompanyName = user.CompanyName
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 2 - 0
models/activity.go

@@ -205,6 +205,8 @@ type ActivityDetail struct {
 	IsCanOutboundCall       int                        `description:"是否提供外呼 1:是 、0:否"`
 	TencentConferenceNumber string                     `description:"腾讯会议号"`
 	YidongActivityIdByCygx  string                     `description:"通过查研观向建会易董返回的活动ID"`
+	IsShowSigninButton      bool                       `description:"是否展示签到码按钮"`
+	SigninImg               string                     `description:"签到码图片"`
 }
 type ListArticleActivity struct {
 	Title   string `description:"文章标题"`

+ 88 - 0
models/activity_signin.go

@@ -0,0 +1,88 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySignin struct {
+	Id           int       `orm:"column(id);pk"`
+	ActivityId   int       `description:"活动ID"`
+	UserId       int       `description:"用户ID"`
+	CreateTime   time.Time `description:"创建时间"`
+	Mobile       string    `description:"手机号"`
+	Email        string    `description:"邮箱"`
+	CompanyId    int       `description:"公司id"`
+	CompanyName  string    `description:"公司名称"`
+	BusinessCard string    `description:"名片"`
+	RealName     string    `description:"用户实际名称"`
+	IsSignup     int       `description:"是否报名了"`
+	CountryCode  string    `description:"手机国家区号"`
+}
+
+type CygxActivitySigninLog struct {
+	Id           int       `orm:"column(id);pk"`
+	ActivityId   int       `description:"活动ID"`
+	UserId       int       `description:"用户ID"`
+	CreateTime   time.Time `description:"创建时间"`
+	Mobile       string    `description:"手机号"`
+	Email        string    `description:"邮箱"`
+	CompanyId    int       `description:"公司id"`
+	CompanyName  string    `description:"公司名称"`
+	BusinessCard string    `description:"名片"`
+	RealName     string    `description:"用户实际名称"`
+	IsSignup     int       `description:"是否报名了"`
+	CountryCode  string    `description:"手机国家区号"`
+}
+
+type CygxActivitySigninResp struct {
+	ActivityId   int    `description:"活动ID"`
+	ActivityName string `description:"活动名称"`
+	RealName     string `description:"用户实际名称"`
+	Mobile       string `description:"手机号"`
+	CompanyName  string `description:"公司名称"`
+	BusinessCard string `description:"名片"`
+	IsNewUser    bool   `description:"是否属于新客户"`
+	IsSignup     bool   `description:"是否报名了"`
+}
+
+type CygxActivitySigninDetailResp struct {
+	Detail          *CygxActivitySigninResp
+	IsBindingMobile bool `description:"是否绑定手机号"`
+}
+
+// 获取数量
+func GetCygxActivitySigninCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_signin as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 添加
+func AddCygxActivitySignin(item *CygxActivitySignin) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+// 添加日志
+func AddCygxActivitySigninLog(item *CygxActivitySigninLog) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+type CygxActivitySigninReq struct {
+	ActivityId   int    `description:"活动id"`
+	CountryCode  string `description:"手机国家区号"`
+	Mobile       string `description:"手机号"`
+	VCode        string `description:"验证码"`
+	CompanyName  string `description:"公司名称"`
+	BusinessCard string `description:"名片"`
+	RealName     string `description:"用户实际名称"`
+	SigninType   int    `description:"签到方式,1:填写手机号/机构名称;2:上传名片"`
+}

+ 2 - 0
models/db.go

@@ -141,6 +141,8 @@ func init() {
 		new(CygxReportMappingCygx),
 		new(CygxReportMappingGroup),
 		new(CygxAboutUsVideoHistory),
+		new(CygxActivitySignin),
+		new(CygxActivitySigninLog),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 18 - 0
routers/commentsRouter.go

@@ -232,6 +232,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"],
+        beego.ControllerComments{
+            Method: "ByHand",
+            Router: `/byHand`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/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",

+ 5 - 0
routers/router.go

@@ -149,6 +149,11 @@ func init() {
 				&controllers.MorningMeetingController{},
 			),
 		),
+		web.NSNamespace("/activity_signin",
+			web.NSInclude(
+				&controllers.ActivitySignCoAntroller{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 34 - 0
services/activity_signin.go

@@ -0,0 +1,34 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+// AddCygxActivitySigninLog 扫码签到日志记录
+func AddCygxActivitySigninLog(item *models.CygxActivitySignin) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("扫码签到日志记录,失败,活动ID:"+strconv.Itoa(item.ActivityId)+err.Error(), 2)
+		}
+	}()
+	//添加日志记录
+	itemLog := new(models.CygxActivitySigninLog)
+	itemLog.ActivityId = item.ActivityId
+	itemLog.UserId = item.UserId
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.RealName = item.RealName
+	itemLog.CompanyName = item.CompanyName
+	itemLog.IsSignup = item.IsSignup
+	itemLog.BusinessCard = item.BusinessCard
+	itemLog.CountryCode = item.CountryCode
+	itemLog.CreateTime = time.Now()
+	err = models.AddCygxActivitySigninLog(itemLog)
+	return
+}