xingzai 3 månader sedan
förälder
incheckning
c8fd8675c6
2 ändrade filer med 25 tillägg och 2 borttagningar
  1. 12 1
      models/roadshow/report.go
  2. 13 1
      services/roadshow/report.go

+ 12 - 1
models/roadshow/report.go

@@ -1,8 +1,8 @@
 package roadshow
 
 import (
-	"time"
 	"github.com/beego/beego/v2/client/orm"
+	"time"
 )
 
 type RsReportRecord struct {
@@ -106,6 +106,17 @@ func RsCompanyList() (list []*CompanySearchView, err error) {
 	return
 }
 
+// 权益客户
+func RsCompanyListRai() (list []*CompanySearchView, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT b.company_id,b.company_name,a.credit_code,b.status FROM company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			WHERE b.status IN('正式','试用') AND b.product_id=2 `
+	sql += ` GROUP BY b.company_id  `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
 func GetExistRsReportRecord(endDate string) (list []*RsReportRecord, err error) {
 	sql := ` SELECT * FROM  rs_report_record
 			WHERE end_date>=? `

+ 13 - 1
services/roadshow/report.go

@@ -1,6 +1,7 @@
 package roadshow
 
 import (
+	"context"
 	"errors"
 	"fmt"
 	"hongze/hongze_task/models"
@@ -8,7 +9,6 @@ import (
 	"hongze/hongze_task/utils"
 	"strconv"
 	"time"
-	"context"
 )
 
 func AddReportRecord(cont context.Context) (err error) {
@@ -31,11 +31,23 @@ func AddReportRecord(cont context.Context) (err error) {
 	if err != nil {
 		return
 	}
+
+	companyListRai, err := roadshow.RsCompanyListRai() //权益销售
+	if err != nil {
+		return
+	}
 	companyMap := make(map[int]*roadshow.CompanySearchView)
 	for _, v := range companyList {
 		companyMap[v.CompanyId] = v
 	}
 
+	for _, v := range companyListRai {
+		if companyMap[v.CompanyId] != nil {
+			continue
+		}
+		companyMap[v.CompanyId] = v
+	}
+
 	endDate := time.Now().AddDate(-1, 0, 0).Format(utils.FormatDate)
 
 	existList, err := roadshow.GetExistRsReportRecord(endDate)