Quellcode durchsuchen

新增路演统计数量修复

hongze vor 1 Jahr
Ursprung
Commit
5213126568
3 geänderte Dateien mit 114 neuen und 9 gelöschten Zeilen
  1. 65 0
      models/overseas_custom/custom.go
  2. 44 0
      services/overseas_custom/custom.go
  3. 5 9
      services/task.go

+ 65 - 0
models/overseas_custom/custom.go

@@ -0,0 +1,65 @@
+package overseas_custom
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type Custom struct {
+}
+
+type RsCompany struct {
+	CompanyId int
+	Total     int
+}
+
+// EnglishCompany 英文客户
+type EnglishCompany struct {
+	CompanyId      int       `orm:"column(company_id);pk" description:"英文客户ID"`
+	CompanyName    string    `description:"客户名称"`
+	CountryCode    string    `description:"国家Code"`
+	Country        string    `description:"国家"`
+	SellerId       int       `description:"销售ID"`
+	SellerName     string    `description:"销售姓名"`
+	ViewTotal      int       `description:"累计点击量/阅读量"`
+	IsDeleted      int       `description:"删除状态:0-正常;1-已删除"`
+	CreateTime     time.Time `description:"创建时间"`
+	ModifyTime     time.Time `description:"更新时间"`
+	Enabled        int       `description:"0-禁用; 1-启用; 2-部分禁用"`
+	Status         int       `description:"1:正式,2:临时,3:终止"`
+	Nation         string    `description:"所属国家"`
+	IsHide         int       `description:"是否隐藏:0:不隐藏,1:隐藏"`
+	OverseasStatus string    `description:"海外客户状态:'正式','试用','关闭'"`
+	OverseasLabel  int       `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
+	RoadShowTotal  int       `description:"累计路演次数"`
+}
+
+// 获取客户路演数据
+func (obj *Custom) GetRsCompanyTotal() (list []*RsCompany, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT a.company_id,COUNT(1) AS total
+				FROM rs_calendar AS a
+				INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id = b.rs_calendar_id 
+				WHERE
+				a.source = 0 
+				AND b.status = 2 
+				AND a.english_company=1
+				GROUP BY a.company_id`
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+// 获取所有英文客户
+func (obj *Custom) GetEnglishCompanyAll() (list []*EnglishCompany, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM english_company WHERE is_deleted = 0 `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+func (obj *Custom) UpdateRoadShowTotal(companyId, total int) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` UPDATE english_company SET road_show_total=? WHERE company_id=? `
+	_, err = o.Raw(sql, total, companyId).Exec()
+	return
+}

+ 44 - 0
services/overseas_custom/custom.go

@@ -0,0 +1,44 @@
+package overseas_custom
+
+import (
+	"context"
+	"fmt"
+	"hongze/hongze_task/models/overseas_custom"
+)
+
+// 修改英文客户路演统计
+func FixEnglishCompanyRoadShowTotal(cont context.Context) (err error) {
+	obj := new(overseas_custom.Custom)
+	list, err := obj.GetRsCompanyTotal()
+	if err != nil {
+		fmt.Println("GetRsCompanyTotal Err:" + err.Error())
+		return err
+	}
+
+	companyList, err := obj.GetEnglishCompanyAll()
+	if err != nil {
+		fmt.Println("GetEnglishCompanyAll Err:" + err.Error())
+		return err
+	}
+
+	companyMap := make(map[int]int)
+	for _, v := range companyList {
+		companyMap[v.CompanyId] = v.RoadShowTotal
+	}
+
+	for _, v := range list {
+		if v.Total > 0 {
+			if val, ok := companyMap[v.CompanyId]; ok {
+				if val != v.Total {
+					err = obj.UpdateRoadShowTotal(v.CompanyId, v.Total)
+					if err != nil {
+						fmt.Println("UpdateRoadShowTotal Err:" + err.Error())
+						return err
+					}
+				}
+			}
+
+		}
+	}
+	return nil
+}

+ 5 - 9
services/task.go

@@ -12,6 +12,7 @@ import (
 	"hongze/hongze_task/services/data"
 	"hongze/hongze_task/services/data/future_good"
 	"hongze/hongze_task/services/maycur"
+	"hongze/hongze_task/services/overseas_custom"
 	"hongze/hongze_task/services/roadshow"
 	"hongze/hongze_task/utils"
 	"runtime"
@@ -177,20 +178,15 @@ func Task() {
 	etaBusinessUpdateStatus := task.NewTask("etaBusinessUpdateStatus", "0 5 5 * * *", EtaBusinessUpdateStatus)
 	task.AddTask("etaBusinessUpdateStatus", etaBusinessUpdateStatus)
 
+	//修复英文客户路演统计
+	fixEnglishCompanyRoadShowTotal := task.NewTask("fixEnglishCompanyRoadShowTotal", "0 */10 6-23 * * *", overseas_custom.FixEnglishCompanyRoadShowTotal)
+	task.AddTask("英文客户路演统计", fixEnglishCompanyRoadShowTotal)
+
 	task.StartTask()
 
 	fmt.Println("task end")
 }
 
-//func Task() {
-//	fmt.Println("start task")
-//
-//	cont := new(context.Context)
-//	_ = maycur.DailyUpdateCompanyProfile(*cont)
-//
-//	fmt.Println("end task")
-//}
-
 // 生产环境需要走的任务
 func releaseTask() {
 	////隆众调研指标获取