xingzai 1 yıl önce
ebeveyn
işleme
d67b814c94

+ 4 - 1
controllers/activity_sign.go

@@ -125,7 +125,7 @@ func (this *ActivitySignCoAntroller) Detail() {
 		services.AddCygxActivityOfflineMeetingDetail(activityId, user)
 
 		//后期扫码签到,处理是否爽约限制
-		services.CygxActivityRestrictSignupByuid(user.UserId)
+		services.CygxActivityRestrictSignupByuid(user.UserId, activityId)
 	}
 
 	if user.Mobile != "" || total > 0 {
@@ -320,6 +320,9 @@ func (this *ActivitySignCoAntroller) ByHand() {
 	if user.CompanyId <= 1 {
 		detail.IsNewUser = true
 	}
+	if user.UserId == 0 {
+		detail.IsNewUser = true
+	}
 	detail.ActivityId = activityId
 	detail.ActivityName = activityInfo.ActivityName
 	detail.Mobile = Mobile

+ 5 - 1
models/activity_signup.go

@@ -515,13 +515,17 @@ type CygxActivitySignupList struct {
 	IsMeeting   int    `description:"是否到会 ,1是, 0否"`
 	Operation   bool   `description:"操作按钮,true,到会,false 未到会"`
 	Channel     int    `description:"报名渠道,0 空降、 1小程序报名"`
+	SellerName  string `description:"所属销售"`
+	Mobile      string `description:"手机号"`
+	Email       string `description:"邮箱"`
+	CompanyId   int    `description:"公司id"`
 }
 
 // 获取用户报名列表
 func GetActivitySignupNomeetingCountList(activityId int) (items []*CygxActivitySignupList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-	s.user_id
+	s.*
 FROM
 	cygx_activity_signup AS s
 	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 

+ 53 - 0
models/activity_signup_break.go

@@ -0,0 +1,53 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySignupBreak 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:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+// 添加爽约记录
+func AddCygxActivitySignupBreak(item *CygxActivitySignupBreak) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 批量添加
+func AddCygxActivitySignupBreakList(items []*CygxActivitySignupBreak) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}
+
+// 删除
+func DeleteCygxActivitySignupBreak(uid, activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_activity_signup_break  WHERE user_id=? AND activity_id =? `
+	_, err = o.Raw(sql, uid, activityId).Exec()
+	return
+}
+
+// 删除
+func DeleteCygxActivitySignupBreakById(activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_activity_signup_break  WHERE  activity_id =? `
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}

+ 1 - 0
models/db.go

@@ -144,6 +144,7 @@ func init() {
 		new(CygxReportMappingCygx),
 		new(CygxReportMappingGroup),
 		new(CygxAboutUsVideoHistory),
+		new(CygxActivitySignupBreak),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 25 - 0
services/activity.go

@@ -1450,6 +1450,7 @@ func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
 		err = errors.New("GetActivitySignupNomeetingCountList" + err.Error())
 		return err
 	}
+	var items []*models.CygxActivitySignupBreak
 	for _, v := range list {
 		totalRestrict, err := models.GetRestrictSignupCountByUid(v.UserId)
 		if err != nil {
@@ -1486,6 +1487,30 @@ func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
 				}
 			}
 		}
+
+		//处理未到会
+		item := new(models.CygxActivitySignupBreak)
+		item.UserId = v.UserId
+		item.ActivityId = v.ActivityId
+		item.CreateTime = time.Now()
+		item.Mobile = v.Mobile
+		item.Email = v.Email
+		item.CompanyId = v.CompanyId
+		item.CompanyName = v.CompanyName
+		item.RealName = v.RealName
+		item.SellerName = v.SellerName
+		items = append(items, item)
+	}
+
+	err = models.DeleteCygxActivitySignupBreakById(activityId)
+	if err != nil {
+		err = errors.New("DeleteCygxActivitySignupBreakById" + err.Error())
+		return
+	}
+	_, err = models.AddCygxActivitySignupBreakList(items)
+	if err != nil {
+		err = errors.New("AddCygxActivitySignupBreakList, Err: " + err.Error())
+		return
 	}
 	return
 }

+ 13 - 7
services/activity_signin.go

@@ -98,12 +98,12 @@ func AddCygxActivityOfflineMeetingDetail(activityid int, user *models.WxUserItem
 		return
 	}
 
-	////修改活动是否提交到会状态
-	//err = models.UpdateCygxActivitySubmitMeetingByActivityId(activityid)
-	//if err != nil {
-	//	err = errors.New("UpdateCygxActivitySubmitMeetingByActivityId, Err: " + err.Error())
-	//	return
-	//}
+	//修改活动是否提交到会状态
+	err = models.UpdateCygxActivitySubmitMeetingByActivityId(activityid)
+	if err != nil {
+		err = errors.New("UpdateCygxActivitySubmitMeetingByActivityId, Err: " + err.Error())
+		return
+	}
 
 	//修改签到时间
 	err = models.UpdateCygxActivityOfflineMeetingDetailSigninTime(activityid, user.UserId)
@@ -153,13 +153,19 @@ func CygxActivityRestrictSignupByTask(cont context.Context) (err error) {
 	return
 }
 
-func CygxActivityRestrictSignupByuid(uid int) (err error) {
+func CygxActivityRestrictSignupByuid(uid, activityId int) (err error) {
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
 			go utils.SendAlarmMsg("判断是否加入黑名单记录失败"+err.Error(), 2)
 		}
 	}()
+
+	err = models.DeleteCygxActivitySignupBreak(uid, activityId)
+	if err != nil {
+		err = errors.New("DeleteCygxActivitySignupBreak" + err.Error())
+		return err
+	}
 	totalNomeet, err := models.GetActivitySignupNomeetingCountByUid(uid)
 	if err != nil {
 		err = errors.New("GetActivitySignupNomeetingCountByUid" + err.Error())

+ 47 - 0
services/init_10.4.go

@@ -0,0 +1,47 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"time"
+)
+
+func init213() {
+	var condition string
+	var pars []interface{}
+	var err error
+	condition += `AND do_fail_type = 0 AND  is_meeting = 0`
+	listSignup, err := models.GetActivitySignuListByUser(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxActivitySignupBreak
+	var numk int
+	for _, v := range listSignup {
+		numk++
+		item := new(models.CygxActivitySignupBreak)
+		item.UserId = v.UserId
+		item.ActivityId = v.ActivityId
+		item.CreateTime = time.Now()
+		item.Mobile = v.Mobile
+		item.Email = v.Email
+		item.CompanyId = v.CompanyId
+		item.CompanyName = v.CompanyName
+		item.RealName = v.RealName
+		item.SellerName = v.SellerName
+		items = append(items, item)
+		if numk%5000 == 0 {
+			fmt.Println(v)
+			_, err = models.AddCygxActivitySignupBreakList(items)
+			if err != nil {
+				fmt.Println(err)
+			}
+			items = make([]*models.CygxActivitySignupBreak, 0)
+			numk = 0
+		}
+	}
+	if len(items) > 0 {
+		_, err = models.AddCygxActivitySignupBreakList(items)
+	}
+	fmt.Println(len(listSignup))
+}