|
@@ -15,6 +15,61 @@ import (
|
|
|
// UpdateCygxActivitySpecialSignupNum()
|
|
|
//}
|
|
|
|
|
|
+// ActivityLabelSpecialUserSql 专项产业调研用户权限查询数据预处理
|
|
|
+func ActivityLabelSpecialUserSql(user *models.WxUserItem) (conditionShengji, conditionZhengshi, conditionHangYe string, err error) {
|
|
|
+ _, userType, e := HandleActivityLabelSpecialTripPermission(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
|
|
|
+ permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if permissionShengji != "" {
|
|
|
+ slicePerShengji := strings.Split(permissionShengji, ",")
|
|
|
+ permissionShengji = ""
|
|
|
+ for _, v := range slicePerShengji {
|
|
|
+ permissionShengji += "'" + v + "',"
|
|
|
+ }
|
|
|
+ permissionShengji = strings.TrimRight(permissionShengji, ",")
|
|
|
+ conditionShengji = ` art.customer_type_ids LIKE '%8%' AND art.chart_permission_name IN (` + permissionShengji + `)`
|
|
|
+ }
|
|
|
+ //9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
|
|
|
+ permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if permissionZhengShiStr != "" {
|
|
|
+ slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
|
|
|
+ permissionZhengShiStr = ""
|
|
|
+ for _, v := range slicePerZhengshi {
|
|
|
+ if userType == 1 {
|
|
|
+ //研选权限处理(永续客户无法查看研选)
|
|
|
+ if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
|
|
|
+ permissionZhengShiStr += "'" + v + "',"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ permissionZhengShiStr += "'" + v + "',"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
|
|
|
+ permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
|
|
|
+ permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
|
|
|
+ permissionZhengShiStr += `, '宏观'`
|
|
|
+ if userType != 1 && userType != 2 && userType != 10 {
|
|
|
+ conditionHangYe = ` art.customer_type_ids LIKE '%3%' AND art.chart_permission_name IN (` + permissionZhengShiStr + `)`
|
|
|
+ }
|
|
|
+ if userType == 9 {
|
|
|
+ conditionZhengshi = ` art.customer_type_ids LIKE '%9%' AND art.chart_permission_name NOT IN (` + permissionZhengShiStr + `)`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// 修改专项调研,用户与公司的参与数量
|
|
|
func UpdateCygxActivitySpecialSignupNum(cont context.Context) (err error) {
|
|
|
defer func() {
|
|
@@ -96,14 +151,15 @@ func GetActivityLabelSpecialList(user *models.WxUserItem, isPower int, chartPerm
|
|
|
}
|
|
|
//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
|
|
|
var condition string
|
|
|
+ var conditionUser string
|
|
|
if companyDetail.Status == "永续" {
|
|
|
- condition, e = HandleActivityLabelSpecialPermission(user)
|
|
|
+ conditionUser, e = HandleActivityLabelSpecialPermission(user)
|
|
|
if e != nil {
|
|
|
err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
- condition, _, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
+ conditionUser, _, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
if e != nil {
|
|
|
err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
return
|
|
@@ -120,17 +176,72 @@ func GetActivityLabelSpecialList(user *models.WxUserItem, isPower int, chartPerm
|
|
|
condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `) `
|
|
|
}
|
|
|
conditionTrip := condition
|
|
|
- conditionTrip += ` AND art.activity_time_end > ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
|
|
|
- conditionTrip += ` AND art.days > 0 ORDER BY art.activity_time ASC `
|
|
|
- specialList, err := models.GetActivityLabelSpecialListAll(conditionTrip, pars, 0, 8)
|
|
|
- if err != nil {
|
|
|
+ conditionTripSql := condition
|
|
|
+ conditionNoTrip := condition
|
|
|
+ conditionNoTripSql := condition
|
|
|
+ //condition += conditionUser
|
|
|
+ conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- //if len(specialList) < 8 {
|
|
|
- // conditionTrip += ` AND art.days = 0 ORDER BY art.last_updated_time DESC`
|
|
|
+ conditionTrip += ` AND art.days > 0 AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + ` '`
|
|
|
+
|
|
|
+ var conditionZhengshiTrip string
|
|
|
+ var conditionShengjiTrip string
|
|
|
+ var conditionHangYeTrip string
|
|
|
|
|
|
- condition += ` AND art.days = 0 ORDER BY art.last_updated_time DESC`
|
|
|
- specialListNotrip, e := models.GetActivityLabelSpecialListAll(condition, pars, 0, 20)
|
|
|
+ //处理专项调研确认行程的其它正式客户权限查询
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionZhengshiTrip = ` OR ( ` + conditionZhengshi + conditionTrip + ` )`
|
|
|
+ }
|
|
|
+ //处理升级权限查询
|
|
|
+ if conditionShengji != "" {
|
|
|
+ conditionShengjiTrip = ` OR ( ` + conditionShengji + conditionTrip + ` )`
|
|
|
+ }
|
|
|
+ //处理行业套餐客户权限查询
|
|
|
+ if conditionHangYe != "" {
|
|
|
+ conditionHangYeTrip = ` OR ( ` + conditionHangYe + conditionTrip + ` )`
|
|
|
+ }
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionTrip += conditionZhengshiTrip
|
|
|
+ }
|
|
|
+ if conditionShengjiTrip != "" {
|
|
|
+ conditionTrip += conditionShengjiTrip
|
|
|
+ }
|
|
|
+ if conditionHangYeTrip != "" {
|
|
|
+ conditionTrip += conditionHangYeTrip
|
|
|
+ }
|
|
|
+
|
|
|
+ conditionTripSql += conditionUser + conditionTrip + ` ORDER BY art.activity_time ASC `
|
|
|
+ specialList, err := models.GetActivityLabelSpecialListAll(conditionTripSql, pars, 0, 80)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ conditionNoTrip += ` AND art.days = 0 `
|
|
|
+ var conditionShengjiNoTrip string
|
|
|
+ var conditionZhengshiNoTrip string
|
|
|
+ var conditionHangYeNoTrip string
|
|
|
+ if conditionShengji != "" {
|
|
|
+ conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
|
|
|
+ }
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionZhengshiNoTrip = ` OR ( ` + conditionZhengshi + conditionNoTrip + ` )`
|
|
|
+ }
|
|
|
+ if conditionHangYe != "" {
|
|
|
+ conditionHangYeNoTrip = ` OR ( ` + conditionHangYe + conditionNoTrip + ` )`
|
|
|
+ }
|
|
|
+ if conditionShengji != "" {
|
|
|
+ conditionNoTrip += conditionShengjiNoTrip
|
|
|
+ }
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionNoTrip += conditionZhengshiNoTrip
|
|
|
+ }
|
|
|
+ if conditionHangYe != "" {
|
|
|
+ conditionNoTrip += conditionHangYeNoTrip
|
|
|
+ }
|
|
|
+ conditionNoTripSql += conditionUser + conditionNoTrip + ` ORDER BY art.last_updated_time DESC`
|
|
|
+ specialListNotrip, e := models.GetActivityLabelSpecialListAll(conditionNoTripSql, pars, 0, 200)
|
|
|
if e != nil {
|
|
|
err = e
|
|
|
return
|
|
@@ -238,7 +349,6 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
|
|
|
//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
|
|
|
var condition string
|
|
|
var conditionUser string
|
|
|
- var userType int
|
|
|
if companyDetail.Status == "永续" {
|
|
|
conditionUser, e = HandleActivityLabelSpecialPermission(user)
|
|
|
if e != nil {
|
|
@@ -246,7 +356,7 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
- conditionUser, userType, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
+ conditionUser, _, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
if e != nil {
|
|
|
err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
return
|
|
@@ -260,32 +370,45 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
|
|
|
pars = append(pars, keywords)
|
|
|
}
|
|
|
|
|
|
- // 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
|
|
|
- permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
|
|
|
- if errs != nil {
|
|
|
- err = errs
|
|
|
+ conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- var conditionOr string
|
|
|
- if permissionShengji != "" && userType != 2 {
|
|
|
- slicePerShengji := strings.Split(permissionShengji, ",")
|
|
|
- permissionShengji = ""
|
|
|
- for _, v := range slicePerShengji {
|
|
|
- permissionShengji += "'" + v + "',"
|
|
|
- }
|
|
|
- permissionShengji = strings.TrimRight(permissionShengji, ",")
|
|
|
- conditionOr += ` OR ( art.customer_type_ids LIKE '%8%' AND art.chart_permission_name IN (` + permissionShengji + `)` + condition + `) `
|
|
|
- pars = append(pars, pars)
|
|
|
+ conditionNoTrip := condition
|
|
|
+ var conditionShengjiNoTrip string
|
|
|
+ var conditionZhengshiNoTrip string
|
|
|
+ var conditionHangYeNoTrip string
|
|
|
+ if conditionShengji != "" {
|
|
|
+ conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
|
|
|
}
|
|
|
- condition += conditionUser + conditionOr
|
|
|
- totalPrepare, e = models.GetActivitySpecialCount(condition, pars)
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionZhengshiNoTrip = ` OR ( ` + conditionZhengshi + conditionNoTrip + ` )`
|
|
|
+ }
|
|
|
+ //处理行业套餐权限查询
|
|
|
+ if conditionHangYe != "" {
|
|
|
+ conditionHangYeNoTrip = ` OR ( ` + conditionHangYe + conditionNoTrip + ` )`
|
|
|
+ }
|
|
|
+
|
|
|
+ if conditionShengji != "" {
|
|
|
+ conditionNoTrip += conditionShengjiNoTrip
|
|
|
+ }
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionNoTrip += conditionZhengshiNoTrip
|
|
|
+ }
|
|
|
+ if conditionHangYe != "" {
|
|
|
+ conditionNoTrip += conditionHangYeNoTrip
|
|
|
+ }
|
|
|
+ conditionNoTripSql := conditionUser + conditionNoTrip
|
|
|
+ //condition += conditionUser + conditionOr
|
|
|
+ totalPrepare, e = models.GetActivitySpecialCount(conditionNoTripSql, pars)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- condition += ` ORDER BY art.last_updated_time DESC `
|
|
|
- list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
|
|
|
+ //conditionNoTripSql += ` ORDER BY art.last_updated_time DESC `
|
|
|
+ list, e = models.GetCygxActivitySpecialDetailList(conditionNoTripSql, pars, user.UserId, startSize, pageSize)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
|
|
|
return
|
|
@@ -306,7 +429,7 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
|
|
|
//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
|
|
|
var condition string
|
|
|
var conditionUser string
|
|
|
- var userType int
|
|
|
+ //var userType int
|
|
|
if companyDetail.Status == "永续" {
|
|
|
conditionUser, e = HandleActivityLabelSpecialPermission(user)
|
|
|
if e != nil {
|
|
@@ -314,7 +437,7 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
- conditionUser, userType, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
+ conditionUser, _, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
if e != nil {
|
|
|
err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
return
|
|
@@ -324,78 +447,67 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
|
|
|
condition += ` AND art.days >0 AND art.publish_status =1 AND art.is_offline = 0 `
|
|
|
if state == 1 {
|
|
|
condition += ` AND art.activity_time > '` + time.Now().Format(utils.FormatDateTime) + `'`
|
|
|
- //pars = append(pars, time.Now())
|
|
|
}
|
|
|
if state == 2 {
|
|
|
condition += ` AND art.activity_time < '` + time.Now().Format(utils.FormatDateTime) + `'`
|
|
|
- //pars = append(pars, time.Now())
|
|
|
condition += ` AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + `'`
|
|
|
- //pars = append(pars, time.Now())
|
|
|
}
|
|
|
if state == 3 {
|
|
|
condition += ` AND art.activity_time_end < '` + time.Now().Format(utils.FormatDateTime) + `'`
|
|
|
- //pars = append(pars, time.Now())
|
|
|
}
|
|
|
if state == 4 {
|
|
|
condition += ` AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + `'`
|
|
|
- //pars = append(pars, time.Now())
|
|
|
}
|
|
|
if keywords != "" {
|
|
|
keywords = "%" + keywords + "%"
|
|
|
- condition += ` AND art.research_theme LIKE ? `
|
|
|
- pars = append(pars, keywords)
|
|
|
+ condition += ` AND art.research_theme LIKE ` + keywords
|
|
|
+ //pars = append(pars, keywords)
|
|
|
}
|
|
|
- // 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
|
|
|
- permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
|
|
|
- if errs != nil {
|
|
|
- err = errs
|
|
|
+ conditionTrip := condition
|
|
|
+ conditionTripSql := condition
|
|
|
+
|
|
|
+ conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- var conditionOr string
|
|
|
- if permissionShengji != "" {
|
|
|
- slicePerShengji := strings.Split(permissionShengji, ",")
|
|
|
- permissionShengji = ""
|
|
|
- for _, v := range slicePerShengji {
|
|
|
- permissionShengji += "'" + v + "',"
|
|
|
- }
|
|
|
- permissionShengji = strings.TrimRight(permissionShengji, ",")
|
|
|
- conditionOr += ` OR ( art.customer_type_ids LIKE '%8%' AND art.chart_permission_name IN (` + permissionShengji + `)` + condition + `) `
|
|
|
- //pars = append(pars, pars)
|
|
|
+ conditionTrip += ` AND art.days > 0 AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + ` '`
|
|
|
+
|
|
|
+ var conditionZhengshiTrip string
|
|
|
+ var conditionShengjiTrip string
|
|
|
+ var conditionHangYeTrip string
|
|
|
+
|
|
|
+ //处理专项调研确认行程的其它正式客户权限查询
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionZhengshiTrip = ` OR ( ` + conditionZhengshi + conditionTrip + ` )`
|
|
|
}
|
|
|
- //9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
|
|
|
- permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
|
|
|
- if errs != nil {
|
|
|
- err = errs
|
|
|
- return
|
|
|
+ //处理专项调研确认行程的升级权限查询
|
|
|
+ if conditionShengji != "" {
|
|
|
+ conditionShengjiTrip = ` OR ( ` + conditionShengji + conditionTrip + ` )`
|
|
|
}
|
|
|
- if permissionZhengShiStr != "" && userType == 9 {
|
|
|
- slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
|
|
|
- permissionZhengShiStr = ""
|
|
|
- for _, v := range slicePerZhengshi {
|
|
|
- if userType == 1 {
|
|
|
- //研选权限处理(永续客户无法查看研选)
|
|
|
- if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
|
|
|
- permissionZhengShiStr += "'" + v + "',"
|
|
|
- }
|
|
|
- } else {
|
|
|
- permissionZhengShiStr += "'" + v + "',"
|
|
|
- }
|
|
|
- }
|
|
|
- permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
|
|
|
- permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
|
|
|
- permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
|
|
|
- conditionOr += ` OR ( art.customer_type_ids LIKE '%9%' AND art.chart_permission_name NOT IN (` + permissionZhengShiStr + `)` + condition + `) `
|
|
|
- //pars = append(pars, pars)
|
|
|
+ //处理行业套餐客户权限查询
|
|
|
+ if conditionHangYe != "" {
|
|
|
+ conditionHangYeTrip = ` OR ( ` + conditionHangYe + conditionTrip + ` )`
|
|
|
+ }
|
|
|
+
|
|
|
+ if conditionZhengshi != "" {
|
|
|
+ conditionTrip += conditionZhengshiTrip
|
|
|
+ }
|
|
|
+ if conditionShengjiTrip != "" {
|
|
|
+ conditionTrip += conditionShengjiTrip
|
|
|
}
|
|
|
+ if conditionHangYeTrip != "" {
|
|
|
+ conditionTrip += conditionHangYeTrip
|
|
|
+ }
|
|
|
+ conditionTripSql += conditionUser + conditionTrip + ` ORDER BY art.activity_time ASC `
|
|
|
|
|
|
- condition += conditionUser + conditionOr
|
|
|
- totalConfirm, e = models.GetActivitySpecialCount(condition, pars)
|
|
|
+ totalConfirm, e = models.GetActivitySpecialCount(conditionTripSql, pars)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
condition += ` ORDER BY art.activity_time ASC `
|
|
|
- list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
|
|
|
+ list, e = models.GetCygxActivitySpecialDetailList(conditionTripSql, pars, user.UserId, startSize, pageSize)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
|
|
|
return
|
|
@@ -800,18 +912,10 @@ func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.Cyg
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
|
|
|
- permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
|
|
|
- if errs != nil {
|
|
|
- err = errs
|
|
|
+ if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
|
|
|
+ havePower = true
|
|
|
return
|
|
|
}
|
|
|
- if permissionShengji != "" {
|
|
|
- if strings.Contains(permissionShengji, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
|
|
|
- havePower = true
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
return
|
|
|
}
|
|
|
|