Просмотр исходного кода

Merge remote-tracking branch 'origin/debug' into debug

ziwen 1 год назад
Родитель
Сommit
9a5d7c61a8
3 измененных файлов с 109 добавлено и 70 удалено
  1. 27 58
      controllers/activity.go
  2. 81 11
      services/activity_points.go
  3. 1 1
      services/user_label.go

+ 27 - 58
controllers/activity.go

@@ -3853,7 +3853,6 @@ func (this *ActivityCoAntroller) OverActivityList() {
 	isPower, _ := this.GetInt("IsPower")
 	chartPermissionIds := this.GetString("ChartPermissionIds")
 	whichDay := this.GetString("WhichDay")
-	fmt.Println("whichDay:", whichDay)
 	typeName := this.GetString("TypeName")
 
 	//入参为 undefined 时的处理
@@ -3872,54 +3871,13 @@ func (this *ActivityCoAntroller) OverActivityList() {
 		br.Data = resp
 		return
 	}
-	userType, permissionStr, err := services.GetUserType(user.CompanyId)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	//var startSize, pageSize int
-	//pageSize = 24
 	var condition string
+	var conditionSpecialinit string
 	var conditionSpecial string
 	var sortTime string
-	//var conditionStatus string
 	var pars []interface{}
-	//活动可见限制
-	var sqlExport string
-
-	slicePer := strings.Split(permissionStr, ",")
-	var permissionSqlStr string
-	for _, v := range slicePer {
-		if userType == 1 {
-			//if v != "研选" {
-			if !strings.Contains(v, "研选") {
-				permissionSqlStr += "'" + v + "',"
-			}
-		} else {
-			permissionSqlStr += "'" + v + "',"
-		}
-	}
-	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
-	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
-	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
-	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
-	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
-	if userType == 2 {
-		sqlExport += ` OR  art.customer_type_ids LIKE '%3%' `
-	}
-	if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
-		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
-	}
-	sqlExport += `) `
-
 	//已结束的活动
-	var conditionOr string
-	conditionOr = ""
 	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.active_state = 3 `
-	if isPower == 1 {
-		condition += permissionSqlStr + sqlExport + conditionOr
-	}
 	if whichDay != "" {
 		var startDate string
 		var endDate string
@@ -3948,23 +3906,31 @@ func (this *ActivityCoAntroller) OverActivityList() {
 		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
 		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
 
-		conditionSpecial += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
-		conditionSpecial += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+		conditionSpecialinit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		conditionSpecialinit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
 
 	}
 	if len(chartPermissionIds) > 0 {
 		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
 	}
 
-	conditionActivity, err := services.GetActivityonditionList(user, typeName, chartPermissionIds, whichDay, "3", "", 0, 0, "", 0, 1)
+	// 如果是C类电话会就不展示内容,且合并到分析师电话会
+	if typeName == "1" || typeName == "2" {
+		if typeName == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
+			condition += ` AND art.publish_status = 1  AND art.label != ''  AND art.activity_type_id IN (` + typeName + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
+		} else {
+			condition += ` AND art.publish_status = 1  AND art.label != ''  AND art.activity_type_id IN (` + typeName + `)`
+		}
+		conditionSpecialinit += ` AND  art.activity_id = 0 `
+	}
+
+	conditionActivity, err := services.ActivityConditioninitSql(user, condition, isPower)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
 		return
 	}
-	//已结束的活动
 	sortTime = ` activity_time DESC `
-
 	//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
 
 	companyDetail, err := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
@@ -3986,7 +3952,7 @@ func (this *ActivityCoAntroller) OverActivityList() {
 	conditionSpecial += ` AND art.days >0  AND art.publish_status =1   AND art.is_offline = 0  `
 	conditionSpecial += ` AND art.activity_time_end <  ` + "'" + time.Now().Format(utils.FormatDateTime) + "'"
 	condition += conditionActivity
-	list, err := models.GetActivityLabelListAllNoLimit(condition, sortTime, pars, conditionSpecial)
+	list, err := models.GetActivityLabelListAllNoLimit(condition, sortTime, pars, conditionSpecialinit+conditionSpecial)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -4006,16 +3972,19 @@ func (this *ActivityCoAntroller) OverActivityList() {
 		resp.List = append(resp.List, v)
 		mapKeyWord[keyWord] = keyWord
 	}
+	if len(list) == 0 {
+		resp.List = make([]*models.CygxActivityLabelList, 0)
+	}
 	//添加更多主题访问记录
-	item := new(models.CygxPageHistoryRecord)
-	item.UserId = user.UserId
-	item.CreateTime = time.Now()
-	item.Mobile = user.Mobile
-	item.Email = user.Email
-	item.CompanyId = user.CompanyId
-	item.CompanyName = user.CompanyName
-	item.PageType = "OverActivity"
-	go models.AddCygxPageHistoryRecord(item)
+	//item := new(models.CygxPageHistoryRecord)
+	//item.UserId = user.UserId
+	//item.CreateTime = time.Now()
+	//item.Mobile = user.Mobile
+	//item.Email = user.Email
+	//item.CompanyId = user.CompanyId
+	//item.CompanyName = user.CompanyName
+	//item.PageType = "OverActivity"
+	//go models.AddCygxPageHistoryRecord(item)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 81 - 11
services/activity_points.go

@@ -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())

+ 1 - 1
services/user_label.go

@@ -556,7 +556,7 @@ func CategoryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err erro
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg("用户关注系列更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
+			go utils.SendAlarmMsg("用户关注系列更新相关标签,处理Redis队列消息失败:"+err.Error()+fmt.Sprint(log), 2)
 		}
 	}()
 	isFllow := log.IsFllow