Ver código fonte

Merge branch 'cygx_10.9.1' into debug

# Conflicts:
#	controllers/company.go
ziwen 1 ano atrás
pai
commit
172fa4621e
2 arquivos alterados com 89 adições e 64 exclusões
  1. 82 63
      controllers/company.go
  2. 7 1
      services/cygx/activity_special.go

+ 82 - 63
controllers/company.go

@@ -9159,69 +9159,6 @@ func (this *CompanyTodoController) CompanyActivityPointsBill() {
 	br.Data = resp
 }
 
-// @Title 获取流水信息接口
-// @Description 获取流水信息接口
-// @Param   CompanyId   query   int  true       "客户id"
-// @Success 200 {object} company.CygxActivityPointsBillListResp
-// @router /company/activity/special/points/bill [get]
-func (this *CompanyTodoController) CompanyActivitySpecialPointsBill() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	companyId, _ := this.GetInt("CompanyId")
-	if companyId <= 0 {
-		br.Msg = "请选择客户"
-		return
-	}
-	// 获取流水信息
-	var condition string
-	var pars []interface{}
-
-	condition += ` AND company_id = ? `
-	pars = append(pars, companyId)
-
-	//查询当年的数据
-	condition += ` AND b.create_time >= ?  `
-	pars = append(pars, time.Now().Format(utils.FormatYearDate)+"-01-01")
-	list, err := cygx.GetCygxActivitySpecialTripBillDetailList(condition, pars)
-	if err != nil {
-		br.Msg = "获取任务信息失败"
-		br.ErrMsg = "获取任务信息失败,err:" + err.Error()
-		return
-	}
-
-	specialSurplus, err := cygxService.GetSpecialSurplusByCompany(companyId)
-	if err != nil {
-		br.Msg = "获取专项调研剩余次数失败"
-		br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
-		return
-	}
-	resp := new(cygx.CygxActivitySpecialPointsBillResp)
-	for _, v := range list {
-		item := cygx.CygxActivitySpecialPointsBillRespItem{
-			Id:                  v.Id,
-			Content:             v.ActivityName,
-			Total:               specialSurplus,
-			CreateTime:          v.CreateTime.Format(utils.FormatDateTime),
-			CompanyId:           v.CompanyId,
-			CompanyName:         v.CompanyName,
-			RealName:            v.RealName,
-			BillDetailed:        v.BillDetailed,
-			ActivityName:        v.ActivityName,
-			ChartPermissionId:   v.ChartPermissionId,
-			ChartPermissionName: v.ChartPermissionName,
-		}
-		resp.List = append(resp.List, &item)
-	}
-
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
 // DelRemark
 // @Title 删除备注
 // @Description 删除备注
@@ -9291,3 +9228,85 @@ func (this *CompanyController) DelRemark() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title 获取流水信息接口
+// @Description 获取流水信息接口
+// @Param   CompanyId   query   int  true       "客户id"
+// @Success 200 {object} company.CygxActivityPointsBillListResp
+// @router /company/activity/special/points/bill [get]
+func (this *CompanyTodoController) CompanyActivitySpecialPointsBill() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	companyId, _ := this.GetInt("CompanyId")
+	if companyId <= 0 {
+		br.Msg = "请选择客户"
+		return
+	}
+	// 获取流水信息
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND company_id = ? `
+	pars = append(pars, companyId)
+
+	//查询当年的数据
+	condition += ` AND b.create_time >= ?  `
+	pars = append(pars, time.Now().Format(utils.FormatYearDate)+"-01-01")
+	list, err := cygx.GetCygxActivitySpecialTripBillDetailListAll(condition, pars)
+	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)
+	for i, v := range list {
+		item := cygx.CygxActivitySpecialPointsBillRespItem{
+			Id:                  v.Id,
+			Content:             v.ActivityName,
+			CreateTime:          v.CreateTime.Format(utils.FormatDateTime),
+			CompanyId:           v.CompanyId,
+			CompanyName:         v.CompanyName,
+			RealName:            v.RealName,
+			BillDetailed:        v.BillDetailed,
+			ActivityName:        v.ActivityName,
+			ChartPermissionId:   v.ChartPermissionId,
+			ChartPermissionName: v.ChartPermissionName,
+		}
+		if v.ActivityId == 0 {
+			item.Content = v.Content
+		}
+		if userType == 2 {
+			if i== 0{
+				item.Total += strconv.Itoa(tripRemaining) + "次"
+			}
+			item.Total += strconv.Itoa(tripRemaining-v.BillDetailed) + "次"
+		} else {
+			for k, num := range mapChartName {
+				if num > 0 {
+					if i== 0{
+						item.Total += k + strconv.Itoa(num) + "次+"
+					}
+					item.Total += k + strconv.Itoa(num-v.BillDetailed) + "次+"
+				}
+			}
+			item.Total = strings.TrimRight(item.Total, "+")
+		}
+		resp.List = append(resp.List, &item)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 7 - 1
services/cygx/activity_special.go

@@ -264,6 +264,9 @@ func GetSpecialSurplusByCompany(companyId int) (specialSurplus string, err error
 			//}
 			var TripBillNum int
 			for _, v := range listTripBill {
+				if v.ActivityId == 0 {
+					continue
+				}
 				TripBillNum += v.BillDetailed
 			}
 			// CRM13.2 70w客户有16次专项调研, 45w有10次
@@ -282,7 +285,7 @@ func GetSpecialSurplusByCompany(companyId int) (specialSurplus string, err error
 			//	specialSurplus += chartMap[k] + strconv.Itoa(tripRemaining) + "次,"
 			//}
 			//specialSurplus = strings.TrimRight(specialSurplus, ",")
-			specialSurplus = specialSurplus + "次"
+			specialSurplus = strconv.Itoa(tripRemaining) + "次"
 			//tripRemaining = 12 - tripTota
 		} else {
 			list, e := company.GetCompanyReportPermissionUpgrade(companyId, 2)
@@ -334,6 +337,9 @@ func GetSpecialSurplusByCompany(companyId int) (specialSurplus string, err error
 			}
 			//var TripBillNum int
 			for _, v := range listTripBill {
+				if v.ActivityId == 0 {
+					continue
+				}
 				mapPermissionNameTrip[v.ChartPermissionName] += v.BillDetailed
 			}
 			for _, v := range chartList {