zhangchuanxing 2 месяцев назад
Родитель
Сommit
d15216e00c
2 измененных файлов с 65 добавлено и 3 удалено
  1. 23 3
      controllers/cygx/report_article.go
  2. 42 0
      models/company/company_contract.go

+ 23 - 3
controllers/cygx/report_article.go

@@ -5598,11 +5598,25 @@ func initUserKw() {
 }
 
 func initContract() {
-	listContractList, e := company.CompanyContractList()
+	listContractList, e := company.CompanyContractListInit2()
 	if e != nil {
 		fmt.Println(e)
 		return
 	}
+	var condition string
+	var pars []interface{}
+	activitySpecialPermissionPointsList, e := cygx.GetCygxActivitySpecialPermissionPointsList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	var companyIds []int
+	mapPointSpeial := make(map[int]float64)
+	for _, v := range activitySpecialPermissionPointsList {
+		companyIds = append(companyIds, v.CompanyId)
+		mapPointSpeial[v.CompanyId] += v.Pointsf
+	}
 
 	var companyContractIds []int
 	for _, v := range listContractList {
@@ -5635,7 +5649,7 @@ func initContract() {
 	style.ApplyAlignment = true
 
 	var sheetName string
-	sheetName = "智造升级公司统计"
+	sheetName = "大套餐统计"
 	sheet, err := xlsxFile.AddSheet(sheetName)
 	if err != nil {
 		fmt.Println(err)
@@ -5654,6 +5668,9 @@ func initContract() {
 	cellB10 := rowTitle.AddCell()
 	cellB10.Value = "合同金额"
 
+	cellPoint := rowTitle.AddCell()
+	cellPoint.Value = "调研点数"
+
 	cellB11 := rowTitle.AddCell()
 	cellB11.Value = "签约套餐"
 
@@ -5671,6 +5688,9 @@ func initContract() {
 		cellBData10 := row.AddCell()
 		cellBData10.Value = fmt.Sprint(vE.Money)
 
+		cellBDataPoint := row.AddCell()
+		cellBDataPoint.Value = fmt.Sprint(mapPointSpeial[vE.CompanyId])
+
 		cellBData11 := row.AddCell()
 		cellBData11.Value = mappermissionName[vE.CompanyContractId]
 
@@ -6011,7 +6031,7 @@ func initActZHouqi() {
 }
 
 //func init() {
-//	initPointBill()
+//	initContract()
 //}
 
 // 研选扣点明细,与专项调研明细

+ 42 - 0
models/company/company_contract.go

@@ -60,6 +60,48 @@ WHERE
 	return
 }
 
+// GetCompanyContractPermissionByCompanyContractId 根据合同ID获取开通的权限
+func CompanyContractListInit1() (items []*CompanyContract, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	a.company_name,
+	c.* 
+FROM
+	company_contract AS c
+	INNER JOIN company a ON a.company_id = c.company_id 
+WHERE
+	1 = 1 
+	AND c.company_id IN ( SELECT company_id FROM company_product WHERE 1 = 1 AND status = '正式' AND product_id = 2 ) 
+  	AND c.company_contract_id IN ( SELECT company_contract_id FROM company_contract_permission WHERE is_upgrade = 1 AND end_date > '2025-02-26'  ) 
+	AND c.status = 1
+	AND c.product_id = 2 
+	AND c.end_date > '2025-02-26' 
+`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// GetCompanyContractPermissionByCompanyContractId 根据合同ID获取开通的权限
+func CompanyContractListInit2() (items []*CompanyContract, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	a.company_name,
+	c.* 
+FROM
+	company_contract AS c
+	INNER JOIN company a ON a.company_id = c.company_id 
+WHERE
+	1 = 1 
+	AND c.company_id IN ( SELECT company_id FROM company_product WHERE 1 = 1 AND status = '正式' AND product_id = 2 ) 
+	AND c.status = 1
+	AND c.product_id = 2 
+	AND c.rai_package_type  > 0 
+	AND c.end_date > '2025-02-26' 
+`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 新增客户合同
 func AddCompanyContract(item *CompanyContract) (lastId int64, err error) {
 	o := orm.NewOrm()