|
@@ -189,7 +189,8 @@ func YanXuanActivityPointsBillSignupAddReduce(log models.YanXuanActivityPointsRe
|
|
|
go utils.SendAlarmMsg("用户报名活动扣点,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("ActivityId", log.ActivityId, "userId", log.UserId), 2)
|
|
|
}
|
|
|
}()
|
|
|
-
|
|
|
+ //加500毫秒的延迟
|
|
|
+ time.Sleep(500 * time.Millisecond)
|
|
|
activityId := log.ActivityId
|
|
|
userId := log.UserId
|
|
|
|
|
@@ -478,8 +479,9 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
if activityPointsSetDetail == nil {
|
|
|
return
|
|
|
}
|
|
|
- if activityPointsSetDetail.CompanyPointsNum == 0 {
|
|
|
- return // 如果不是办会人,即扣点的这种形式,那么就不做任何处理
|
|
|
+ if activityPointsSetDetail.CompanyPointsNum == 0 && activityPointsSetDetail.PointsType == 2 {
|
|
|
+ //if activityPointsSetDetail.CompanyPointsNum == 0 {
|
|
|
+ return // 如果不是办会人扣点,且对用户是到会扣点的这种形式,那么就不做任何处理
|
|
|
}
|
|
|
|
|
|
activityInfo, e := models.GetAddActivityInfoByActivityId(activityId)
|
|
@@ -492,7 +494,7 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
var items []*models.CygxActivityPointsBill
|
|
|
|
|
|
var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
-
|
|
|
+ mapCompanyPoints := make(map[int]float64) //一组公司的剩余点数
|
|
|
if publishStatus == 1 {
|
|
|
fmt.Println("//活动发布")
|
|
|
if comapnyId > 0 {
|
|
@@ -531,11 +533,79 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
itemCompany.Points = item.Points
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ mapCompanyPoints[comapnyId] = item.Points
|
|
|
}
|
|
|
+
|
|
|
+ if activityPointsSetDetail.UserPointsNum > 0 && activityPointsSetDetail.PointsType == 1 {
|
|
|
+ //如果扣点形式选的是报名即扣点,那么就对已经报名的用户所在机构进行扣点
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND do_fail_type = 0 AND activity_id = ?`
|
|
|
+ pars = append(pars, activityId)
|
|
|
+
|
|
|
+ listSignup, e := models.GetActivitySignupList(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetActivitySignupList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ if len(listSignup) > 0 {
|
|
|
+ for _, v := range listSignup {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
|
|
|
+ pars = append(pars, companyIds)
|
|
|
+
|
|
|
+ //获取这些公司剩余的点数
|
|
|
+ conpanyList, e := models.GetCygxActivityPointsCompanyList(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivityPointsCompanyList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range conpanyList {
|
|
|
+ if mapCompanyPoints[v.CompanyId] == 0 {
|
|
|
+ mapCompanyPoints[v.CompanyId] = v.Points
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, user := range listSignup {
|
|
|
+ item := new(models.CygxActivityPointsBill)
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.BillDetailed = -activityPointsSetDetail.UserPointsNum
|
|
|
+ item.RegisterPlatform = log.RegisterPlatform
|
|
|
+ item.AdminId = log.AdminId
|
|
|
+ item.Source = log.Source
|
|
|
+ item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.DoType = 1
|
|
|
+ item.Content = activityInfo.ActivityName + "--发布活动"
|
|
|
+ mapCompanyPoints[user.CompanyId] -= activityPointsSetDetail.UserPointsNum //通过map处理机构剩余点数
|
|
|
+ item.Points = mapCompanyPoints[user.CompanyId]
|
|
|
+ items = append(items, item)
|
|
|
+
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = item.Points
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
fmt.Println("//活动取消发布")
|
|
|
//活动取消发布
|
|
|
- mapCompanyPoints := make(map[int]float64) //一组公司的剩余点数
|
|
|
+
|
|
|
if comapnyId > 0 {
|
|
|
comapny, e := models.GetCompanyById(comapnyId)
|
|
|
if e != nil {
|
|
@@ -603,8 +673,8 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
}
|
|
|
|
|
|
for _, v := range conpanyList {
|
|
|
- if mapCompanyPoints[comapnyId] != 0 {
|
|
|
- mapCompanyPoints[comapnyId] = v.Points
|
|
|
+ if mapCompanyPoints[v.CompanyId] == 0 {
|
|
|
+ mapCompanyPoints[v.CompanyId] = v.Points
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -613,6 +683,7 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
|
item.Mobile = user.Mobile
|
|
|
+ item.UserId = user.UserId
|
|
|
item.Email = user.Email
|
|
|
item.CompanyId = user.CompanyId
|
|
|
item.CompanyName = user.CompanyName
|
|
@@ -624,8 +695,8 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
item.DoType = 2
|
|
|
item.Content = activityInfo.ActivityName + "--取消活动"
|
|
|
- mapCompanyPoints[comapnyId] += activityPointsSetDetail.UserPointsNum //通过map处理机构剩余点数
|
|
|
- item.Points = mapCompanyPoints[comapnyId]
|
|
|
+ mapCompanyPoints[user.CompanyId] += activityPointsSetDetail.UserPointsNum //通过map处理机构剩余点数
|
|
|
+ item.Points = mapCompanyPoints[user.CompanyId]
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
@@ -634,12 +705,11 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
itemCompany.Points = item.Points
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- mapCompanyPoints[comapnyId] = item.Points
|
|
|
+ mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
e = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
err = errors.New("AddCygxActivityPointsBillMulti, Err: " + e.Error())
|