ziwen 1 年之前
父节点
当前提交
1242e9b97e
共有 1 个文件被更改,包括 39 次插入3 次删除
  1. 39 3
      controllers/cygx/activity_special_trip.go

+ 39 - 3
controllers/cygx/activity_special_trip.go

@@ -62,7 +62,7 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
 		uids += strconv.Itoa(v.UserId) + ","
 	}
 	uids = strings.TrimRight(uids, ",")
-	for _, v := range uidList {
+	for i, v := range uidList {
 		uid := v.UserId
 		wxUser, userErr := models.GetWxUserByUserId(uid)
 		if userErr != nil {
@@ -150,12 +150,12 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
 					return
 				}
 				if userType == 2 {
-					tripRemaining -= 1
+					tripRemaining -= 1-i
 					itemBill.Total = strconv.Itoa(tripRemaining) + "次"
 				} else {
 					for k, num := range mapChartName {
 						if activityInfo.ChartPermissionName == k {
-							num -= 1
+							num -= 1 - i
 						}
 						itemBill.Total += k + strconv.Itoa(num) + "次+"
 					}
@@ -772,6 +772,24 @@ func (this *ActivitySpecialTripCoAntroller) MeetingDo() {
 				itemBill.ChartPermissionId = activityInfo.ChartPermissionId
 				itemBill.AdminId = AdminUser.AdminId
 				itemBill.Way = 2
+				userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(v.CompanyId)
+				if err != nil {
+					br.Msg = "获取专项调研剩余次数失败"
+					br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
+					return
+				}
+				if userType == 2 {
+					tripRemaining += itemBill.BillDetailed
+					itemBill.Total = strconv.Itoa(tripRemaining) + "次"
+				} else {
+					for k, num := range mapChartName {
+						if activityInfo.ChartPermissionName == k {
+							num += itemBill.BillDetailed
+						}
+						itemBill.Total += k + strconv.Itoa(num) + "次+"
+					}
+					itemBill.Total = strings.TrimRight(itemBill.Total, "+")
+				}
 				itemsBill = append(itemsBill, itemBill)
 			}
 		}
@@ -811,6 +829,24 @@ func (this *ActivitySpecialTripCoAntroller) MeetingDo() {
 			itemBill.ChartPermissionId = activityInfo.ChartPermissionId
 			itemBill.AdminId = AdminUser.AdminId
 			itemBill.Way = 2
+			userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(v.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, "+")
+			}
 			itemsBill = append(itemsBill, itemBill)
 		}
 		items = append(items, item)