|
@@ -302,7 +302,6 @@ func GetSpecialSurplusByCompany(companyId int) (specialSurplus string, err error
|
|
|
//mapPermissionName := make(map[int]string)
|
|
|
for _, v := range list {
|
|
|
chartPermissionIdSlice = append(chartPermissionIdSlice, strconv.Itoa(v.ChartPermissionId))
|
|
|
-
|
|
|
}
|
|
|
chartList, e := models.GetChartPermissionByIds(chartPermissionIdSlice)
|
|
|
if e != nil {
|
|
@@ -421,7 +420,7 @@ func CheckActivitySpecialUpdatePower(adminId int, activityInfo *cygx.ActivitySpe
|
|
|
}
|
|
|
|
|
|
// GetChartPermissionSpecialSurplusByCompany 获取公司专项调研次数-分品种
|
|
|
-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 := cygx.GetCompanyDetailByIdGroup(companyId)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetCompanyDetailByIdGroup, Err: " + e.Error())
|
|
@@ -438,6 +437,7 @@ 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}
|
|
|
//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}
|
|
|
if companyDetail.Status == "正式" {
|
|
|
//var packageType int
|
|
|
userType, _, _, _, _ = GetUserType(companyId)
|
|
@@ -455,6 +455,11 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ // 获取继承点数
|
|
|
+ inheritList, e := cygx.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
|
|
|
+ }
|
|
|
if userType == 2 {
|
|
|
//airborneList, e := cygx.GetActivitySpecialTripAirborneCountByActivitySpecial(condition, pars)
|
|
|
//if e != nil {
|
|
@@ -512,6 +517,7 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
}
|
|
|
var chartPermissionIdSlice []string
|
|
|
mapChartName = make(map[string]int)
|
|
|
+ mapInheritChartName := make(map[string]int)
|
|
|
mapPermissionNameTrip := make(map[string]int)
|
|
|
//mapPermissionName := make(map[int]string)
|
|
|
for _, v := range list {
|
|
@@ -523,9 +529,11 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
err = errors.New("获取品种信息失败, Err:" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if len(chartList) == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
+ // 10.9.1本身升级没有也可能通过继承获得
|
|
|
+ //if len(chartList) == 0 {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
//到会空降的也加入流水记录表,这里不在做单独计算 2023-07-10
|
|
|
//airborneList, e := cygx.GetCygxActivitySpecialTripAirborneListByComapnyId(companyId)
|
|
|
//if e != nil {
|
|
@@ -546,6 +554,16 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
for _, v := range chartList {
|
|
|
mapChartName[v.PermissionName] = 5 + mapPermissionNameTrip[v.ChartPermissionName]
|
|
|
}
|
|
|
+ for _, v := range inheritList {
|
|
|
+ mapInheritChartName[v.ChartPermissionName] = v.Points
|
|
|
+ }
|
|
|
+ for k, _ := range chartNameMap {
|
|
|
+ if _, ok := mapChartName[k]; ok {
|
|
|
+ if inherit, ok2 := mapInheritChartName[k]; ok2 {
|
|
|
+ mapChartName[k] += inherit
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for k, v := range mapChartName {
|
|
|
if v > 0 {
|
|
|
specialSurplus += k + strconv.Itoa(v) + "次+"
|
|
@@ -558,7 +576,7 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
}
|
|
|
|
|
|
// 审批通过的时候专项调研次数更新
|
|
|
-func ActivitySpecialCompanyApproval(companyId int,companyName string) (err error) {
|
|
|
+func ActivitySpecialCompanyApproval(companyId int, companyName string) (err error) {
|
|
|
userType, packageType, _, _, _ := GetUserType(companyId)
|
|
|
itemBill := new(cygx.CygxActivitySpecialTripBill)
|
|
|
itemBill.CreateTime = time.Now()
|
|
@@ -567,7 +585,7 @@ func ActivitySpecialCompanyApproval(companyId int,companyName string) (err error
|
|
|
itemBill.Source = 2
|
|
|
itemBill.DoType = 2
|
|
|
itemBill.Way = 3
|
|
|
- if userType == 2{
|
|
|
+ if userType == 2 {
|
|
|
packageTypeMap := map[int]int{1: 16, 2: 10}
|
|
|
totalTrip := packageTypeMap[packageType]
|
|
|
itemBill.BillDetailed = totalTrip
|
|
@@ -619,7 +637,6 @@ func ActivitySpecialCompanyApproval(companyId int,companyName string) (err error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 取消专项调研返点
|
|
|
func ActivitySpecialPublishAndCancel(activityInfo *cygx.ActivitySpecialDetail) (err error) {
|
|
|
//userType, tripRemaining, mapChartName, err := GetChartPermissionSpecialSurplusByCompany(companyId)
|
|
@@ -641,4 +658,33 @@ func ActivitySpecialPublishAndCancel(activityInfo *cygx.ActivitySpecialDetail) (
|
|
|
// return
|
|
|
//}
|
|
|
return
|
|
|
+}
|
|
|
+
|
|
|
+// GetSpecialSurplusByCompanyNew 获取公司专项调研剩余次数-用流水表数据不计算了,计算都丢在流水里
|
|
|
+func GetSpecialSurplusByCompanyNew(companyId int) (specialSurplus string, err error) {
|
|
|
+ companyDetail, e := cygx.GetCompanyDetailByIdGroup(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyDetailByIdGroup, Err: " + e.Error())
|
|
|
+ }
|
|
|
+ if companyDetail == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyDetail.Status != "永续" && companyDetail.Status != "正式" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyDetail.Status == "永续" {
|
|
|
+ specialSurplus = "不限次数"
|
|
|
+ }
|
|
|
+ //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}
|
|
|
+ if companyDetail.Status == "正式" {
|
|
|
+ billItem,e := cygx.GetCygxActivitySpecialTripBillByCompanyId(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ specialSurplus = billItem.Total
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|