瀏覽代碼

Merge branch 'cygx_10.7' of http://8.136.199.33:3000/cxzhang/hongze_clpt into debug

xingzai 1 年之前
父節點
當前提交
ac60a242e8
共有 4 個文件被更改,包括 48 次插入30 次删除
  1. 2 0
      controllers/activity.go
  2. 12 0
      models/activity_points_set.go
  3. 31 28
      services/activity_points.go
  4. 3 2
      utils/constants.go

+ 2 - 0
controllers/activity.go

@@ -1088,6 +1088,7 @@ func (this *ActivityController) SignupAdd() {
 			if activityInfo.IsResearchPoints {
 				resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
 			}
+			go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
 		}
 
 	} else {
@@ -1232,6 +1233,7 @@ func (this *ActivityController) SignupCancel() {
 		br.ErrMsg = "操作失败,Err:" + errSignup.Error()
 		return
 	}
+	go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 12 - 0
models/activity_points_set.go

@@ -28,6 +28,18 @@ type CygxActivityPointsSetRsq struct {
 	CompanyPointsNum string `gorm:"column:company_points_num;default:0;NOT NULL" json:"CompanyPointsNum"` // 办会人扣点数量
 }
 
+type YanXuanActivityPointsRedis struct {
+	UserId           int       `description:"用户ID"`
+	ComapnyId        int       `description:"公司ID"`
+	ActivityId       int       `description:"活动ID"`
+	PublishStatus    int       `description:"发布状态 1已发布,0未发布"`
+	SourceType       int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
+	AdminId          int       `description:"管理员、销售ID"`
+	Source           int       `description:" 来源,1客户端,2后台添加, 3开发人员手动添加、4定时任务"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	CreateTime       time.Time `description:"创建时间"`
+}
+
 type CygxActivityPointsSetConfigListResp struct {
 	List []*CygxActivityPointsSetConfigResp
 }

+ 31 - 28
services/activity_points.go

@@ -1,49 +1,52 @@
 package services
 
 import (
-	"errors"
 	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
+	"time"
 )
 
 //func init() {
 //	GetActivityPointsAll()
 //}
 
-// GetActivityPointsAll 获取所有带有扣点的活动
-func GetActivityPointsAll() (listxActivity []*models.CygxActivity, err error) {
+// 用户报名添加到处理研选扣点
+func YanXuanActivityPointsBillSignupAdd(activityId, uid int) (err error) {
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg("获取所有带有扣点的活动失败"+err.Error(), 2)
+			msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
+			go utils.SendAlarmMsg("用户报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
 		}
 	}()
-	var condition string
-	var pars []interface{}
-	listxActivity = make([]*models.CygxActivity, 0)
-	list, e := models.GetCygxActivityPointsSetList(condition, pars, 0, 0)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("GetCygxActivityPointsSetList,Err: " + e.Error())
-		return
-	}
-	var activityIds []int
-	for _, v := range list {
-		activityIds = append(activityIds, v.ActivityId)
+	//SourceType int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
+	log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 1, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
+		if err != nil {
+			fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
+		}
 	}
-	lenArr := len(activityIds)
-	if lenArr == 0 {
-		return
+	return
+}
+
+// 用户取消报名添加到处理研选扣点
+func YanXuanActivityPointsBillSignupCancel(activityId, uid int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
+			go utils.SendAlarmMsg("用户取消报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	//SourceType int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
+	log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 2, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
+		if err != nil {
+			fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
+		}
 	}
-	//condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(lenArr) + `)`
-	//pars = append(pars, activityIds)
-	//listxActivity, e = models.GetCygxActivityList(condition, pars, 0, lenArr)
-	//if e != nil && e.Error() != utils.ErrNoRow() {
-	//	err = errors.New("GetCygxActivityList,Err: " + e.Error())
-	//	return
-	//}
-	//for _, v := range listxActivity {
-	//	fmt.Println(v)
-	//}
 	return
 }

+ 3 - 2
utils/constants.go

@@ -142,8 +142,9 @@ const (
 	YAN_XUAN_TAB_KEY = "yanxuan_header_tab"
 )
 const (
-	YD_TOKEN            = "yidong_token"
-	CYGX_USER_KEY_LABEL = "CYGX_USER_KEY_LABEL" //查研观向用户标签
+	YD_TOKEN                = "yidong_token"
+	CYGX_USER_KEY_LABEL     = "CYGX_USER_KEY_LABEL"     //查研观向用户标签
+	CYGX_YANXUAN_POINTS_KEY = "CYGX_YANXUAN_POINTS_KEY" //查研观向研选活动扣点KEY
 )
 
 // 邀请机构标识