|
@@ -539,15 +539,19 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+//func init() {
|
|
|
+// ActivitySpecialCompanyApproval(7012, 1213, "10.11添加客户升级")
|
|
|
+//}
|
|
|
+
|
|
|
// 审批通过的时候专项调研次数更新
|
|
|
-func ActivitySpecialCompanyApproval(companyId int, companyName string) (err error) {
|
|
|
+func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyName string) (err error) {
|
|
|
userType, packageType, _, _, _ := GetUserType(companyId)
|
|
|
// 获取继承点数
|
|
|
- inheritList, e := cygx.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
|
|
|
- }
|
|
|
- chartNameMap := map[string]int{utils.YI_YAO_NAME: 0, utils.XIAO_FEI_NAME: 0, utils.KE_JI_NAME: 0, utils.ZHI_ZAO_NAME: 0}
|
|
|
+ //inheritList, e := cygx.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
|
|
|
+ //if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ // err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
|
|
|
+ //}
|
|
|
+ //chartNameMap := map[string]int{utils.YI_YAO_NAME: 0, utils.XIAO_FEI_NAME: 0, utils.KE_JI_NAME: 0, utils.ZHI_ZAO_NAME: 0}
|
|
|
var items []*cygx.CygxActivitySpecialPermissionPoints
|
|
|
|
|
|
itemBill := new(cygx.CygxActivitySpecialTripBill)
|
|
@@ -560,18 +564,7 @@ func ActivitySpecialCompanyApproval(companyId int, companyName string) (err erro
|
|
|
if userType == 2 {
|
|
|
packageTypeMap := map[int]int{1: 16, 2: 10}
|
|
|
totalTrip := packageTypeMap[packageType]
|
|
|
- if len(inheritList) > 0 {
|
|
|
- for _, v := range inheritList {
|
|
|
- if v.ChartPermissionId == 0 {
|
|
|
- itemBill.BillDetailed = totalTrip + v.Points
|
|
|
- } else {
|
|
|
- itemBill.BillDetailed = totalTrip
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- itemBill.BillDetailed = totalTrip
|
|
|
- }
|
|
|
-
|
|
|
+ itemBill.BillDetailed = totalTrip
|
|
|
itemBill.Total = strconv.Itoa(itemBill.BillDetailed) + "次"
|
|
|
if totalTrip == 10 {
|
|
|
itemBill.Content = "45w大套餐转正"
|
|
@@ -589,76 +582,92 @@ func ActivitySpecialCompanyApproval(companyId int, companyName string) (err erro
|
|
|
items = append(items, item)
|
|
|
|
|
|
} else {
|
|
|
- list, e := company.GetCompanyReportPermissionByCompanyIdAndProductId(companyId, 2)
|
|
|
+ //list, e := company.GetCompanyReportPermissionByCompanyIdAndProductId(companyId, 2)
|
|
|
+ //if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ // err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
|
|
|
+ //}
|
|
|
+ //if len(list) == 0 {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = " AND company_contract_id = ? AND is_upgrade = 1 "
|
|
|
+ pars = append(pars, companyContractId)
|
|
|
+ list, e := company.GetCompanyContractPermissionList(condition, pars) // 获取带有升级的权限
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
|
|
|
+ err = errors.New("GetCompanyContractPermissionList, Err: " + e.Error())
|
|
|
+ return
|
|
|
}
|
|
|
- if len(list) == 0 {
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxAllocationCompanyContractPermissionListById, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- var chartPermissionIdSlice []string
|
|
|
- mapChartName := make(map[string]int)
|
|
|
- mapUpgradeId := make(map[int]int)
|
|
|
- mapInheritChartName := make(map[string]int)
|
|
|
- mapPermissionNameTrip := make(map[string]int)
|
|
|
- //mapPermissionName := make(map[int]string)
|
|
|
- for _, v := range list {
|
|
|
- chartPermissionIdSlice = append(chartPermissionIdSlice, strconv.Itoa(v.ChartPermissionId))
|
|
|
- //是升级套餐才有点数
|
|
|
- if v.IsUpgrade == 1 {
|
|
|
- mapUpgradeId[v.ChartPermissionId] = 1
|
|
|
- }
|
|
|
+
|
|
|
+ if len(list) == 0 {
|
|
|
+ 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
|
|
|
- }
|
|
|
+
|
|
|
+ //获取权益主观权限
|
|
|
+ listRaiSubjectivity, e := models.GetChartPermissionListRaiSubjectivity()
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetChartPermissionListRaiSubjectivity, Err: " + e.Error())
|
|
|
}
|
|
|
- if len(chartList) == 0 {
|
|
|
- return
|
|
|
+ mapRaiSubjectivity := make(map[int]bool)
|
|
|
+ mapPermissionName := make(map[int]string)
|
|
|
+ for _, v := range listRaiSubjectivity {
|
|
|
+ mapRaiSubjectivity[v.ChartPermissionId] = true
|
|
|
+ mapPermissionName[v.ChartPermissionId] = v.ChartPermissionName
|
|
|
}
|
|
|
- for _, v := range chartList {
|
|
|
+ for _, v := range list {
|
|
|
//如果是升级则加点
|
|
|
- if _, ok := mapUpgradeId[v.ChartPermissionId]; ok {
|
|
|
- mapChartName[v.PermissionName] = 5 + mapPermissionNameTrip[v.ChartPermissionName]
|
|
|
+ if v.IsUpgrade == 1 && mapRaiSubjectivity[v.ChartPermissionId] {
|
|
|
item := new(cygx.CygxActivitySpecialPermissionPoints)
|
|
|
item.Points = 5
|
|
|
item.CompanyId = companyId
|
|
|
item.CompanyName = companyName
|
|
|
+ item.ChartPermissionId = v.ChartPermissionId
|
|
|
+ item.ChartPermissionName = mapPermissionName[v.ChartPermissionId]
|
|
|
item.CreateTime = time.Now()
|
|
|
item.ModifyTime = time.Now()
|
|
|
items = append(items, item)
|
|
|
- } else {
|
|
|
- mapChartName[v.PermissionName] = 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 {
|
|
|
- itemBill.BillDetailed += v
|
|
|
- itemBill.Total += k + strconv.Itoa(v) + "次+"
|
|
|
}
|
|
|
}
|
|
|
itemBill.Content = "行业升级套餐转正"
|
|
|
- itemBill.Total = strings.TrimRight(itemBill.Total, "+")
|
|
|
}
|
|
|
- err = cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
- if err != nil {
|
|
|
+
|
|
|
+ e := cygx.MultiAddCygxActivitySpecialPermissionPoints(items)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("MultiAddCygxActivitySpecialPermissionPoints, Err:" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ if userType != 2 && len(items) > 0 {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = " AND company_id = ? AND points > 0 "
|
|
|
+ pars = append(pars, companyId)
|
|
|
+ activitySpecialPermissionPointsList, e := cygx.GetCygxActivitySpecialPermissionPointsList(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsList, Err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var itemBillTotal []string
|
|
|
+ for _, v := range activitySpecialPermissionPointsList {
|
|
|
+ itemBillTotal = append(itemBillTotal, fmt.Sprint(v.ChartPermissionName, v.Points, "次"))
|
|
|
+ }
|
|
|
+ itemBill.Total = strings.Join(itemBillTotal, "+")
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果有升级行业权限,或者大套餐客户就写入流水信息
|
|
|
+ if itemBill.Total != "" {
|
|
|
+ e := cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivitySpecialTripBill, Err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|