소스 검색

no message

zhangchuanxing 1 주 전
부모
커밋
305e7d60d5
4개의 변경된 파일256개의 추가작업 그리고 1개의 파일을 삭제
  1. 224 1
      controllers/cygx/report_article.go
  2. 7 0
      models/company/company.go
  3. 8 0
      models/company/company_contract.go
  4. 17 0
      models/roadshow/calendar.go

+ 224 - 1
controllers/cygx/report_article.go

@@ -6031,7 +6031,7 @@ func initActZHouqi() {
 }
 
 //func init() {
-//	initContract()
+//	initRsCalendarCheck()
 //}
 
 // 研选扣点明细,与专项调研明细
@@ -6172,3 +6172,226 @@ func initPointBill() {
 	}
 	fmt.Println("end")
 }
+
+// 公司最后一份合同期间内参加的路演
+func initRsCalendar() {
+	//行业
+	listcompany, e := company.GetOverseasCompanysByCompanyIdsInit()
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	//创建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 = "点数明细"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "客户名称"
+
+	cellPd := rowTitle.AddCell()
+	cellPd.Value = "最后一份合同开始时间"
+	//cellA := rowTitle.AddCell()
+	//cellA.Value = "系列"
+
+	cellAt := rowTitle.AddCell()
+	cellAt.Value = "最后一份合同结束时间"
+
+	cellUser := rowTitle.AddCell()
+	cellUser.Value = "路演次数"
+
+	//cellRsdate := rowTitle.AddCell()
+	//cellRsdate.Value = "路演时间"
+	//
+	//cellYjy := rowTitle.AddCell()
+	//cellYjy.Value = "路演研究员"
+
+	cellId := rowTitle.AddCell()
+	cellId.Value = "公司ID"
+
+	for _, v := range listcompany {
+		fmt.Println(v.CompanyId)
+
+		detail, err := company.GetCompanyContractDetailByCompanyContractIdInit(v.CompanyId)
+		if err != nil {
+			fmt.Println(err, v.CompanyId)
+			return
+		}
+
+		listRs, err := roadshow.GetRsCalendarResearcherListByCalendarResearcherIdInit(v.CompanyId, detail.StartDate, detail.EndDate)
+		if err != nil {
+			fmt.Println(err, "GetRsCalendarResearcherListByCalendarResearcherIdInit", v.CompanyId)
+			return
+		}
+
+		row := sheet.AddRow()
+		cellADatatitle := row.AddCell()
+		cellADatatitle.Value = v.CompanyName
+
+		cellADataPd := row.AddCell()
+		cellADataPd.Value = detail.StartDate
+
+		cellBData := row.AddCell()
+		cellBData.Value = detail.EndDate
+
+		cellUserData := row.AddCell()
+		cellUserData.Value = fmt.Sprint(len(listRs))
+
+		//cellRsdateData := row.AddCell()
+		//cellRsdateData.Value = vs.StartDate
+		//
+		//cellYjyData := row.AddCell()
+		//cellYjyData.Value = vs.ResearcherName
+
+		cellCompanyData := row.AddCell()
+		cellCompanyData.Value = fmt.Sprint(v.CompanyId)
+
+		//for _, vs := range listRs {
+		//
+		//}
+
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+}
+
+// 公司最后一份合同期间内参加的路演
+func initRsCalendarCheck() {
+	//行业
+	var condition string
+	var pars []interface{}
+
+	condition = " AND  points > 0 GROUP BY company_id  "
+	listcompany, e := cygx.GetCygxActivitySpecialPermissionPointsList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	//创建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 = "点数明细"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "客户名称"
+
+	cellPd := rowTitle.AddCell()
+	cellPd.Value = "剩余点数"
+
+	cellId := rowTitle.AddCell()
+	cellId.Value = "公司ID"
+
+	for _, v := range listcompany {
+		fmt.Println(v.CompanyId)
+		var conditionP string
+		var parsP []interface{}
+		detail, err := company.GetCompanyContractDetailByCompanyContractIdInit(v.CompanyId)
+		if err != nil {
+			fmt.Println(err, v.CompanyId)
+			continue
+			//return
+		}
+
+		conditionP = " AND  company_id = ? AND product_id = 2  AND status = '正式'  AND is_upgrade = 1  "
+		parsP = append(parsP, v.CompanyId)
+
+		//获取所有开通买方研选正式试用的客户列表
+		listCompanyPermission, e := company.GetCompanyReportPermissionList(conditionP, parsP, 0, 10)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			fmt.Println(e, v.CompanyId)
+			return
+		}
+
+		if len(listCompanyPermission) > 0 || detail.RaiPackageType > 0 {
+			continue
+		}
+
+		row := sheet.AddRow()
+		cellADatatitle := row.AddCell()
+		cellADatatitle.Value = v.CompanyName
+
+		cellADataPd := row.AddCell()
+		cellADataPd.Value = fmt.Sprint(v.Points)
+
+		cellCompanyData := row.AddCell()
+		cellCompanyData.Value = fmt.Sprint(v.CompanyId)
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+}

+ 7 - 0
models/company/company.go

@@ -1988,3 +1988,10 @@ func GetOverseasCompanysByCompanyIds(company_id []int) (items []*Company, err er
 	_, err = o.Raw(sql, company_id).QueryRows(&items)
 	return
 }
+
+func GetOverseasCompanysByCompanyIdsInit() (items []*Company, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM company where company_id  IN  (17199,5390,5604,5245,763,5258,5321,17249,141,5248,5255,3539,11641,7149,5575,4096,9163,5349,5597,2656,11497,14090,13337,18600,5314,8127,6405) `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 8 - 0
models/company/company_contract.go

@@ -258,6 +258,14 @@ func GetCompanyContractDetailByCompanyContractId(companyContractId int) (item *C
 	return
 }
 
+// GetCompanyContractDetailByCompanyContractId 根据客户合同id获取合同信息
+func GetCompanyContractDetailByCompanyContractIdInit(companyId int) (item *CompanyContract, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM company_contract WHERE  company_id = ?   AND  product_id = 2   AND status = 1 ORDER BY company_contract_id DESC  LIMIT  1  `
+	err = o.Raw(sql, companyId).QueryRow(&item)
+	return
+}
+
 // GetCompanyContractPermissionListByContractId 根据合同Id获取合同的权限列表
 func GetCompanyContractPermissionListByContractId(companyContractId int) (list []*CompanyContractPermissionName, err error) {
 	o := orm.NewOrm()

+ 17 - 0
models/roadshow/calendar.go

@@ -138,6 +138,23 @@ func GetRsCalendarResearcherListByCalendarResearcherId(rsCalendarResearcherId in
 	return
 }
 
+func GetRsCalendarResearcherListByCalendarResearcherIdInit(companyId int, startDate, endDate string) (item []*RsCalendarResearcher, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.*
+		FROM
+			rs_calendar AS r
+			INNER JOIN rs_calendar_researcher AS a ON r.rs_calendar_id = a.rs_calendar_id 
+		WHERE
+			company_id  = ?
+		  	AND r.sys_user_id IN (SELECT  admin_id  FROM  admin WHERE role_type_code in ('rai_seller','rai_group','rai_admin'))
+			AND status IN ( 1, 2, 6 ) 
+			AND a.start_date >= ? 
+			AND a.start_date <= ? `
+	_, err = o.Raw(sql, companyId, startDate, endDate).QueryRows(&item)
+	return
+}
+
 // 添加RsCalendar
 func AddRsCalendar(item *RsCalendar) (lastId int64, err error) {
 	o := orm.NewOrm()