|
@@ -556,202 +556,146 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
|
|
|
//}
|
|
|
|
|
|
// 审批通过的时候专项调研次数更新
|
|
|
-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}
|
|
|
-
|
|
|
- // 获取合同信息-套餐信息
|
|
|
- companyContract, e := company.GetCompanyContractById(companyContractId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("GetCompanyContractById, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- packageType := companyContract.RaiPackageType
|
|
|
- var items []*cygx.CygxActivitySpecialPermissionPoints
|
|
|
-
|
|
|
- itemBill := new(cygx.CygxActivitySpecialTripBill)
|
|
|
- itemBill.CreateTime = time.Now()
|
|
|
- itemBill.CompanyId = companyId
|
|
|
- itemBill.CompanyName = companyName
|
|
|
- itemBill.Source = 2
|
|
|
- itemBill.DoType = 2
|
|
|
- itemBill.Way = 3
|
|
|
- if packageType > 0 {
|
|
|
- packageTypeMap := map[int]float64{1: 16, 2: 12}
|
|
|
- totalTrip := packageTypeMap[packageType]
|
|
|
- itemBill.BillDetailed = totalTrip
|
|
|
- itemBill.Total = fmt.Sprint(itemBill.BillDetailed) + "次"
|
|
|
- if packageType == 2 {
|
|
|
- itemBill.Content = "45w大套餐转正"
|
|
|
- } else {
|
|
|
- itemBill.Content = "70w大套餐转正"
|
|
|
- }
|
|
|
-
|
|
|
- //记录公司剩余点数
|
|
|
- item := new(cygx.CygxActivitySpecialPermissionPoints)
|
|
|
- item.Points = totalTrip
|
|
|
- item.CompanyId = companyId
|
|
|
- item.CompanyName = companyName
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.ModifyTime = time.Now()
|
|
|
- items = append(items, item)
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- 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("GetCompanyContractPermissionList, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if len(list) == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- //获取权益主观权限
|
|
|
- listRaiSubjectivity, e := models.GetChartPermissionListRaiSubjectivity()
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetChartPermissionListRaiSubjectivity, Err: " + e.Error())
|
|
|
- }
|
|
|
- mapRaiSubjectivity := make(map[int]bool)
|
|
|
- mapPermissionName := make(map[int]string)
|
|
|
- for _, v := range listRaiSubjectivity {
|
|
|
- mapRaiSubjectivity[v.ChartPermissionId] = true
|
|
|
- mapPermissionName[v.ChartPermissionId] = v.ChartPermissionName
|
|
|
- }
|
|
|
- var points float64
|
|
|
- for _, v := range list {
|
|
|
- //如果是升级则加点
|
|
|
- if v.IsUpgrade == 1 && mapRaiSubjectivity[v.ChartPermissionId] {
|
|
|
- points += 4
|
|
|
- }
|
|
|
- }
|
|
|
- item := new(cygx.CygxActivitySpecialPermissionPoints)
|
|
|
- item.Points = points
|
|
|
- item.CompanyId = companyId
|
|
|
- item.CompanyName = companyName
|
|
|
- item.ChartPermissionId = 0
|
|
|
- item.ChartPermissionName = ""
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.ModifyTime = time.Now()
|
|
|
- items = append(items, item)
|
|
|
- itemBill.Content = "行业升级套餐转正"
|
|
|
- }
|
|
|
+//func ActivitySpecialCompanyApproval(companyId, companyContractId int, companyName string) (err error) {
|
|
|
|
|
|
- e = cygx.MultiAddCygxActivitySpecialPermissionPoints(items)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("MultiAddCygxActivitySpecialPermissionPoints, Err:" + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if packageType == 0 && len(items) > 0 {
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
- pars = make([]interface{}, 0)
|
|
|
- condition = " AND company_id = ? AND points > 0 ORDER BY chart_permission_id DESC "
|
|
|
- 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
|
|
|
- itemBillTotalMap := make(map[string]string)
|
|
|
- for _, v := range activitySpecialPermissionPointsList {
|
|
|
- itemBillTotal = append(itemBillTotal, fmt.Sprint(v.ChartPermissionName, v.Points, "次"))
|
|
|
- itemBillTotalMap[v.ChartPermissionName] = fmt.Sprint(v.ChartPermissionName, v.Points, "次")
|
|
|
- }
|
|
|
- itemBill.BillDetailed = float64(4 * len(items))
|
|
|
- permissionNameSlice := []string{"医药", "消费", "科技", "智造"}
|
|
|
- var itemBillTotalNew []string
|
|
|
- for _, v := range permissionNameSlice {
|
|
|
- if itemBillTotalMap[v] == "" {
|
|
|
- itemBillTotalNew = append(itemBillTotalNew, fmt.Sprint(v, "0次"))
|
|
|
- } else {
|
|
|
- itemBillTotalNew = append(itemBillTotalNew, itemBillTotalMap[v])
|
|
|
- }
|
|
|
- }
|
|
|
- itemBill.Total = strings.Join(itemBillTotalNew, "+")
|
|
|
- }
|
|
|
-
|
|
|
- //如果有升级行业权限,或者大套餐客户就写入流水信息
|
|
|
- if itemBill.Total != "" {
|
|
|
- e := cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("AddCygxActivitySpecialTripBill, Err:" + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// 取消专项调研返点
|
|
|
-func ActivitySpecialPublishAndCancel(activityInfo *cygx.ActivitySpecialDetail) (err error) {
|
|
|
- //userType, tripRemaining, mapChartName, err := GetChartPermissionSpecialSurplusByCompany(companyId)
|
|
|
- //if err != nil {
|
|
|
- // br.Msg = "获取专项调研剩余次数失败"
|
|
|
- // br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //itemBill := new(cygx.CygxActivitySpecialTripBill)
|
|
|
- //itemBill.CreateTime = time.Now()
|
|
|
- //itemBill.ActivityId = activityInfo.ActivityId
|
|
|
- //itemBill.Content = activityInfo.ResearchTheme + "--活动取消"
|
|
|
- //itemBill.Source = 2
|
|
|
- //itemBill.DoType = 2
|
|
|
- //itemBill.Way = 4
|
|
|
- //itemBill.BillDetailed = 1
|
|
|
- //err = cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//func init() {
|
|
|
-// fmt.Println(GetSpecialSurplusByCompanyNew(16))
|
|
|
+// 获取合同信息-套餐信息
|
|
|
+//companyContract, e := company.GetCompanyContractById(companyContractId)
|
|
|
+//if e != nil {
|
|
|
+// err = errors.New("GetCompanyContractById, Err: " + e.Error())
|
|
|
+// return
|
|
|
+//}
|
|
|
+//packageType := companyContract.RaiPackageType
|
|
|
+//var items []*cygx.CygxActivitySpecialPermissionPoints
|
|
|
+//
|
|
|
+//itemBill := new(cygx.CygxActivitySpecialTripBill)
|
|
|
+//itemBill.CreateTime = time.Now()
|
|
|
+//itemBill.CompanyId = companyId
|
|
|
+//itemBill.CompanyName = companyName
|
|
|
+//itemBill.Source = 2
|
|
|
+//itemBill.DoType = 2
|
|
|
+//itemBill.Way = 3
|
|
|
+//if packageType > 0 {
|
|
|
+// packageTypeMap := map[int]float64{1: 16, 2: 12}
|
|
|
+// totalTrip := packageTypeMap[packageType]
|
|
|
+// itemBill.BillDetailed = totalTrip
|
|
|
+// itemBill.Total = fmt.Sprint(itemBill.BillDetailed) + "次"
|
|
|
+// if packageType == 2 {
|
|
|
+// itemBill.Content = "45w大套餐转正"
|
|
|
+// } else {
|
|
|
+// itemBill.Content = "70w大套餐转正"
|
|
|
+// }
|
|
|
+//
|
|
|
+// //记录公司剩余点数
|
|
|
+// item := new(cygx.CygxActivitySpecialPermissionPoints)
|
|
|
+// item.Points = totalTrip
|
|
|
+// item.CompanyId = companyId
|
|
|
+// item.CompanyName = companyName
|
|
|
+// item.CreateTime = time.Now()
|
|
|
+// item.ModifyTime = time.Now()
|
|
|
+// items = append(items, item)
|
|
|
+//
|
|
|
+//} else {
|
|
|
+//
|
|
|
+// 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("GetCompanyContractPermissionList, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// if len(list) == 0 {
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// //获取权益主观权限
|
|
|
+// listRaiSubjectivity, e := models.GetChartPermissionListRaiSubjectivity()
|
|
|
+// if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+// err = errors.New("GetChartPermissionListRaiSubjectivity, Err: " + e.Error())
|
|
|
+// }
|
|
|
+// mapRaiSubjectivity := make(map[int]bool)
|
|
|
+// mapPermissionName := make(map[int]string)
|
|
|
+// for _, v := range listRaiSubjectivity {
|
|
|
+// mapRaiSubjectivity[v.ChartPermissionId] = true
|
|
|
+// mapPermissionName[v.ChartPermissionId] = v.ChartPermissionName
|
|
|
+// }
|
|
|
+// var points float64
|
|
|
+// for _, v := range list {
|
|
|
+// //如果是升级则加点
|
|
|
+// if v.IsUpgrade == 1 && mapRaiSubjectivity[v.ChartPermissionId] {
|
|
|
+// points += 4
|
|
|
+// }
|
|
|
+// }
|
|
|
+// item := new(cygx.CygxActivitySpecialPermissionPoints)
|
|
|
+// item.Points = points
|
|
|
+// item.CompanyId = companyId
|
|
|
+// item.CompanyName = companyName
|
|
|
+// item.ChartPermissionId = 0
|
|
|
+// item.ChartPermissionName = ""
|
|
|
+// item.CreateTime = time.Now()
|
|
|
+// item.ModifyTime = time.Now()
|
|
|
+// items = append(items, item)
|
|
|
+// itemBill.Content = "行业升级套餐转正"
|
|
|
+//}
|
|
|
+//
|
|
|
+//e = cygx.MultiAddCygxActivitySpecialPermissionPoints(items)
|
|
|
+//if e != nil {
|
|
|
+// err = errors.New("MultiAddCygxActivitySpecialPermissionPoints, Err:" + e.Error())
|
|
|
+// return
|
|
|
+//}
|
|
|
+//if packageType == 0 && len(items) > 0 {
|
|
|
+// var condition string
|
|
|
+// var pars []interface{}
|
|
|
+// pars = make([]interface{}, 0)
|
|
|
+// condition = " AND company_id = ? AND points > 0 ORDER BY chart_permission_id DESC "
|
|
|
+// 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
|
|
|
+// itemBillTotalMap := make(map[string]string)
|
|
|
+// for _, v := range activitySpecialPermissionPointsList {
|
|
|
+// itemBillTotal = append(itemBillTotal, fmt.Sprint(v.ChartPermissionName, v.Points, "次"))
|
|
|
+// itemBillTotalMap[v.ChartPermissionName] = fmt.Sprint(v.ChartPermissionName, v.Points, "次")
|
|
|
+// }
|
|
|
+// itemBill.BillDetailed = float64(4 * len(items))
|
|
|
+// permissionNameSlice := []string{"医药", "消费", "科技", "智造"}
|
|
|
+// var itemBillTotalNew []string
|
|
|
+// for _, v := range permissionNameSlice {
|
|
|
+// if itemBillTotalMap[v] == "" {
|
|
|
+// itemBillTotalNew = append(itemBillTotalNew, fmt.Sprint(v, "0次"))
|
|
|
+// } else {
|
|
|
+// itemBillTotalNew = append(itemBillTotalNew, itemBillTotalMap[v])
|
|
|
+// }
|
|
|
+// }
|
|
|
+// itemBill.Total = strings.Join(itemBillTotalNew, "+")
|
|
|
+//}
|
|
|
+//
|
|
|
+////如果有升级行业权限,或者大套餐客户就写入流水信息
|
|
|
+//if itemBill.Total != "" {
|
|
|
+// e := cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("AddCygxActivitySpecialTripBill, Err:" + e.Error())
|
|
|
+// 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)
|
|
|
+ points, e := cygx.GetCygxActivitySpecialPermissionPointsCount(companyId)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
err = e
|
|
|
return
|
|
|
}
|
|
|
- if billItem != nil {
|
|
|
- specialSurplus = billItem.Total
|
|
|
- } else {
|
|
|
- specialSurplus = "0次"
|
|
|
- }
|
|
|
+ specialSurplus = fmt.Sprint(points, "次")
|
|
|
return
|
|
|
- //}
|
|
|
- //return
|
|
|
}
|
|
|
|
|
|
// GetSpecialBillMaxChartPermissionId 获取专项调研剩余点数最多的行业
|
|
@@ -1007,7 +951,5 @@ func CheckSpecialActivityPointsByUserIds(userIds string, activityLen int) (err e
|
|
|
err = errors.New("您的专项调研次数已用完,如仍想参加,请与您的对口销售商议")
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return
|
|
|
-
|
|
|
}
|