|
@@ -174,6 +174,10 @@ func YanXuanActivityPointsBillReduce() (err error) {
|
|
|
go YanXuanCompanyCompanyTryOutReduce(log)
|
|
|
fmt.Println("7:正式专试用定时任务更新研选扣点。")
|
|
|
break
|
|
|
+ case 8:
|
|
|
+ go YanXuanActivityVivoPointsBillSignupReduce(log)
|
|
|
+ fmt.Println("8:播放研选扣点音视频。")
|
|
|
+ break
|
|
|
default:
|
|
|
fmt.Println(string(b))
|
|
|
go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+string(b), 2)
|
|
@@ -1092,3 +1096,76 @@ func YanXuanCompanyCompanyTryOutReduce(log models.YanXuanActivityPointsRedis) (e
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 8:用户观看音视频研选扣点处理
|
|
|
+func YanXuanActivityVivoPointsBillSignupReduce(log models.YanXuanActivityPointsRedis) (err error) {
|
|
|
+ //func YanXuanActivityPointsBillSubmitMeetingReduce(activityId int) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("用户观看音视频研选扣点处理,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("ActivityId", log.ActivityId, "UserId", log.UserId), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ activityId := log.ActivityId
|
|
|
+ userId := log.UserId
|
|
|
+ //获取活动是否扣点以及扣点规则明细
|
|
|
+ vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivityVivoPointsSetByActivityId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if vivoPointsSetDetail == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ activityInfo, e := models.GetAddActivityInfoByActivityId(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetAddActivityInfoByActivityId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ user, e := models.GetWxUserItemByUserId(userId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetWxUserItemByUserId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取用户所在公司剩余的点
|
|
|
+ companyPointsNum, e := models.GetCompanyPoints(user.CompanyId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取需要添加的流水信息
|
|
|
+ var items []*models.CygxActivityPointsBill
|
|
|
+ item := new(models.CygxActivityPointsBill)
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.BillDetailed = -vivoPointsSetDetail.PointsNum
|
|
|
+ item.RegisterPlatform = log.RegisterPlatform
|
|
|
+ item.AdminId = log.AdminId
|
|
|
+ item.Source = log.Source
|
|
|
+ item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.DoType = 1
|
|
|
+ item.Content = "查看活动回放"
|
|
|
+ item.Points = companyPointsNum - vivoPointsSetDetail.PointsNum
|
|
|
+ items = append(items, item)
|
|
|
+
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
+ itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = item.Points
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ err = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ return
|
|
|
+}
|