Procházet zdrojové kódy

Merge branch 'cygx_10.9.1' into debug

ziwen před 1 rokem
rodič
revize
c57d235a05

+ 40 - 40
controllers/company.go

@@ -9262,16 +9262,16 @@ func (this *CompanyTodoController) CompanyActivitySpecialPointsBill() {
 		return
 	}
 
-	userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(companyId)
-	if err != nil {
-		br.Msg = "获取专项调研剩余次数失败"
-		br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
-		return
-	}
+	//userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(companyId)
+	//if err != nil {
+	//	br.Msg = "获取专项调研剩余次数失败"
+	//	br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
+	//	return
+	//}
 	//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}
 	resp := new(cygx.CygxActivitySpecialPointsBillResp)
 	//lastTripRemaining := 0
-	for i, v := range list {
+	for _, v := range list {
 		item := cygx.CygxActivitySpecialPointsBillRespItem{
 			Id:                  v.Id,
 			CreateTime:          v.CreateTime.Format(utils.FormatDateTime),
@@ -9282,6 +9282,7 @@ func (this *CompanyTodoController) CompanyActivitySpecialPointsBill() {
 			ActivityName:        v.ResearchTheme,
 			ChartPermissionId:   v.ChartPermissionId,
 			ChartPermissionName: v.ChartPermissionName,
+			Total:               v.Total,
 		}
 		if v.ActivityId == 0 {
 			item.Content = v.Content
@@ -9293,40 +9294,39 @@ func (this *CompanyTodoController) CompanyActivitySpecialPointsBill() {
 			} else if v.Way == 4 {
 				item.Content = item.ActivityName + "--活动取消"
 			}
-
-		}
-		if userType == 2 {
-			if i== 0 {
-				item.Total += strconv.Itoa(tripRemaining) + "次"
-			} else {
-				item.Total += strconv.Itoa(tripRemaining-list[i-1].BillDetailed) + "次"
-			}
-			//if v.BillDetailed < 4 {
-			//	item.Total += strconv.Itoa(lastTripRemaining-list[i-1].BillDetailed) + "次"
-			//} else {
-			//	item.Total += strconv.Itoa(lastTripRemaining) + "次"
-			//}
-		} else {
-			for k, num := range mapChartName {
-				if i== 0 {
-					item.Total += k + strconv.Itoa(num) + "次"
-				} else {
-					if list[i-1].ActivityId == 0 {
-						item.Total += k + strconv.Itoa(num) + "次+"
-					} else {
-						item.Total += k + strconv.Itoa(num-list[i-1].BillDetailed) + "次+"
-					}
-				}
-				//if num > 0 {
-				//	if i== 0{
-				//		item.Total += k + strconv.Itoa(num) + "次+"
-				//	} else {
-				//		item.Total += k + strconv.Itoa(num-v.BillDetailed) + "次+"
-				//	}
-				//}
-			}
-			item.Total = strings.TrimRight(item.Total, "+")
 		}
+		//if userType == 2 {
+		//	if i== 0 {
+		//		item.Total += strconv.Itoa(tripRemaining) + "次"
+		//	} else {
+		//		item.Total += strconv.Itoa(tripRemaining-list[i-1].BillDetailed) + "次"
+		//	}
+		//	//if v.BillDetailed < 4 {
+		//	//	item.Total += strconv.Itoa(lastTripRemaining-list[i-1].BillDetailed) + "次"
+		//	//} else {
+		//	//	item.Total += strconv.Itoa(lastTripRemaining) + "次"
+		//	//}
+		//} else {
+		//	for k, num := range mapChartName {
+		//		if i== 0 {
+		//			item.Total += k + strconv.Itoa(num) + "次+"
+		//		} else {
+		//			if list[i-1].ActivityId == 0 {
+		//				item.Total += k + strconv.Itoa(num) + "次+"
+		//			} else {
+		//				item.Total += k + strconv.Itoa(num-list[i-1].BillDetailed) + "次+"
+		//			}
+		//		}
+		//		//if num > 0 {
+		//		//	if i== 0{
+		//		//		item.Total += k + strconv.Itoa(num) + "次+"
+		//		//	} else {
+		//		//		item.Total += k + strconv.Itoa(num-v.BillDetailed) + "次+"
+		//		//	}
+		//		//}
+		//	}
+		//	item.Total = strings.TrimRight(item.Total, "+")
+		//}
 		resp.List = append(resp.List, &item)
 	}
 

+ 37 - 0
controllers/cygx/activity_special_trip.go

@@ -144,6 +144,25 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
 				itemBill.RegisterPlatform = 1
 				itemBill.ChartPermissionId = activityInfo.ChartPermissionId
 				itemBill.AdminId = AdminUser.AdminId
+				userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
+				if err != nil {
+					br.Msg = "获取专项调研剩余次数失败"
+					br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
+					return
+				}
+				if userType == 2 {
+					tripRemaining -= 1
+					itemBill.Total = strconv.Itoa(tripRemaining) + "次"
+				} else {
+					for k, num := range mapChartName {
+						if activityInfo.ChartPermissionName == k {
+							num -= 1
+						}
+						itemBill.Total += k + strconv.Itoa(num) + "次+"
+					}
+					itemBill.Total = strings.TrimRight(itemBill.Total, "+")
+				}
+
 
 				item := new(cygx.CygxActivitySpecialTrip)
 				item.UserId = infoUser.UserId
@@ -508,6 +527,24 @@ func (this *ActivitySpecialTripCoAntroller) TripCancel() {
 		br.ErrMsg = "修改失败 Err:" + err.Error()
 		return
 	}
+	userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
+	if err != nil {
+		br.Msg = "获取专项调研剩余次数失败"
+		br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
+		return
+	}
+	if userType == 2 {
+		tripRemaining += 1
+		itemBill.Total = strconv.Itoa(tripRemaining) + "次"
+	} else {
+		for k, num := range mapChartName {
+			if activityInfo.ChartPermissionName == k {
+				num += 1
+			}
+			itemBill.Total += k + strconv.Itoa(num) + "次+"
+		}
+		itemBill.Total = strings.TrimRight(itemBill.Total, "+")
+	}
 	err = cygx.AddCygxActivitySpecialTripBill(itemBill)
 	if err != nil {
 		br.Msg = "修改失败"

+ 4 - 0
models/cygx/activity_special_trip_bill.go

@@ -23,6 +23,7 @@ type CygxActivitySpecialTripBill struct {
 	ChartPermissionId int       `description:"行业id"`
 	Way               int       `description:"1报名,取消报名。2到会取消到会 3转正或清零 4取消活动"`
 	Content           string    `description:"内容"`
+	Total             string    `description:"总和"`
 }
 
 type CygxActivitySpecialTripBillList struct {
@@ -42,6 +43,8 @@ type CygxActivitySpecialTripBillList struct {
 	RegisterPlatform    int       `description:"来源 1小程序,2:网页"`
 	ChartPermissionId   int       `description:"行业id"`
 	ChartPermissionName string    `description:"行业名称"`
+	Way                 int       `description:"1报名,取消报名。2到会取消到会 3转正或清零 4取消活动"`
+	Content             string    `description:"内容"`
 }
 
 // 添加
@@ -129,6 +132,7 @@ type CygxActivitySpecialTripBillDetailList struct {
 	ChartPermissionName string    `description:"行业名称"`
 	Content             string    `description:"内容"`
 	Way                 int       `description:"1报名,取消报名。2到会取消到会 3转正或清零 4取消活动"`
+	Total               string    `description:"总和"`
 }
 
 func GetCygxActivitySpecialTripBillDetailList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripBillDetailList, err error) {

+ 2 - 1
services/company_apply/company_approval.go

@@ -399,7 +399,6 @@ func Approved(approvalRecord *contract.ContractApprovalRecord, opUser *system.Ad
 
 				go cygxService.YanXuanCompanyApproval(recordInfo.CompanyId) //研选审批通过的时候研选扣点更新
 
-				go cygxService.ActivitySpecialCompanyApproval(recordInfo.CompanyId, companyInfo.CompanyName) //审批通过的时候专项调研次数更新
 			}
 		}()
 	} else {
@@ -654,6 +653,8 @@ func afterApproved(companyApprovalId int, opUserId int, opUserName string) (err
 				err = errors.New("试用转正式失败,Err:" + tmpErr.Error())
 				return
 			}
+
+			go cygxService.ActivitySpecialCompanyApproval(recodeInfo.CompanyId, companyInfo.CompanyName) //审批通过的时候专项调研次数更新
 		} else {
 			tmpErr = company.ApplyApproveContract(recodeInfo.CompanyId, recodeInfo.ProductId, recodeInfo.CompanyApprovalId, contractInfo.CompanyContractId)
 			if tmpErr != nil {

+ 51 - 13
services/cygx/activity_special.go

@@ -572,8 +572,40 @@ func ActivitySpecialCompanyApproval(companyId int,companyName string) (err error
 		packageTypeMap := map[int]int{1: 16, 2: 10}
 		totalTrip := packageTypeMap[packageType]
 		itemBill.BillDetailed = totalTrip
+		itemBill.Total = strconv.Itoa(totalTrip) + "次"
 	} else {
-		itemBill.BillDetailed = 5
+		itemBill.BillDetailed = 15
+		list, e := company.GetCompanyReportPermissionUpgrade(companyId, 2)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
+		}
+		if len(list) == 0 {
+			return
+		}
+		var chartPermissionIdSlice []string
+		mapChartName := 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))
+		}
+		chartList, e := models.GetChartPermissionByIds(chartPermissionIdSlice)
+		if e != nil {
+			err = errors.New("获取品种信息失败, Err:" + e.Error())
+			return
+		}
+		if len(chartList) == 0 {
+			return
+		}
+		for _, v := range chartList {
+			mapChartName[v.PermissionName] = 5 + mapPermissionNameTrip[v.ChartPermissionName]
+		}
+		for k, v := range mapChartName {
+			if v > 0 {
+				itemBill.Total += k + strconv.Itoa(v) + "次+"
+			}
+		}
+		itemBill.Total = strings.TrimRight(itemBill.Total, "+")
 	}
 	err = cygx.AddCygxActivitySpecialTripBill(itemBill)
 	if err != nil {
@@ -585,17 +617,23 @@ func ActivitySpecialCompanyApproval(companyId int,companyName string) (err error
 
 // 取消专项调研返点
 func ActivitySpecialPublishAndCancel(activityInfo *cygx.ActivitySpecialDetail) (err error) {
-	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
-	}
+	//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
 }