|
@@ -1257,7 +1257,7 @@ func SendWxMsgActivitySpecialCancel(cont context.Context) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tripRemaining int,mapChartName map[string]int, err error) {
|
|
|
|
|
|
+func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tripRemaining int, mapChartName map[string]int, err error) {
|
|
companyDetail, e := models.GetCompanyDetailByIdGroup(companyId)
|
|
companyDetail, e := models.GetCompanyDetailByIdGroup(companyId)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = errors.New("GetCompanyDetailByIdGroup, Err: " + e.Error())
|
|
err = errors.New("GetCompanyDetailByIdGroup, Err: " + e.Error())
|
|
@@ -1275,7 +1275,6 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
//chartMap := map[int]string{utils.YI_YAO_ID:utils.YI_YAO_NAME, utils.XIAO_FEI_ID:utils.XIAO_FEI_NAME, utils.KE_JI_ID:utils.KE_JI_NAME, utils.ZHI_ZAO_ID:utils.ZHI_ZAO_NAME}
|
|
//chartMap := map[int]string{utils.YI_YAO_ID:utils.YI_YAO_NAME, utils.XIAO_FEI_ID:utils.XIAO_FEI_NAME, utils.KE_JI_ID:utils.KE_JI_NAME, utils.ZHI_ZAO_ID:utils.ZHI_ZAO_NAME}
|
|
//chartNumMap := map[int]int{utils.YI_YAO_ID:0, utils.XIAO_FEI_ID:0, utils.KE_JI_ID:0, utils.ZHI_ZAO_ID:0}
|
|
//chartNumMap := map[int]int{utils.YI_YAO_ID:0, utils.XIAO_FEI_ID:0, utils.KE_JI_ID:0, utils.ZHI_ZAO_ID:0}
|
|
chartNameMap := map[string]int{utils.YI_YAO_NAME: 0, utils.XIAO_FEI_NAME: 0, utils.KE_JI_NAME: 0, utils.ZHI_ZAO_NAME: 0}
|
|
chartNameMap := map[string]int{utils.YI_YAO_NAME: 0, utils.XIAO_FEI_NAME: 0, utils.KE_JI_NAME: 0, utils.ZHI_ZAO_NAME: 0}
|
|
-
|
|
|
|
if companyDetail.Status == "正式" {
|
|
if companyDetail.Status == "正式" {
|
|
//var packageType int
|
|
//var packageType int
|
|
userType, _, _ = GetUserType(companyId)
|
|
userType, _, _ = GetUserType(companyId)
|
|
@@ -1299,92 +1298,61 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
|
|
err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
|
|
}
|
|
}
|
|
if userType == 2 {
|
|
if userType == 2 {
|
|
- //airborneList, e := cygx.GetActivitySpecialTripAirborneCountByActivitySpecial(condition, pars)
|
|
|
|
- //if e != nil {
|
|
|
|
- // err = errors.New("GetActivitySpecialTripAirborneCountByActivitySpecial, Err: " + e.Error())
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
- //ariborneMap := make(map[int]int)
|
|
|
|
- //for _, v := range airborneList {
|
|
|
|
- // ariborneMap[v.ChartPermissionId] = v.Count
|
|
|
|
- //}
|
|
|
|
- //到会空降的也加入流水记录表,这里不在做单独计算 2023-07-10
|
|
|
|
- //airborneTotal, e := cygx.GetActivitySpecialTripAirborneCountByActivitySpecial(condition, pars)
|
|
|
|
- //if e != nil {
|
|
|
|
- // err = errors.New("GetActivitySpecialTripAirborneCountByActivitySpecial, Err: " + e.Error())
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
- //condition += ` AND is_valid = 1 `
|
|
|
|
- //TripBillNumMap := make(map[int]int)
|
|
|
|
- //for _, v := range listTripBill {
|
|
|
|
- // TripBillNumMap[v.ChartPermissionId] += v.BillDetailed
|
|
|
|
- //}
|
|
|
|
- var TripBillNum int
|
|
|
|
|
|
+
|
|
|
|
+ var tripBillNum int
|
|
for _, v := range listTripBill {
|
|
for _, v := range listTripBill {
|
|
//if v.ActivityId == 0 {
|
|
//if v.ActivityId == 0 {
|
|
// continue
|
|
// continue
|
|
//}
|
|
//}
|
|
- TripBillNum += v.BillDetailed
|
|
|
|
|
|
+ tripBillNum += v.BillDetailed
|
|
|
|
+ }
|
|
|
|
+ if len(inheritList) > 0 {
|
|
|
|
+ for _, v := range inheritList {
|
|
|
|
+ if v.ChartPermissionId == 0 {
|
|
|
|
+ tripBillNum += v.Points
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // CRM13.2 70w客户有16次专项调研, 45w有10次
|
|
|
|
- //packageTypeMap := map[int]int{1: 16, 2: 10}
|
|
|
|
- //totalTrip := packageTypeMap[packageType]
|
|
|
|
|
|
|
|
- tripRemaining = TripBillNum
|
|
|
|
|
|
+ tripRemaining = tripBillNum
|
|
if tripRemaining < 0 {
|
|
if tripRemaining < 0 {
|
|
tripRemaining = 0
|
|
tripRemaining = 0
|
|
}
|
|
}
|
|
|
|
|
|
- //for k, _ := range chartNumMap {
|
|
|
|
- // tripRemaining := totalTrip - ariborneMap[k] + TripBillNumMap[k]
|
|
|
|
- // if tripRemaining < 0 {
|
|
|
|
- // tripRemaining = 0
|
|
|
|
- // }
|
|
|
|
- // specialSurplus += chartMap[k] + strconv.Itoa(tripRemaining) + "次,"
|
|
|
|
- //}
|
|
|
|
- //specialSurplus = strings.TrimRight(specialSurplus, ",")
|
|
|
|
-
|
|
|
|
- //tripRemaining = 12 - tripTota
|
|
|
|
} else {
|
|
} else {
|
|
- list, e := models.GetCompanyReportPermissionUpgrade(companyId, 2)
|
|
|
|
|
|
+ list, e := models.GetCompanyReportPermissionByCompanyIdAndProductId(companyId, 2)
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
|
|
err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
|
|
}
|
|
}
|
|
- // 10.9.1本身升级没有也可能通过继承获得
|
|
|
|
- //if len(list) == 0 {
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
|
|
+ if len(list) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
var chartPermissionIdSlice []string
|
|
var chartPermissionIdSlice []string
|
|
mapChartName = make(map[string]int)
|
|
mapChartName = make(map[string]int)
|
|
- mapInheritChartName := make(map[string]int)
|
|
|
|
|
|
+ mapUpgradeId := make(map[int]int)
|
|
mapPermissionNameTrip := make(map[string]int)
|
|
mapPermissionNameTrip := make(map[string]int)
|
|
-
|
|
|
|
|
|
+ mapInheritChartName := make(map[string]int)
|
|
//mapPermissionName := make(map[int]string)
|
|
//mapPermissionName := make(map[int]string)
|
|
for _, v := range list {
|
|
for _, v := range list {
|
|
chartPermissionIdSlice = append(chartPermissionIdSlice, strconv.Itoa(v.ChartPermissionId))
|
|
chartPermissionIdSlice = append(chartPermissionIdSlice, strconv.Itoa(v.ChartPermissionId))
|
|
-
|
|
|
|
|
|
+ //是升级套餐才有点数
|
|
|
|
+ if v.IsUpgrade == 1 {
|
|
|
|
+ mapUpgradeId[v.ChartPermissionId] = 1
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- chartList, e := models.GetChartPermissionByIds(chartPermissionIdSlice)
|
|
|
|
- if e != nil {
|
|
|
|
- err = errors.New("获取品种信息失败, Err:" + e.Error())
|
|
|
|
- return
|
|
|
|
|
|
+ chartList := make([]*models.ChartPermission, 0)
|
|
|
|
+ if len(chartPermissionIdSlice) > 0 {
|
|
|
|
+ chartList, e = models.GetChartPermissionByIds(chartPermissionIdSlice)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = errors.New("获取品种信息失败, Err:" + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // 10.9.1本身升级没有也可能通过继承获得
|
|
|
|
- //if len(chartList) == 0 {
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
|
|
|
|
- //到会空降的也加入流水记录表,这里不在做单独计算 2023-07-10
|
|
|
|
- //airborneList, e := cygx.GetCygxActivitySpecialTripAirborneListByComapnyId(companyId)
|
|
|
|
- //if e != nil {
|
|
|
|
- // err = errors.New("获取品种信息失败, Err:" + e.Error())
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
- //for _, v := range airborneList {
|
|
|
|
- // mapPermissionNameTrip[v.ChartPermissionName] += 1
|
|
|
|
- //}
|
|
|
|
|
|
+ if len(chartList) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
- //var TripBillNum int
|
|
|
|
for _, v := range listTripBill {
|
|
for _, v := range listTripBill {
|
|
if v.ActivityId == 0 {
|
|
if v.ActivityId == 0 {
|
|
continue
|
|
continue
|
|
@@ -1392,8 +1360,14 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
mapPermissionNameTrip[v.ChartPermissionName] += v.BillDetailed
|
|
mapPermissionNameTrip[v.ChartPermissionName] += v.BillDetailed
|
|
}
|
|
}
|
|
for _, v := range chartList {
|
|
for _, v := range chartList {
|
|
- mapChartName[v.PermissionName] = 5 + mapPermissionNameTrip[v.PermissionName]
|
|
|
|
|
|
+ //如果是升级则加点
|
|
|
|
+ if _, ok := mapUpgradeId[v.ChartPermissionId]; ok {
|
|
|
|
+ mapChartName[v.PermissionName] = 5 + mapPermissionNameTrip[v.PermissionName]
|
|
|
|
+ } else {
|
|
|
|
+ mapChartName[v.PermissionName] = mapPermissionNameTrip[v.PermissionName]
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ // 通过继承获得的加点
|
|
for _, v := range inheritList {
|
|
for _, v := range inheritList {
|
|
mapInheritChartName[v.ChartPermissionName] = v.Points
|
|
mapInheritChartName[v.ChartPermissionName] = v.Points
|
|
}
|
|
}
|
|
@@ -1404,6 +1378,7 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
for k, v := range mapChartName {
|
|
for k, v := range mapChartName {
|
|
if v > 0 {
|
|
if v > 0 {
|
|
specialSurplus += k + strconv.Itoa(v) + "次+"
|
|
specialSurplus += k + strconv.Itoa(v) + "次+"
|