xingzai hai 6 meses
pai
achega
adc1b91a6d
Modificáronse 3 ficheiros con 181 adicións e 1 borrados
  1. 131 1
      controllers/cygx/report_article.go
  2. 3 0
      models/cygx/cygx_user.go
  3. 47 0
      models/wx_user.go

+ 131 - 1
controllers/cygx/report_article.go

@@ -1978,7 +1978,7 @@ func (this *IndustrialSubjectController) ReportMappingAdd() {
 }
 
 //func init() {
-//	initart()
+//	initAct()
 //}
 
 func initart() {
@@ -2219,3 +2219,133 @@ func initart() {
 		}
 	}
 }
+
+func initAct() {
+	var condition string
+	condition = " AND  s.activity_id = 5734    AND is_meeting = 1 "
+	list, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		fmt.Println(err)
+		return
+	}
+
+	var companyIds []int
+	for _, vuser := range list {
+		//mapuserMapbil[vuser.Mobile] = vuser
+		companyIds = append(companyIds, vuser.CompanyId)
+	}
+	mapuserMapbil := make(map[int]*models.WxUserSller)
+	listCompany, err := models.GetWxUserRaiSllerListByUserComapnyId(companyIds)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	//合并合同所对应的权限
+	mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	for _, v := range listCompany {
+		v.ChartPermissionName = mappermissionName[v.CompanyId]
+		mapuserMapbil[v.CompanyId] = v
+	}
+
+	listCompanyFicc, err := models.GetWxUserRaiSllerListByUserComapnyIdFicc(companyIds)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	for _, v := range listCompanyFicc {
+		if mapuserMapbil[v.CompanyId] != nil {
+			continue
+		}
+		v.Status = ""
+		v.SellerName = ""
+		mapuserMapbil[v.CompanyId] = v
+	}
+
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+
+	redStyle := xlsx.NewStyle()
+	redStyle.Alignment = alignment
+	redStyle.ApplyAlignment = true
+	redStyle.Font.Color = "ff0000"
+	//定义底色需要标黄的 单元格颜色
+	redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
+	redStyle.Fill = redFill
+	//redStyle.Border = *border
+
+	var sheetName string
+	sheetName = "PV"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "姓名"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "手机号"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+	cellD := rowTitle.AddCell()
+	cellD.Value = "所属销售"
+
+	cellStatus := rowTitle.AddCell()
+	cellStatus.Value = "客户状态"
+
+	cellTc := rowTitle.AddCell()
+	cellTc.Value = "签约套餐"
+
+	for _, item := range list {
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = item.RealName
+		//if item.Ly == "1" {
+		//	cellAData.SetStyle(redStyle)
+		//}
+		cellBData := row.AddCell()
+		cellBData.Value = item.Mobile
+		cellCData := row.AddCell()
+		//cellCData.Value = item.CompanyName
+		cellDData := row.AddCell()
+		//cellDData.Value = item.SellerName
+
+		cellStatusData := row.AddCell()
+		cellermissionNameData := row.AddCell()
+		if mapuserMapbil[item.CompanyId] != nil {
+			cellCData.Value = mapuserMapbil[item.CompanyId].CompanyName
+			cellDData.Value = mapuserMapbil[item.CompanyId].SellerName
+			cellStatusData.Value = mapuserMapbil[item.CompanyId].Status
+			cellermissionNameData.Value = mapuserMapbil[item.CompanyId].ChartPermissionName
+		}
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+}

+ 3 - 0
models/cygx/cygx_user.go

@@ -1078,6 +1078,9 @@ func GetActivityMeetByUser(condition string, startSize, pageSize int) (item []*U
 			t.activity_type,
 			s.signup_type,
 			s.is_meeting,
+			s.real_name,
+			s.mobile,
+			s.company_id,
 			a.activity_name,
 			a.chart_permission_name,
 			a.activity_type_name,

+ 47 - 0
models/wx_user.go

@@ -616,6 +616,53 @@ func GetWxUserRaiSllerListByUserMobileFiic(mobiles []string) (list []*WxUserSlle
 	return
 }
 
+// GetWxUserRaiSllerListByUserMobile 根据用户手机号获取权益相关用户信息
+func GetWxUserRaiSllerListByUserComapnyId(company_ids []int) (list []*WxUserSller, err error) {
+	lenarr := len(company_ids)
+	if lenarr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := ` SELECT
+				c.company_name,
+				c.company_id,
+				p.status,
+				p.seller_name 
+			FROM
+			
+		company_product AS p 
+				INNER JOIN company AS c ON c.company_id = p.company_id 
+			WHERE
+				1 = 1 
+				AND p.product_id = 2 
+				AND c.company_id IN (` + utils.GetOrmInReplace(lenarr) + `)  `
+	_, err = o.Raw(sql, company_ids).QueryRows(&list)
+	return
+}
+
+func GetWxUserRaiSllerListByUserComapnyIdFicc(company_ids []int) (list []*WxUserSller, err error) {
+	lenarr := len(company_ids)
+	if lenarr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := ` SELECT
+				c.company_name,
+				c.company_id,
+				p.status,
+				p.seller_name 
+			FROM
+			
+		company_product AS p 
+				INNER JOIN company AS c ON c.company_id = p.company_id 
+			WHERE
+				1 = 1 
+				AND p.product_id = 1 
+				AND c.company_id IN (` + utils.GetOrmInReplace(lenarr) + `)  `
+	_, err = o.Raw(sql, company_ids).QueryRows(&list)
+	return
+}
+
 // GetWxUserByCompanyIds 根据客户ID集合获取用户列表
 func GetWxUserByCompanyIds(companyIds []int) (items []*WxUser, err error) {
 	num := len(companyIds)