longyu 2 жил өмнө
parent
commit
824969aa5f
83 өөрчлөгдсөн 877 нэмэгдсэн , 710 устгасан
  1. 1 1
      models/admin.go
  2. 14 27
      models/classify.go
  3. 1 1
      models/company.go
  4. 37 28
      models/company/company.go
  5. 1 1
      models/company_approval.go
  6. 1 1
      models/company_approval/company_approval.go
  7. 1 1
      models/company_contract/company_contract.go
  8. 1 1
      models/company_end_date.go
  9. 1 1
      models/company_permission_log.go
  10. 4 4
      models/company_product.go
  11. 1 1
      models/company_product_update_log.go
  12. 1 1
      models/company_report_permission.go
  13. 1 1
      models/company_report_permission_log.go
  14. 57 0
      models/company_report_record.go
  15. 1 1
      models/company_view_statistics.go
  16. 5 9
      models/data_entry.go
  17. 13 25
      models/data_manage/base_from_smm.go
  18. 4 7
      models/data_manage/chart_info.go
  19. 2 3
      models/data_manage/edb_data_base.go
  20. 7 13
      models/data_manage/edb_data_calculate.go
  21. 2 3
      models/data_manage/edb_data_calculate_ljztbpj.go
  22. 19 16
      models/data_manage/edb_data_calculate_time_shift.go
  23. 2 3
      models/data_manage/edb_data_calculate_zjpj.go
  24. 25 28
      models/data_manage/edb_data_cffex.go
  25. 25 28
      models/data_manage/edb_data_dl.go
  26. 14 16
      models/data_manage/edb_data_gl.go
  27. 12 18
      models/data_manage/edb_data_lt.go
  28. 11 16
      models/data_manage/edb_data_lz.go
  29. 14 17
      models/data_manage/edb_data_manual.go
  30. 6 11
      models/data_manage/edb_data_pb.go
  31. 2 3
      models/data_manage/edb_data_quarter.go
  32. 25 28
      models/data_manage/edb_data_sh.go
  33. 25 28
      models/data_manage/edb_data_shfe.go
  34. 5 9
      models/data_manage/edb_data_ths.go
  35. 6 11
      models/data_manage/edb_data_wind.go
  36. 3 5
      models/data_manage/edb_data_ys.go
  37. 24 27
      models/data_manage/edb_data_zz.go
  38. 12 23
      models/data_manage/edb_info.go
  39. 10 9
      models/data_manage/edb_info_calculate_bp.go
  40. 10 9
      models/data_manage/edb_info_calculate_hbz.go
  41. 10 9
      models/data_manage/edb_info_calculate_hcz.go
  42. 12 10
      models/data_manage/edb_info_calculate_ljztbpj.go
  43. 12 13
      models/data_manage/edb_info_calculate_ljzzy.go
  44. 12 13
      models/data_manage/edb_info_calculate_mapping.go
  45. 12 13
      models/data_manage/edb_info_calculate_nszydpjjs.go
  46. 12 13
      models/data_manage/edb_info_calculate_tbz.go
  47. 12 13
      models/data_manage/edb_info_calculate_tcz.go
  48. 9 7
      models/data_manage/edb_info_calculate_zjpj.go
  49. 35 69
      models/data_source_longzhong.go
  50. 2 1
      models/db.go
  51. 2 3
      models/edbdata.go
  52. 5 9
      models/edbdata_classify.go
  53. 2 3
      models/edbinfo_longzhong.go
  54. 3 5
      models/edbinfo_send_msg_record.go
  55. 42 22
      models/free_viewer.go
  56. 3 5
      models/longzhong.go
  57. 10 13
      models/report.go
  58. 1 1
      models/report_send_ths_detail.go
  59. 2 3
      models/report_view.go
  60. 1 1
      models/roadshow/calendar.go
  61. 1 1
      models/roadshow/public_meeting.go
  62. 1 1
      models/roadshow/report.go
  63. 1 1
      models/stack_company_statistic.go
  64. 4 7
      models/user_view_statistics.go
  65. 1 1
      models/users.go
  66. 1 1
      models/wechat.go
  67. 1 1
      models/wx_template_msg.go
  68. 1 1
      models/yb/activity.go
  69. 1 1
      models/yb/activity_register.go
  70. 1 1
      models/yb/activity_remind.go
  71. 1 1
      models/yb/activity_type.go
  72. 1 1
      models/yb/activity_voice.go
  73. 1 1
      models/yb/yb_speaker.go
  74. 29 0
      services/alarm_msg/alarm_msg.go
  75. 76 0
      services/company/company_report_record.go
  76. 31 14
      services/data/edb_info.go
  77. 24 5
      services/free_viewer.go
  78. 70 3
      services/report_push.go
  79. 1 1
      services/roadshow/company_product.go
  80. 4 2
      services/roadshow/report.go
  81. 10 3
      services/task.go
  82. 9 0
      utils/constants.go
  83. 2 2
      utils/email.go

+ 1 - 1
models/admin.go

@@ -1,6 +1,6 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import "github.com/beego/beego/v2/client/orm"
 
 type Admin struct {
 	AdminId      int

+ 14 - 27
models/classify.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
@@ -42,39 +42,34 @@ type ClassifyAddReq struct {
 
 func GetClassifyByName(classifyName string, parentId int) (item *Classify, err error) {
 	sql := `SELECT * FROM classify WHERE classify_name=? AND parent_id=? `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	err = o.Raw(sql, classifyName, parentId).QueryRow(&item)
 	return
 }
 
 func GetClassifyById(classifyId int) (item *Classify, err error) {
 	sql := `SELECT * FROM classify WHERE id=? `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	err = o.Raw(sql, classifyId).QueryRow(&item)
 	return
 }
 
 //添加分类
 func AddClassify(item *Classify) (err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Insert(item)
 	return
 }
 
 func GetReportCountByClassifyId(classifyId int) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT COUNT(1) AS count FROM report WHERE classify_id_second=? `
 	err = o.Raw(sql, classifyId).QueryRow(&count)
 	return
 }
 
 func GetClassifySubCountByClassifyId(classifyId int) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT COUNT(1) as num FROM classify AS a
         INNER JOIN report AS b ON a.id=b.classify_id_second
         WHERE a.parent_id=? `
@@ -86,8 +81,7 @@ func GetClassifySubCountByParentId(classifyId int) (count int, err error) {
 	sqlCount := `
 	SELECT COUNT(1) as num FROM classify AS a
 	WHERE a.parent_id=? `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	err = o.Raw(sqlCount, classifyId).QueryRow(&count)
 	return
 }
@@ -95,8 +89,7 @@ func GetClassifySubCountByParentId(classifyId int) (count int, err error) {
 //删除分类
 func DeleteClassify(classifyId int) (err error) {
 	sql := `DELETE FROM classify WHERE id=? `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql, classifyId).Exec()
 	if err != nil {
 		return
@@ -109,8 +102,7 @@ func DeleteClassify(classifyId int) (err error) {
 //classifyName, abstract, descript string, parentId, classifyId int
 //修改分类
 func EditClassify(req *EditClassifyReq) (err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := `UPDATE classify SET classify_name = ?,abstract=?, parent_id= ?,descript=?,report_author=?,author_descript=?,column_img_url=?,head_img_url=?,avatar_img_url=?,report_img_url=?,home_img_url=?,classify_label=?, modify_time= NOW() WHERE id = ? `
 	_, err = o.Raw(sql, req.ClassifyName, req.Abstract, req.ParentId, req.Descript, req.ReportAuthor, req.AuthorDescript, req.ColumnImgUrl, req.HeadImgUrl, req.AvatarImgUrl, req.ReportImgUrl, req.HomeImgUrl, req.ClassifyLabel, req.ClassifyId).Exec()
 	return
@@ -120,8 +112,7 @@ func EditClassify(req *EditClassifyReq) (err error) {
 
 func ParentClassify() (items []*Classify, err error) {
 	sql := `SELECT * FROM classify WHERE parent_id=0 order by id desc `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -129,8 +120,7 @@ func ParentClassify() (items []*Classify, err error) {
 //根据id获取分类详情
 func FindByIdClassify(classifyId int) (item *Classify, err error) {
 	sql := `SELECT * FROM classify WHERE id=? `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	err = o.Raw(sql, classifyId).QueryRow(&item)
 	return
 }
@@ -176,8 +166,7 @@ func GetClassifyList(startSize, pageSize int, keyWord, companyType string) (item
 	} else {
 		sql = `SELECT * FROM classify WHERE parent_id=0 ` + companyTypeSqlStr + ` ORDER BY create_time ASC LIMIT ?,? `
 	}
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
 	return
 }
@@ -204,8 +193,7 @@ func GetClassifyListCount(keyWord, companyType string) (count int, err error) {
 	} else {
 		sqlCount = `SELECT COUNT(1) AS count FROM classify WHERE parent_id=0 ` + companyTypeSqlStr
 	}
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	err = o.Raw(sqlCount).QueryRow(&count)
 	return
 }
@@ -244,8 +232,7 @@ type FindByIdClassifyReq struct {
 }
 
 func GetClassifyChild(parentId int, keyWord string) (items []*Classify, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := ``
 	if keyWord != "" {
 		sql = `SELECT * FROM classify WHERE parent_id=? AND classify_name LIKE '%` + keyWord + `%' ORDER BY create_time ASC `

+ 1 - 1
models/company.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 37 - 28
models/company/company.go

@@ -1,7 +1,7 @@
 package company
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/models"
 	"hongze/hongze_task/models/company_contract"
 	"hongze/hongze_task/utils"
@@ -11,21 +11,24 @@ import (
 // TryOutToFormal 试用转正式
 func TryOutToFormal(companyId, productId, sellerId, companyContractId int, startDate, endDate, sellerName, productName string, packageType int) (err error) {
 	o := orm.NewOrm()
-	o.Begin()
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
-	sql := `UPDATE company_product SET status='正式',is_suspend=0,start_date=?,end_date=?,package_type=?,modify_time=NOW(),formal_time=NOW() WHERE company_id=? AND product_id=? `
-	_, err = o.Raw(sql, startDate, endDate, packageType, companyId, productId).Exec()
+	sql := `UPDATE company_product SET status='正式',renewal_intention=0,is_suspend=0,is_formal=1,start_date=?,end_date=?,package_type=?,modify_time=NOW(),formal_time=NOW(),try_stage=1 WHERE company_id=? AND product_id=? `
+	_, err = tx.Raw(sql, startDate, endDate, packageType, companyId, productId).Exec()
 	if err != nil {
 		return
 	}
 	sql = `UPDATE company SET type=1,last_updated_time=NOW() WHERE company_id=? `
-	_, err = o.Raw(sql, companyId).Exec()
+	_, err = tx.Raw(sql, companyId).Exec()
 	if err != nil {
 		return
 	}
@@ -47,14 +50,14 @@ func TryOutToFormal(companyId, productId, sellerId, companyContractId int, start
 	}
 
 	sql = `DELETE FROM company_report_permission WHERE company_id=? AND product_id=?`
-	_, err = o.Raw(sql, companyId, productId).Exec()
+	_, err = tx.Raw(sql, companyId, productId).Exec()
 	if err != nil {
 		return
 	}
 
 	contractPermission := make([]*models.CompanyReportPermission, 0)
 	sql = `SELECT * FROM company_contract_permission WHERE company_contract_id=? AND company_id=? `
-	_, err = o.Raw(sql, companyContractId, companyId).QueryRows(&contractPermission)
+	_, err = tx.Raw(sql, companyContractId, companyId).QueryRows(&contractPermission)
 	if err != nil {
 		return
 	}
@@ -62,7 +65,7 @@ func TryOutToFormal(companyId, productId, sellerId, companyContractId int, start
 		sql = `INSERT INTO company_report_permission(company_id, report_permission_id,created_time, last_updated_time,
              chart_permission_id, start_date,end_date,product_id,product_name, modify_time,company_contract_id,status) 
 			VALUES(?,?,NOW(),NOW(),?,?,?,?,?,NOW(),?,?) `
-		_, err = o.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
+		_, err = tx.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
 		if err != nil {
 			return
 		}
@@ -73,17 +76,20 @@ func TryOutToFormal(companyId, productId, sellerId, companyContractId int, start
 //服务更新
 func ApplyServiceUpdateOld(companyId, productId, sellerId, companyContractId int, startDate, endDate, sellerName, productName string) (err error) {
 	o := orm.NewOrm()
-	o.Begin()
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
-	sql := `UPDATE company_product SET status='正式',start_date=?,end_date=?,modify_time=NOW() WHERE company_id=? AND product_id=? `
-	_, err = o.Raw(sql, startDate, endDate, companyId, productId).Exec()
+	sql := `UPDATE company_product SET status='正式',start_date=?,end_date=?,modify_time=NOW(),try_stage=1 WHERE company_id=? AND product_id=? `
+	_, err = tx.Raw(sql, startDate, endDate, companyId, productId).Exec()
 	if err != nil {
 		return
 	}
@@ -91,7 +97,7 @@ func ApplyServiceUpdateOld(companyId, productId, sellerId, companyContractId int
 	//合同权限变更
 	items := make([]*models.CompanyReportPermission, 0)
 	sql = `SELECT * FROM company_report_permission WHERE company_id=? AND product_id=? `
-	_, err = o.Raw(sql, companyId, productId).QueryRows(&items)
+	_, err = tx.Raw(sql, companyId, productId).QueryRows(&items)
 	if err != nil {
 		return
 	}
@@ -109,14 +115,14 @@ func ApplyServiceUpdateOld(companyId, productId, sellerId, companyContractId int
 		go models.AddCompanyPermissionLog(cpLog)
 	}
 	sql = `DELETE FROM company_report_permission WHERE company_id=? AND product_id=? `
-	_, err = o.Raw(sql, companyId, productId).Exec()
+	_, err = tx.Raw(sql, companyId, productId).Exec()
 	if err != nil {
 		return
 	}
 
 	contractPermission := make([]*models.CompanyReportPermission, 0)
 	sql = `SELECT * FROM company_contract_permission WHERE company_contract_id=? AND company_id=? `
-	_, err = o.Raw(sql, companyContractId, companyId).QueryRows(&contractPermission)
+	_, err = tx.Raw(sql, companyContractId, companyId).QueryRows(&contractPermission)
 	if err != nil {
 		return
 	}
@@ -124,7 +130,7 @@ func ApplyServiceUpdateOld(companyId, productId, sellerId, companyContractId int
 		sql = `INSERT INTO company_report_permission(company_id, report_permission_id,created_time, last_updated_time,
              chart_permission_id, start_date,end_date,product_id,product_name, modify_time,company_contract_id,status) 
 			VALUES(?,?,NOW(),NOW(),?,?,?,?,?,NOW(),?,?) `
-		_, err = o.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
+		_, err = tx.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
 		if err != nil {
 			return
 		}
@@ -134,19 +140,22 @@ func ApplyServiceUpdateOld(companyId, productId, sellerId, companyContractId int
 
 func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, startDate, endDate, sellerName, productName string, packageType int) (err error) {
 	o := orm.NewOrm()
-	o.Begin()
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
 	//合同权限变更
 	items := make([]*models.CompanyReportPermission, 0)
 	sql := `SELECT * FROM company_report_permission WHERE company_id=? AND product_id=? `
-	_, err = o.Raw(sql, companyId, productId).QueryRows(&items)
+	_, err = tx.Raw(sql, companyId, productId).QueryRows(&items)
 	if err != nil {
 		return
 	}
@@ -210,15 +219,15 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 	//}
 
 	//更新客户产品信息
-	sql = `UPDATE company_product SET status='正式',is_suspend=0,start_date=?,end_date=?,package_type=?,modify_time=NOW() WHERE company_id=? AND product_id=? `
-	_, err = o.Raw(sql, updateStartDateTime, updateEndDateTime, packageType, companyId, productId).Exec()
+	sql = `UPDATE company_product SET status='正式',is_formal=1,is_suspend=0,start_date=?,end_date=?,package_type=?,modify_time=NOW(),try_stage=1 WHERE company_id=? AND product_id=? `
+	_, err = tx.Raw(sql, updateStartDateTime, updateEndDateTime, packageType, companyId, productId).Exec()
 	if err != nil {
 		return
 	}
 
 	contractPermission := make([]*company_contract.CompanyContractPermission, 0)
 	sql = `SELECT * FROM company_contract_permission WHERE company_contract_id=? AND company_id=? `
-	_, err = o.Raw(sql, companyContractId, companyId).QueryRows(&contractPermission)
+	_, err = tx.Raw(sql, companyContractId, companyId).QueryRows(&contractPermission)
 	if err != nil {
 		return
 	}
@@ -253,7 +262,7 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 			//如果 需要更新 字段 为 true,那么就去更新
 			if needUpdate {
 				sql = `update company_report_permission set end_date=?,last_updated_time=now(),modify_time=now(),company_contract_id=?,status=? where company_report_permission_id=? `
-				_, tmpErr := o.Raw(sql, pv.EndDate, companyContractId, "正式", nowPermission.CompanyReportPermissionId).Exec()
+				_, tmpErr := tx.Raw(sql, pv.EndDate, companyContractId, "正式", nowPermission.CompanyReportPermissionId).Exec()
 				err = tmpErr
 				if err != nil {
 					return
@@ -264,7 +273,7 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 			sql = `INSERT INTO company_report_permission(company_id, report_permission_id,created_time, last_updated_time,
              chart_permission_id, start_date,end_date,product_id,product_name, modify_time,company_contract_id,status) 
 			VALUES(?,?,NOW(),NOW(),?,?,?,?,?,NOW(),?,?) `
-			_, tmpErr := o.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
+			_, tmpErr := tx.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
 			err = tmpErr
 			if err != nil {
 				return

+ 1 - 1
models/company_approval.go

@@ -1,6 +1,6 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import "github.com/beego/beego/v2/client/orm"
 
 func GetCompanyApprovalCount(companyId int,productId int) (count int, err error) {
 	sql:=`SELECT COUNT(1) AS count FROM company_approval WHERE company_id = ? AND product_id = ?  AND approve_status='待审批' `

+ 1 - 1
models/company_approval/company_approval.go

@@ -1,7 +1,7 @@
 package company_approval
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/company_contract/company_contract.go

@@ -1,7 +1,7 @@
 package company_contract
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/company_end_date.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/company_permission_log.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 4 - 4
models/company_product.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
 	"time"
 )
@@ -42,7 +42,7 @@ func CompanyFreeze(companyId, productId int) (companyReportPermissionList []*Com
 	}
 
 	//客户产品 状态 变更
-	sql := `UPDATE company_product SET status='冻结',is_formal=0,is_suspend=0,freeze_time=NOW(),modify_time=NOW(),start_date=?,end_date=?,freeze_start_date=?,freeze_end_date=? WHERE company_id=? AND product_id=? `
+	sql := `UPDATE company_product SET status='冻结',is_formal=0,is_suspend=0,freeze_time=NOW(),modify_time=NOW(),start_date=?,end_date=?,freeze_start_date=?,freeze_end_date=?,try_stage=1 WHERE company_id=? AND product_id=? `
 	_, err = o.Raw(sql, freezeStartDate, freezeEndDate, freezeStartDate, freezeEndDate, companyId, productId).Exec()
 	if err != nil {
 		return
@@ -77,7 +77,7 @@ func CompanyFreeze(companyId, productId int) (companyReportPermissionList []*Com
 func CompanyLoss(companyId, productId int) (err error) {
 	o := orm.NewOrm()
 	//客户产品状态变更
-	sql := `UPDATE company_product SET status='流失',is_formal=0,loss_time=NOW(),modify_time=NOW(),lose_reason='冻结到期系统自动流失' WHERE company_id=? AND product_id=? `
+	sql := `UPDATE company_product SET status='流失',is_formal=0,loss_time=NOW(),modify_time=NOW(),lose_reason='冻结到期系统自动流失',try_stage=1 WHERE company_id=? AND product_id=? `
 	_, err = o.Raw(sql, companyId, productId).Exec()
 	if err != nil {
 		return
@@ -99,7 +99,7 @@ func CompanyTryOut(companyId, productId int) (companyReportPermissionList []*Com
 	endDate := time.Now().AddDate(0, 2, 0).Format(utils.FormatDate)
 
 	//客户产品 状态 变更
-	sql := `UPDATE company_product SET status='试用',start_date=?,end_date=?,modify_time=NOW(),try_out_time=NOW(),renewal_reason="",package_type=0 WHERE company_id=? AND product_id=? `
+	sql := `UPDATE company_product SET status='试用',start_date=?,end_date=?,modify_time=NOW(),try_out_time=NOW(),renewal_reason="",package_type=0,try_stage=1 WHERE company_id=? AND product_id=? `
 	_, err = o.Raw(sql, startDate, endDate, companyId, productId).Exec()
 	if err != nil {
 		return

+ 1 - 1
models/company_product_update_log.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/company_report_permission.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
 	"time"
 )

+ 1 - 1
models/company_report_permission_log.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 57 - 0
models/company_report_record.go

@@ -0,0 +1,57 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CompanyReportRecord struct {
+	CompanyReportRecordId int `orm:"column(company_report_record_id);pk"`
+	CompanyId             int
+	CompanyProductId      int
+	CompanyName           string
+	Status                string
+	StartDate             string
+	EndDate               string
+	SellerId              int
+	SellerName            string
+	CreditCode            string
+	CreateDate            string
+	CreateTime            time.Time
+	ModifyTime            time.Time
+}
+
+func AddCompanyReportRecord(item *CompanyReportRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+func GetExistCompanyReportRecord(endDate string) (list []*CompanyReportRecord, err error) {
+	sql := ` SELECT * FROM  company_report_record WHERE create_date>=? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, endDate).QueryRows(&list)
+	return
+}
+
+func GetCompanyList(endDate string) (list []*CompanyReportRecord, err error) {
+	sql := ` SELECT a.company_id,a.company_name,a.credit_code,b.status,b.start_date,b.end_date,b.seller_id,b.seller_name,b.company_product_id
+			FROM  company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			WHERE b.product_id=1`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+// 更新客户报告记录信息
+func UpdateCompanyReportRecord(where, updateParams map[string]interface{}) error {
+	o := orm.NewOrm()
+	ptrStructOrTableName := "company_report_record"
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range where {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err := qs.Update(updateParams)
+	return err
+}

+ 1 - 1
models/company_view_statistics.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 5 - 9
models/data_entry.go

@@ -1,6 +1,6 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import "github.com/beego/beego/v2/client/orm"
 
 //数据录入
 
@@ -15,8 +15,7 @@ type EdbInfo struct {
 //获取日度指标
 func GetEdbInfoByFrequency(frequency string) (items []*EdbInfo, err error) {
 	sql := `SELECT * FROM edbinfo WHERE frequency=? AND notice_time<>'' `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, frequency).QueryRows(&items)
 	return
 }
@@ -24,16 +23,14 @@ func GetEdbInfoByFrequency(frequency string) (items []*EdbInfo, err error) {
 //获取日度指标
 func GetEdbInfoByFrequencyWeek(frequency, weekDay string) (items []*EdbInfo, err error) {
 	sql := `SELECT * FROM edbinfo WHERE frequency=? AND notice_time<>'' AND left(notice_time,2)=? `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, frequency, weekDay).QueryRows(&items)
 	return
 }
 
 func GetEdbdataCount(tradeCode, nowDate string) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM edbdata WHERE TRADE_CODE=? AND DT=? `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	err = o.Raw(sql, tradeCode, nowDate).QueryRow(&count)
 	return
 }
@@ -41,8 +38,7 @@ func GetEdbdataCount(tradeCode, nowDate string) (count int, err error) {
 // GetEdbInfoByFrequencyNotDay 获取频度非日度 且 提醒时间不为空 的指标数据
 func GetEdbInfoByFrequencyNotDay() (items []*EdbInfo, err error) {
 	sql := `SELECT * FROM edbinfo WHERE frequency!="日度" AND notice_time<>'' and user_id>0 `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 13 - 25
models/data_manage/base_from_smm.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -34,15 +34,13 @@ type BaseFromSmm struct {
 }
 
 func AddBaseFromSmm(item *BaseFromSmm) (lastId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	lastId, err = o.Insert(item)
 	return
 }
 
 func GetBaseFromSmmList() (list []*BaseFromSmm, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	//sql := `SELECT * FROM base_from_smm WHERE interface='cu_annual_copper_cathode_demand_supply_balance_in_china' `
 	sql := `SELECT * FROM base_from_smm WHERE end_date IS NOT NULL `
 	_, err = o.Raw(sql).QueryRows(&list)
@@ -69,15 +67,13 @@ type BaseFromSmmIndex struct {
 }
 
 func AddBaseFromSmmIndex(item *BaseFromSmmIndex) (lastId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	lastId, err = o.Insert(item)
 	return
 }
 
 func GetBaseFromSmmIndex() (list []*BaseFromSmmIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_smm_index `
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
@@ -95,39 +91,34 @@ type BaseFromSmmData struct {
 }
 
 func AddBaseFromSmmData(item *BaseFromSmmData) (lastId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	lastId, err = o.Insert(item)
 	return
 }
 
 func GetBaseFromSmmDataAll(indexCode string) (list []*BaseFromSmmData, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_smm_data WHERE index_code=?`
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
 	return
 }
 
 func ModifyBaseFromSmmData(smmDataId int, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `UPDATE base_from_smm_data SET value=?,modify_time=NOW() WHERE smm_data_id=? `
 	_, err = o.Raw(sql, value, smmDataId).Exec()
 	return
 }
 
 func GetBaseFromSmmIndexByCode(smmCode string) (list []*BaseFromSmmIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM base_from_smm_index WHERE interface=? `
 	_, err = o.Raw(sql, smmCode).QueryRows(&list)
 	return
 }
 
 func GetBaseFromSmmMaxOrMinDate(indexCode string) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM base_from_smm_data WHERE index_code=? `
 	err = o.Raw(sql, indexCode).QueryRow(&min_date, &max_date)
 	return
@@ -135,16 +126,14 @@ func GetBaseFromSmmMaxOrMinDate(indexCode string) (min_date, max_date string, er
 
 
 func ModifyBaseFromSmmSmmType(baseFromSmmId int, smmType string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE base_from_smm SET smm_type=? WHERE base_from_smm_id=? `
 	_, err = o.Raw(sql, smmType, baseFromSmmId).Exec()
 	return
 }
 
 func ModifyBaseFromSmmMinDateAndMaxDate(baseFromSmmIndexId, baseFromSmmId int, minDate, maxDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE base_from_smm_index SET start_date=?,end_date=?,modify_time=NOW() WHERE base_from_smm_index_id=? `
 	_, err = o.Raw(sql, minDate, maxDate, baseFromSmmIndexId).Exec()
 	sql = ` UPDATE base_from_smm SET start_date=?,end_date=?,modify_time=NOW() WHERE base_from_smm_id=? `
@@ -161,8 +150,7 @@ type BaseFromSmmDataSimple struct {
 }
 
 func GetBaseFromSmmDataByCondition(condition string, pars []interface{}) (list []*BaseFromSmmDataSimple, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_smm_data WHERE 1=1 `
 	if condition!="" {
 		sql+=condition

+ 4 - 7
models/data_manage/chart_info.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -29,16 +29,14 @@ type ChartInfo struct {
 }
 
 func GetAllChartInfo() (list []*ChartInfo, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM chart_info  `
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
 
 func GetChartInfoEdbEndDate() (list []*ChartInfo, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,max(c.end_date) AS edb_end_date FROM  chart_info  AS a
 			INNER JOIN chart_edb_mapping AS b ON a.chart_info_id=b.chart_info_id
 			INNER JOIN edb_info AS c ON b.edb_info_id=c.edb_info_id
@@ -48,8 +46,7 @@ func GetChartInfoEdbEndDate() (list []*ChartInfo, err error) {
 }
 
 func ModifyChartInfoEdbEndDate(chartInfoId int, edbEndDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE chart_info SET edb_end_date=? WHERE chart_info_id=? `
 	_, err = o.Raw(sql, edbEndDate, chartInfoId).Exec()
 	return

+ 2 - 3
models/data_manage/edb_data_base.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"errors"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
 	"strconv"
 	"time"
@@ -106,8 +106,7 @@ func GetAddSql(edbInfoId, edbCode, dataTime, timestampStr, value string) (addSql
 }
 
 func GetEdbDataBaseByCodeAndDate(source int, edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	tableName := GetEdbDataTableName(source)
 	sql := ` SELECT COUNT(1) AS count FROM %s WHERE edb_code=? AND data_time=? `
 	sql = fmt.Sprintf(sql, tableName)

+ 7 - 13
models/data_manage/edb_data_calculate.go

@@ -2,37 +2,33 @@ package data_manage
 
 import (
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
 func GetEdbDataCalculateByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataCalculate(edbInfoId int64, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_calculate SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return
 }
 
 func AddEdbDataCalculateBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
 
 // DeleteEdbDataCalculateBySql 根据删除sql删除指标数据
 func DeleteEdbDataCalculateBySql(deleteStr string, edbInfoId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(deleteStr, edbInfoId).Exec()
 	return
 }
@@ -55,8 +51,7 @@ type EdbInfoCalculateDetail struct {
 }
 
 func GetEdbInfoCalculateDetail(edbInfoId int) (list []*EdbInfoCalculateDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? ORDER BY sort ASC `
@@ -65,8 +60,7 @@ func GetEdbInfoCalculateDetail(edbInfoId int) (list []*EdbInfoCalculateDetail, e
 }
 
 func GetEdbInfoCalculateMap(edbInfoId, source int) (list []*EdbInfoCalculateDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 
 	calculateTableName := GetEdbInfoCalculateTableName(source)
 	sql := ` SELECT a.*,b.start_date,b.end_date,b.edb_type FROM %s AS a

+ 2 - 3
models/data_manage/edb_data_calculate_ljztbpj.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -20,8 +20,7 @@ type EdbDataCalculateLjztbpj struct {
 
 // GetAllEdbDataCalculateLjztbpjByEdbInfoId 根据指标id获取全部的数据
 func GetAllEdbDataCalculateLjztbpjByEdbInfoId(edbInfoId int) (items []*EdbDataCalculateLjztbpj, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_data_calculate_ljztbpj WHERE edb_info_id=? ORDER BY data_time DESC `
 	_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
 	return

+ 19 - 16
models/data_manage/edb_data_calculate_time_shift.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -29,14 +29,16 @@ type EdbInfoCalculateMove struct {
 
 //变频
 func RefreshCalculateTimeShift(edbInfoId, formulaInt, moveType int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate, moveFrequency string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err != nil {
+		return
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -103,7 +105,7 @@ func RefreshCalculateTimeShift(edbInfoId, formulaInt, moveType int, fromEdbInfo
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -129,8 +131,7 @@ type EdbInfoCalculateTimeShiftDetail struct {
 }
 
 func GetEdbInfoCalculateTimeShiftDetail(edbInfoId int) (item *EdbInfoCalculateTbzDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
@@ -140,14 +141,16 @@ func GetEdbInfoCalculateTimeShiftDetail(edbInfoId int) (item *EdbInfoCalculateTb
 
 //刷新所有变频数据
 func RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, moveType int, fromEdbInfo *EdbInfo, edbCode, moveFrequency string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -241,7 +244,7 @@ func RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, moveType int, f
 				if existVal != valStr {
 					sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 					sql = fmt.Sprintf(sql, dataTableName)
-					_, err = o.Raw(sql, valStr, edbInfoId, newDate.Format(utils.FormatDate)).Exec()
+					_, err = tx.Raw(sql, valStr, edbInfoId, newDate.Format(utils.FormatDate)).Exec()
 					if err != nil {
 						return err
 					}
@@ -253,7 +256,7 @@ func RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, moveType int, f
 
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}

+ 2 - 3
models/data_manage/edb_data_calculate_zjpj.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -20,8 +20,7 @@ type EdbDataCalculateZjpj struct {
 
 // GetAllEdbDataCalculateZjpjByEdbInfoId 根据指标id获取全部的数据
 func GetAllEdbDataCalculateZjpjByEdbInfoId(edbInfoId int) (items []*EdbDataCalculateZjpj, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_data_calculate_zjpj WHERE edb_info_id=? ORDER BY data_time DESC `
 	_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
 	return

+ 25 - 28
models/data_manage/edb_data_cffex.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,8 +58,7 @@ type BaseFromTradeCFFEXIndex struct {
 }
 
 func GetEdbDataCffexMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_cffex WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
 	return
@@ -68,14 +67,16 @@ func GetEdbDataCffexMaxOrMinDate(edbCode string) (minDate, maxDate string, err e
 
 // RefreshEdbDataByCffex 刷新中金所指标数据
 func RefreshEdbDataByCffex(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -160,7 +161,7 @@ func RefreshEdbDataByCffex(edbInfoId int, edbCode, startDate, endDate string) (e
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -170,14 +171,16 @@ func RefreshEdbDataByCffex(edbInfoId int, edbCode, startDate, endDate string) (e
 
 // RefreshAllEdbDataByCffex 全部刷新中金所
 func RefreshAllEdbDataByCffex(edbInfoId, source int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -266,7 +269,7 @@ func RefreshAllEdbDataByCffex(edbInfoId, source int, edbCode, startDate, endDate
 					if existVal != saveValue {
 						sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 						sql = fmt.Sprintf(sql, dataTableName)
-						_, err = o.Raw(sql, sValue, edbInfoId, eDate).Exec()
+						_, err = tx.Raw(sql, sValue, edbInfoId, eDate).Exec()
 						if err != nil {
 							return err
 						}
@@ -278,7 +281,7 @@ func RefreshAllEdbDataByCffex(edbInfoId, source int, edbCode, startDate, endDate
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -288,8 +291,7 @@ func RefreshAllEdbDataByCffex(edbInfoId, source int, edbCode, startDate, endDate
 
 // GetBaseInfoFromCffexByIndexCode 获取指标信息
 func GetBaseInfoFromCffexByIndexCode(indexCode, suffix string) (list []*BaseInfoFromCffex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_cffex_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -298,8 +300,7 @@ func GetBaseInfoFromCffexByIndexCode(indexCode, suffix string) (list []*BaseInfo
 
 func GetCffexDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromCffexDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_cffex_index WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -309,15 +310,13 @@ func GetCffexDataByTradeCode(condition string, pars []interface{}) (item []*Base
 }
 
 func AddEdbDataCffexBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
 
 func GetBaseFromCffexDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeCFFEXIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_cffex_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -325,16 +324,14 @@ func GetBaseFromCffexDataAllByIndexCode(indexCode, suffix string) (list []*BaseF
 }
 
 func GetEdbDataCffexByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_cffex WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataCffex(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_cffex SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 25 - 28
models/data_manage/edb_data_dl.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,8 +58,7 @@ type BaseFromTradeDalianIndex struct {
 }
 
 func GetEdbDataDlMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_dl WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
 	return
@@ -68,14 +67,16 @@ func GetEdbDataDlMaxOrMinDate(edbCode string) (minDate, maxDate string, err erro
 
 // RefreshEdbDataByDl 刷新大商所指标数据
 func RefreshEdbDataByDl(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -160,7 +161,7 @@ func RefreshEdbDataByDl(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -170,14 +171,16 @@ func RefreshEdbDataByDl(edbInfoId int, edbCode, startDate, endDate string) (err
 
 // RefreshAllEdbDataByDl 全部刷新大商所
 func RefreshAllEdbDataByDl(edbInfoId, source int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -266,7 +269,7 @@ func RefreshAllEdbDataByDl(edbInfoId, source int, edbCode, startDate, endDate st
 					if existVal != saveValue {
 						sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 						sql = fmt.Sprintf(sql, dataTableName)
-						_, err = o.Raw(sql, sValue, edbInfoId, eDate).Exec()
+						_, err = tx.Raw(sql, sValue, edbInfoId, eDate).Exec()
 						if err != nil {
 							return err
 						}
@@ -278,7 +281,7 @@ func RefreshAllEdbDataByDl(edbInfoId, source int, edbCode, startDate, endDate st
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -288,8 +291,7 @@ func RefreshAllEdbDataByDl(edbInfoId, source int, edbCode, startDate, endDate st
 
 // GetBaseInfoFromDalianByIndexCode 获取指标信息
 func GetBaseInfoFromDalianByIndexCode(indexCode, suffix string) (list []*BaseInfoFromDl, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_dalian_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -298,8 +300,7 @@ func GetBaseInfoFromDalianByIndexCode(indexCode, suffix string) (list []*BaseInf
 
 func GetDlDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromDlDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_dalian_index WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -309,16 +310,14 @@ func GetDlDataByTradeCode(condition string, pars []interface{}) (item []*BaseFro
 }
 
 func AddEdbDataDlBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
 
 
 func GetBaseFromDalianDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeDalianIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_dalian_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -326,16 +325,14 @@ func GetBaseFromDalianDataAllByIndexCode(indexCode, suffix string) (list []*Base
 }
 
 func GetEdbDataDlByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_dl WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataDl(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_dl SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 14 - 16
models/data_manage/edb_data_gl.go

@@ -2,7 +2,7 @@ package data_manage
 
 import (
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
 	"strconv"
 	"strings"
@@ -10,8 +10,7 @@ import (
 )
 
 func AddEdbDataGlBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
@@ -23,8 +22,7 @@ type GlData struct {
 
 func GetGlDataByTradeCode(condition string, pars []interface{}) (item []*GlData, err error) {
 	sql := ` SELECT * FROM mb_index_main_data WHERE 1=1 AND DATA_VALUE is not null `
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -34,16 +32,14 @@ func GetGlDataByTradeCode(condition string, pars []interface{}) (item []*GlData,
 }
 
 func GetEdbDataGlByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_gl WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataGl(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_gl SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return
@@ -51,14 +47,16 @@ func ModifyEdbDataGl(edbInfoId int64, dataTime, value string) (err error) {
 
 //刷新钢联指标数据
 func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -126,7 +124,7 @@ func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err
 				if existVal != item.InputValue {
 					sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 					sql = fmt.Sprintf(sql, dataTableName)
-					_, err = o.Raw(sql, item.InputValue, edbInfoId, v.DataTime).Exec()
+					_, err = tx.Raw(sql, item.InputValue, edbInfoId, v.DataTime).Exec()
 					if err != nil {
 						return err
 					}
@@ -137,7 +135,7 @@ func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}

+ 12 - 18
models/data_manage/edb_data_lt.go

@@ -4,7 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/http"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
 	"reflect"
 	"strconv"
@@ -26,40 +26,35 @@ type EdbDataLt struct {
 
 // AddEdbDataLtBySql 执行添加数据的sql
 func AddEdbDataLtBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
 
 // ModifyEdbDataLt 修改路透社数据
 func ModifyEdbDataLt(edbInfoId int64, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_lt SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return
 }
 
 func GetEdbDataLtMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_lt WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
 	return
 }
 
 func GetEdbDataLtByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_lt WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func GetEdbDataLtByCode(edbCode string, size int) (items []*EdbInfoSearchData, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_data_lt WHERE edb_code=? ORDER BY data_time DESC LIMIT ? `
 	_, err = o.Raw(sql, edbCode, size).QueryRows(&items)
 	return
@@ -73,14 +68,13 @@ func RefreshAllEdbDataByLt(edbInfoId, source int, edbCode, startDate, endDate st
 		return
 	}
 
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -131,7 +125,7 @@ func RefreshAllEdbDataByLt(edbInfoId, source int, edbCode, startDate, endDate st
 			if existVal != saveValue {
 				sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 				sql = fmt.Sprintf(sql, dataTableName)
-				_, err = o.Raw(sql, sValue, edbInfoId, eDate).Exec()
+				_, err = tx.Raw(sql, sValue, edbInfoId, eDate).Exec()
 				if err != nil {
 					return err
 				}
@@ -140,7 +134,7 @@ func RefreshAllEdbDataByLt(edbInfoId, source int, edbCode, startDate, endDate st
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			fmt.Println("RefreshAllEdbDataByLt add Err", err.Error())
 			return

+ 11 - 16
models/data_manage/edb_data_lz.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -52,8 +52,7 @@ func GetLzSurveyDataByTradeCode(condition string, pars []interface{}) (item []*l
 	sql := ` SELECT  a.* FROM longzhong_survey_data AS a
 				INNER JOIN longzhong_survey_product AS b ON a.survey_product_id=b.survey_product_id
 				WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -64,23 +63,20 @@ func GetLzSurveyDataByTradeCode(condition string, pars []interface{}) (item []*l
 
 func GetLzSurveyDataExistByTradeCode(surveyProductId int) (items []*LongzhongSurveyData, err error) {
 	sql := ` SELECT  * FROM longzhong_survey_data WHERE 1=1 AND survey_product_id=? `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sql, surveyProductId).QueryRows(&items)
 	return
 }
 
 func GetEdbDataLzByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_lz WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataLz(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_lz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return
@@ -88,14 +84,13 @@ func ModifyEdbDataLz(edbInfoId int64, dataTime, value string) (err error) {
 
 //刷新隆众指标数据
 func RefreshEdbDataByLz(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -161,7 +156,7 @@ func RefreshEdbDataByLz(edbInfoId int, edbCode, startDate, endDate string) (err
 				if existVal != item.InputValue {
 					sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 					sql = fmt.Sprintf(sql, dataTableName)
-					_, err = o.Raw(sql, item.InputValue, edbInfoId, v.DataTime).Exec()
+					_, err = tx.Raw(sql, item.InputValue, edbInfoId, v.DataTime).Exec()
 					if err != nil {
 						return err
 					}
@@ -172,7 +167,7 @@ func RefreshEdbDataByLz(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}

+ 14 - 17
models/data_manage/edb_data_manual.go

@@ -2,7 +2,7 @@ package data_manage
 
 import (
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
 	"strconv"
 	"strings"
@@ -10,15 +10,13 @@ import (
 )
 
 func AddEdbDataManualBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
 
 func GetEdbDataManualMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_manual WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
 	return
@@ -33,8 +31,7 @@ type ManualEdbdata struct {
 
 func GetEdbdataManualByTradeCode(condition string, pars []interface{}) (item []*ManualEdbdata, err error) {
 	sql := ` SELECT  * FROM edbdata WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -44,16 +41,14 @@ func GetEdbdataManualByTradeCode(condition string, pars []interface{}) (item []*
 }
 
 func GetEdbDataManualByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_manual WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataManual(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_manual SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return
@@ -62,14 +57,16 @@ func ModifyEdbDataManual(edbInfoId int64, dataTime, value string) (err error) {
 //刷新手工指标数据
 func RefreshManual(item *EdbInfoList) (err error) {
 	//edbInfoId int, edbCode, startDate, endDate string
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -147,7 +144,7 @@ func RefreshManual(item *EdbInfoList) (err error) {
 
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}

+ 6 - 11
models/data_manage/edb_data_pb.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -20,39 +20,34 @@ type EdbDataPb struct {
 }
 
 func AddEdbDataPb(items []*EdbDataPb) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.InsertMulti(1, items)
 	return
 }
 
 func ModifyEdbDataPb(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_pb SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
 	_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
 	return
 }
 
 func ModifyEdbDataPbStatus(edbInfoId int64, edbCode string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_pb SET edb_info_id=?, status=1,modify_time=NOW() WHERE edb_code=? `
 	_, err = o.Raw(sql, edbInfoId, edbCode).Exec()
 	return
 }
 
 func GetEdbDataPbCount(edbCode, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_pb WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
 	return
 }
 
 func GetEdbDataPbMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_pb WHERE edb_info_id=? `
 	err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
 	return

+ 2 - 3
models/data_manage/edb_data_quarter.go

@@ -1,12 +1,11 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 func GetEdbDataQuarterCount(edbInfoId int) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	hsql := `SELECT COUNT(1) AS count FROM edb_data_quarter WHERE edb_info_id=? `
 	err = o.Raw(hsql, edbInfoId).QueryRow(&count)
 	return

+ 25 - 28
models/data_manage/edb_data_sh.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,8 +58,7 @@ type BaseFromTradeShIndex struct {
 }
 
 func GetEdbDataShMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_sh WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
 	return
@@ -67,14 +66,16 @@ func GetEdbDataShMaxOrMinDate(edbCode string) (minDate, maxDate string, err erro
 
 // RefreshEdbDataBySh 刷新上期所指标数据
 func RefreshEdbDataBySh(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx, err := o.Begin()
+	if err != nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -159,7 +160,7 @@ func RefreshEdbDataBySh(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -169,14 +170,16 @@ func RefreshEdbDataBySh(edbInfoId int, edbCode, startDate, endDate string) (err
 
 // RefreshAllEdbDataBySh 全部刷新上期所
 func RefreshAllEdbDataBySh(edbInfoId, source int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -265,7 +268,7 @@ func RefreshAllEdbDataBySh(edbInfoId, source int, edbCode, startDate, endDate st
 					if existVal != saveValue {
 						sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 						sql = fmt.Sprintf(sql, dataTableName)
-						_, err = o.Raw(sql, sValue, edbInfoId, eDate).Exec()
+						_, err = tx.Raw(sql, sValue, edbInfoId, eDate).Exec()
 						if err != nil {
 							return err
 						}
@@ -277,7 +280,7 @@ func RefreshAllEdbDataBySh(edbInfoId, source int, edbCode, startDate, endDate st
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -287,8 +290,7 @@ func RefreshAllEdbDataBySh(edbInfoId, source int, edbCode, startDate, endDate st
 
 // GetBaseInfoFromShByIndexCode 获取指标信息
 func GetBaseInfoFromShByIndexCode(indexCode, suffix string) (list []*BaseInfoFromSh, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_shanghai_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -297,8 +299,7 @@ func GetBaseInfoFromShByIndexCode(indexCode, suffix string) (list []*BaseInfoFro
 
 func GetShDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromShDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_shanghai_index WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -308,15 +309,13 @@ func GetShDataByTradeCode(condition string, pars []interface{}) (item []*BaseFro
 }
 
 func AddEdbDataShBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
 
 func GetBaseFromShDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeShIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_shanghai_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -324,16 +323,14 @@ func GetBaseFromShDataAllByIndexCode(indexCode, suffix string) (list []*BaseFrom
 }
 
 func GetEdbDataShByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_sh WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataSh(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_sh SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 25 - 28
models/data_manage/edb_data_shfe.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,8 +58,7 @@ type BaseFromTradeShfeIndex struct {
 }
 
 func GetEdbDataShfeMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_ine WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
 	return
@@ -68,14 +67,16 @@ func GetEdbDataShfeMaxOrMinDate(edbCode string) (minDate, maxDate string, err er
 
 // RefreshEdbDataByShfe 刷新上期能源指标数据
 func RefreshEdbDataByShfe(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -160,7 +161,7 @@ func RefreshEdbDataByShfe(edbInfoId int, edbCode, startDate, endDate string) (er
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -170,14 +171,16 @@ func RefreshEdbDataByShfe(edbInfoId int, edbCode, startDate, endDate string) (er
 
 // RefreshAllEdbDataByShfe 全部刷新上期能源
 func RefreshAllEdbDataByShfe(edbInfoId, source int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -266,7 +269,7 @@ func RefreshAllEdbDataByShfe(edbInfoId, source int, edbCode, startDate, endDate
 					if existVal != saveValue {
 						sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 						sql = fmt.Sprintf(sql, dataTableName)
-						_, err = o.Raw(sql, sValue, edbInfoId, eDate).Exec()
+						_, err = tx.Raw(sql, sValue, edbInfoId, eDate).Exec()
 						if err != nil {
 							return err
 						}
@@ -278,7 +281,7 @@ func RefreshAllEdbDataByShfe(edbInfoId, source int, edbCode, startDate, endDate
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -288,8 +291,7 @@ func RefreshAllEdbDataByShfe(edbInfoId, source int, edbCode, startDate, endDate
 
 // GetBaseInfoFromShfeByIndexCode 获取指标信息
 func GetBaseInfoFromShfeByIndexCode(indexCode, suffix string) (list []*BaseInfoFromShfe, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_ine_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -298,8 +300,7 @@ func GetBaseInfoFromShfeByIndexCode(indexCode, suffix string) (list []*BaseInfoF
 
 func GetShfeDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromShfeDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_ine_index WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -309,8 +310,7 @@ func GetShfeDataByTradeCode(condition string, pars []interface{}) (item []*BaseF
 }
 
 func AddEdbDataShfeBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
@@ -318,8 +318,7 @@ func AddEdbDataShfeBySql(sqlStr string) (err error) {
 
 
 func GetBaseFromShfeDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeShfeIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_ine_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -327,16 +326,14 @@ func GetBaseFromShfeDataAllByIndexCode(indexCode, suffix string) (list []*BaseFr
 }
 
 func GetEdbDataShfeByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_ine WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataShfe(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_ine SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 5 - 9
models/data_manage/edb_data_ths.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -18,31 +18,27 @@ type EdbDataThs struct {
 }
 
 func AddEdbDataThs(items []*EdbDataThs) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.InsertMulti(1, items)
 	return
 }
 
 func ModifyEdbDataThs(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_ths SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
 	_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
 	return
 }
 
 func GetEdbDataThsCount(ebdCode, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_ths WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, ebdCode, dataTime).QueryRow(&count)
 	return
 }
 
 func GetEdbDataThsMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_ths WHERE edb_info_id=? `
 	err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
 	return

+ 6 - 11
models/data_manage/edb_data_wind.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -18,39 +18,34 @@ type EdbDataWind struct {
 }
 
 func AddEdbDataWind(items []*EdbDataWind) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.InsertMulti(1, items)
 	return
 }
 
 func ModifyEdbDataWind(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_wind SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
 	_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
 	return
 }
 
 func ModifyEdbDataWindStatus(edbInfoId int64, edbCode string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_wind SET edb_info_id=?, status=1,modify_time=NOW() WHERE edb_code=? `
 	_, err = o.Raw(sql, edbInfoId, edbCode).Exec()
 	return
 }
 
 func GetEdbDataWindCount(edbCode, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_wind WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
 	return
 }
 
 func GetEdbDataWindMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_wind WHERE edb_info_id=? `
 	err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
 	return

+ 3 - 5
models/data_manage/edb_data_ys.go

@@ -15,7 +15,7 @@ import (
 	"io/ioutil"
 	"net/http"
 	"net/url"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"time"
 )
@@ -33,15 +33,13 @@ type EdbDataYs struct {
 }
 
 func AddEdbDataSmm(items []*EdbDataYs) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.InsertMulti(1, items)
 	return
 }
 
 func ModifyEdbDataSmm(edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_ys SET value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbCode, dataTime).Exec()
 	return

+ 24 - 27
models/data_manage/edb_data_zz.go

@@ -3,7 +3,7 @@ package data_manage
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,8 +58,7 @@ type BaseFromTradeZhengzhouIndex struct {
 }
 
 func GetEdbDataZzMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_zz WHERE edb_code=? `
 	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
 	return
@@ -68,14 +67,16 @@ func GetEdbDataZzMaxOrMinDate(edbCode string) (minDate, maxDate string, err erro
 
 // RefreshEdbDataByZz 刷新郑商所指标数据
 func RefreshEdbDataByZz(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -160,7 +161,7 @@ func RefreshEdbDataByZz(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -170,14 +171,16 @@ func RefreshEdbDataByZz(edbInfoId int, edbCode, startDate, endDate string) (err
 
 // RefreshAllEdbDataByZz 全部刷新郑商所
 func RefreshAllEdbDataByZz(edbInfoId, source int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	if err != nil {
@@ -266,7 +269,7 @@ func RefreshAllEdbDataByZz(edbInfoId, source int, edbCode, startDate, endDate st
 					if existVal != saveValue {
 						sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 						sql = fmt.Sprintf(sql, dataTableName)
-						_, err = o.Raw(sql, sValue, edbInfoId, eDate).Exec()
+						_, err = tx.Raw(sql, sValue, edbInfoId, eDate).Exec()
 						if err != nil {
 							return err
 						}
@@ -288,8 +291,7 @@ func RefreshAllEdbDataByZz(edbInfoId, source int, edbCode, startDate, endDate st
 
 // GetBaseInfoFromZhengzhouByIndexCode 获取指标信息
 func GetBaseInfoFromZhengzhouByIndexCode(indexCode, suffix string) (list []*BaseInfoFromZz, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -298,8 +300,7 @@ func GetBaseInfoFromZhengzhouByIndexCode(indexCode, suffix string) (list []*Base
 
 func GetZzDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromZzDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_zhengzhou_index WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	if condition != "" {
 		sql += condition
 	}
@@ -309,8 +310,7 @@ func GetZzDataByTradeCode(condition string, pars []interface{}) (item []*BaseFro
 }
 
 func AddEdbDataZzBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sqlStr).Exec()
 	return
 }
@@ -318,8 +318,7 @@ func AddEdbDataZzBySql(sqlStr string) (err error) {
 
 
 func GetBaseFromZhengzhouDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeZhengzhouIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
 	_, err = o.Raw(sql, indexCode).QueryRows(&list)
@@ -327,16 +326,14 @@ func GetBaseFromZhengzhouDataAllByIndexCode(indexCode, suffix string) (list []*B
 }
 
 func GetEdbDataZzByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_zz WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataZz(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_zz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 12 - 23
models/data_manage/edb_info.go

@@ -2,7 +2,7 @@ package data_manage
 
 import (
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -56,8 +56,7 @@ type EdbInfoSearchDataV1 struct {
 }
 
 func GetEdbInfoByCondition(condition string, pars []interface{}, order int) (item []*EdbInfoList, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_info WHERE 1=1 `
 	if condition != "" {
 		sql += condition
@@ -72,8 +71,7 @@ func GetEdbInfoByCondition(condition string, pars []interface{}, order int) (ite
 }
 
 func ModifyEdbDataInfoDate(edbInfoId int, maxDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_info SET end_date=?,modify_time=NOW() WHERE edb_info_id=? `
 	_, err = o.Raw(sql, maxDate, edbInfoId).Exec()
 	return
@@ -88,8 +86,7 @@ type EdbInfoMaxAndMinInfo struct {
 }
 
 func GetEdbInfoMaxAndMinInfo(source int, edbCode string) (item *EdbInfoMaxAndMinInfo, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ``
 	tableName := GetEdbDataTableName(source)
 	sql = ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(value) AS min_value,MAX(value) AS max_value FROM %s WHERE edb_code=? `
@@ -105,8 +102,7 @@ func GetEdbInfoMaxAndMinInfo(source int, edbCode string) (item *EdbInfoMaxAndMin
 }
 
 func ModifyEdbInfoMaxAndMinInfo(edbInfoId int, item *EdbInfoMaxAndMinInfo) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_info SET start_date=?,end_date=?,min_value=?,max_value=?,is_update=2,latest_date=?,latest_value=?,modify_time=NOW() WHERE edb_info_id=? `
 	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, item.MaxDate, item.LatestValue, edbInfoId).Exec()
 	return
@@ -114,8 +110,7 @@ func ModifyEdbInfoMaxAndMinInfo(edbInfoId int, item *EdbInfoMaxAndMinInfo) (err
 
 //order:1升序,其余值为降序
 func GetEdbDataListAll(condition string, pars []interface{}, source, order int) (item []*EdbInfoSearchData, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ``
 	tableName := GetEdbDataTableName(source)
 	sql = ` SELECT * FROM %s WHERE 1=1 `
@@ -134,8 +129,7 @@ func GetEdbDataListAll(condition string, pars []interface{}, source, order int)
 }
 
 func GetEdbDataListAllV1(condition string, pars []interface{}, source, order int) (item []*EdbInfoSearchDataV1, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ``
 	tableName := GetEdbDataTableName(source)
 	sql = ` SELECT * FROM %s WHERE 1=1 `
@@ -154,16 +148,14 @@ func GetEdbDataListAllV1(condition string, pars []interface{}, source, order int
 }
 
 func GetEdbInfoById(edbInfoId int) (item *EdbInfo, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_info WHERE edb_info_id=? `
 	err = o.Raw(sql, edbInfoId).QueryRow(&item)
 	return
 }
 
 func GetQuarterEdbInfo() (item []*EdbInfo, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT c.* FROM chart_info AS a
 			INNER JOIN chart_edb_mapping AS b ON a.chart_info_id=b.chart_info_id
 			INNER JOIN edb_info AS c ON b.edb_info_id=c.edb_info_id
@@ -175,8 +167,7 @@ func GetQuarterEdbInfo() (item []*EdbInfo, err error) {
 }
 
 func ResetEdbInfoIsUpdate() (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_info SET is_update=1  `
 	_, err = o.Raw(sql).Exec()
 	return
@@ -184,8 +175,7 @@ func ResetEdbInfoIsUpdate() (err error) {
 
 // GetEdbInfoCalculateListByCondition 获取指标关系列表
 func GetEdbInfoCalculateListByCondition(condition string, pars []interface{}) (items []*EdbInfoCalculateMapping, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	//calculateTableName := GetEdbInfoCalculateTableName(source)
 	//if calculateTableName == "" {
 	//	err = errors.New("无效的表名")
@@ -206,8 +196,7 @@ func DeleteEdbDataByIdAndSource(edbDataId, source int) (err error) {
 	tableName := GetEdbDataTableName(source)
 	sql = fmt.Sprintf(sql, tableName)
 
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sql, edbDataId).Exec()
 	return
 }

+ 10 - 9
models/data_manage/edb_info_calculate_bp.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -27,14 +27,16 @@ type EdbInfoCalculateBp struct {
 
 //变频
 func RefreshCalculateBp(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -128,7 +130,7 @@ func RefreshCalculateBp(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate,
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			fmt.Println("add err:" + err.Error())
 			return err
@@ -155,8 +157,7 @@ type EdbInfoCalculateBpDetail struct {
 }
 
 func GetEdbInfoCalculateBpDetail(edbInfoId int) (item *EdbInfoCalculateTbzDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `

+ 10 - 9
models/data_manage/edb_info_calculate_hbz.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -39,14 +39,16 @@ func HbzDiv(current, pre float64) string {
 
 //刷新环比值数据
 func RefreshCalculateHbz(edbInfoId, source int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate string, formulaInt int) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -114,7 +116,7 @@ func RefreshCalculateHbz(edbInfoId, source int, fromEdbInfo *EdbInfo, edbCode, s
 							if existVal != val {
 								sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 								sql = fmt.Sprintf(sql, dataTableName)
-								_, err = o.Raw(sql, val, edbInfoId, currentItem.DataTime).Exec()
+								_, err = tx.Raw(sql, val, edbInfoId, currentItem.DataTime).Exec()
 								if err != nil {
 									return err
 								}
@@ -154,8 +156,7 @@ type EdbInfoCalculateHbzDetail struct {
 }
 
 func GetEdbInfoCalculateHbzDetail(edbInfoId int) (item *EdbInfoCalculateTbzDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `

+ 10 - 9
models/data_manage/edb_info_calculate_hcz.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -39,14 +39,16 @@ func HczDiv(current, pre float64) string {
 
 //刷新环比值数据
 func RefreshCalculateHcz(edbInfoId, source int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -113,7 +115,7 @@ func RefreshCalculateHcz(edbInfoId, source int, fromEdbInfo *EdbInfo, edbCode, s
 							if existVal != val {
 								sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 								sql = fmt.Sprintf(sql, dataTableName)
-								_, err = o.Raw(sql, val, edbInfoId, currentItem.DataTime).Exec()
+								_, err = tx.Raw(sql, val, edbInfoId, currentItem.DataTime).Exec()
 								if err != nil {
 									return err
 								}
@@ -153,8 +155,7 @@ type EdbInfoCalculateHczDetail struct {
 }
 
 func GetEdbInfoCalculateHczDetail(edbInfoId int) (item *EdbInfoCalculateHczDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `

+ 12 - 10
models/data_manage/edb_info_calculate_ljztbpj.go

@@ -5,7 +5,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"sort"
 	"strings"
 	"time"
@@ -30,14 +30,16 @@ type EdbInfoCalculateLjztbpjDetail struct {
 
 // RefreshAllCalculateLjztbpj 刷新所有 累计值同比拼接 数据
 func RefreshAllCalculateLjztbpj(edbInfo *EdbInfo) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -234,7 +236,7 @@ func RefreshAllCalculateLjztbpj(edbInfo *EdbInfo) (err error) {
 			tmpAddDataList = append(tmpAddDataList, v)
 
 			if len(tmpAddDataList) >= 200 {
-				_, tmpErr := o.InsertMulti(len(tmpAddDataList), tmpAddDataList)
+				_, tmpErr := tx.InsertMulti(len(tmpAddDataList), tmpAddDataList)
 				if tmpErr != nil {
 					err = tmpErr
 					return
@@ -245,7 +247,7 @@ func RefreshAllCalculateLjztbpj(edbInfo *EdbInfo) (err error) {
 		}
 		//最后如果还有需要新增的数据,那么就统一入库
 		if len(tmpAddDataList) > 0 {
-			_, tmpErr := o.InsertMulti(len(tmpAddDataList), tmpAddDataList)
+			_, tmpErr := tx.InsertMulti(len(tmpAddDataList), tmpAddDataList)
 			if tmpErr != nil {
 				err = tmpErr
 				return
@@ -262,7 +264,7 @@ func RefreshAllCalculateLjztbpj(edbInfo *EdbInfo) (err error) {
 			tableName := GetEdbDataTableName(edbInfo.Source)
 			sql := fmt.Sprintf(` DELETE FROM %s WHERE edb_info_id = ? and data_time in (%s) `, tableName, removeDateStr)
 
-			_, err = o.Raw(sql, edbInfo.EdbInfoId).Exec()
+			_, err = tx.Raw(sql, edbInfo.EdbInfoId).Exec()
 			if err != nil {
 				err = errors.New("删除不存在的累计值同比拼接指标数据失败,Err:" + err.Error())
 				return
@@ -276,7 +278,7 @@ func RefreshAllCalculateLjztbpj(edbInfo *EdbInfo) (err error) {
 		for edbDate, edbDataValue := range updateEdbDataMap {
 			sql := fmt.Sprintf(` UPDATE  %s set value = ?,modify_time=now() WHERE edb_info_id = ? and data_time = ? `, tableName)
 
-			_, err = o.Raw(sql, edbDataValue, edbInfo.EdbInfoId, edbDate).Exec()
+			_, err = tx.Raw(sql, edbDataValue, edbInfo.EdbInfoId, edbDate).Exec()
 			if err != nil {
 				err = errors.New("更新现有的累计值同比拼接指标数据失败,Err:" + err.Error())
 				return

+ 12 - 13
models/data_manage/edb_info_calculate_ljzzy.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -27,14 +27,16 @@ type EdbInfoCalculateLjzzy struct {
 
 //刷新累计值转月值数据
 func RefreshCalculateLjzzy(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -166,7 +168,7 @@ func RefreshCalculateLjzzy(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDa
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -192,8 +194,7 @@ type EdbInfoCalculateLjzzyDetail struct {
 }
 
 func GetEdbInfoCalculateLjzzyDetail(edbInfoId int) (item *EdbInfoCalculateLjzzyDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
@@ -202,16 +203,14 @@ func GetEdbInfoCalculateLjzzyDetail(edbInfoId int) (item *EdbInfoCalculateLjzzyD
 }
 
 func GetEdbDataCalculateLjzzyByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate_ljzzy WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataCalculateLjzzy(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_calculate_ljzzy SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 12 - 13
models/data_manage/edb_info_calculate_mapping.go

@@ -2,7 +2,7 @@ package data_manage
 
 import (
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -24,22 +24,22 @@ type EdbInfoCalculateMapping struct {
 }
 
 func AddEdbInfoCalculateMappingMulti(items []*EdbInfoCalculateMapping) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	_, err = o.InsertMulti(1, items)
 	return
 }
 
 func FixEdbInfoCalculateMapping() {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
-	var err error
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 	edbInfoList := make([]*EdbInfoList, 0)
@@ -55,7 +55,7 @@ func FixEdbInfoCalculateMapping() {
 		sql := ` SELECT * FROM %s
 			WHERE edb_info_id=? ORDER BY sort ASC `
 		sql = fmt.Sprintf(sql, calculateTableName)
-		_, err = o.Raw(sql, v.EdbInfoId).QueryRows(&calculateList)
+		_, err = tx.Raw(sql, v.EdbInfoId).QueryRows(&calculateList)
 		if err != nil {
 			fmt.Println("query calculate err:" + err.Error())
 			return
@@ -76,7 +76,7 @@ func FixEdbInfoCalculateMapping() {
 			calculateMappingItem.FromTag = cv.FromTag
 			calculateMappingItem.Source = v.Source
 			calculateMappingItem.SourceName = v.SourceName
-			o.Insert(calculateMappingItem)
+			tx.Insert(calculateMappingItem)
 		}
 	}
 }
@@ -104,8 +104,7 @@ type EdbInfoCalculateMappingView struct {
 }
 
 func GetEdbInfoCalculateMappingDetail(edbInfoId int) (item *EdbInfoCalculateMappingView, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date,b.calculate_formula,b.move_type,b.move_frequency FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `

+ 12 - 13
models/data_manage/edb_info_calculate_nszydpjjs.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -27,14 +27,16 @@ type EdbInfoCalculateNszydpjjs struct {
 
 //刷新 N数值移动平均计算
 func RefreshCalculateNszydpjjs(edbInfoId, source, formulaInt int, fromEdbInfo *EdbInfo, edbCode string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -141,7 +143,7 @@ func RefreshCalculateNszydpjjs(edbInfoId, source, formulaInt int, fromEdbInfo *E
 
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -167,8 +169,7 @@ type EdbInfoCalculateNszydpjjsDetail struct {
 }
 
 func GetEdbInfoCalculateNszydpjjsDetail(edbInfoId int) (item *EdbInfoCalculateNszydpjjsDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
@@ -177,16 +178,14 @@ func GetEdbInfoCalculateNszydpjjsDetail(edbInfoId int) (item *EdbInfoCalculateNs
 }
 
 func GetEdbDataCalculateNszydpjjsByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate_nszydpjjs WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataCalculateNszydpjjs(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_calculate_nszydpjjs SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 12 - 13
models/data_manage/edb_info_calculate_tbz.go

@@ -2,7 +2,7 @@ package data_manage
 
 import (
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
 	"strconv"
@@ -36,14 +36,16 @@ func TbzDiv(a, b float64) string {
 
 //刷新同比值数据
 func RefreshCalculateTbz(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -251,7 +253,7 @@ func RefreshCalculateTbz(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -277,8 +279,7 @@ type EdbInfoCalculateTbzDetail struct {
 }
 
 func GetEdbInfoCalculateTbzDetail(edbInfoId int) (item *EdbInfoCalculateTbzDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
@@ -287,16 +288,14 @@ func GetEdbInfoCalculateTbzDetail(edbInfoId int) (item *EdbInfoCalculateTbzDetai
 }
 
 func GetEdbDataCalculateTbzByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate_tbz WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataCalculateTbz(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_calculate_tbz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 12 - 13
models/data_manage/edb_info_calculate_tcz.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"github.com/shopspring/decimal"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -36,14 +36,16 @@ func TczSub(a, b float64) string {
 
 //刷新同差值数据
 func RefreshCalculateTcz(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -252,7 +254,7 @@ func RefreshCalculateTcz(edbInfoId int, fromEdbInfo *EdbInfo, edbCode, startDate
 
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = o.Raw(addSql).Exec()
+		_, err = tx.Raw(addSql).Exec()
 		if err != nil {
 			return err
 		}
@@ -278,8 +280,7 @@ type EdbInfoCalculateTczDetail struct {
 }
 
 func GetEdbInfoCalculateTczDetail(edbInfoId int) (item *EdbInfoCalculateTczDetail, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
@@ -288,16 +289,14 @@ func GetEdbInfoCalculateTczDetail(edbInfoId int) (item *EdbInfoCalculateTczDetai
 }
 
 func GetEdbDataCalculateTczByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate_tcz WHERE edb_code=? AND data_time=? `
 	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
 	return
 }
 
 func ModifyEdbDataCalculateTcz(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
+	o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_data_calculate_tcz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
 	return

+ 9 - 7
models/data_manage/edb_info_calculate_zjpj.go

@@ -4,7 +4,7 @@ import (
 	"errors"
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
@@ -28,14 +28,16 @@ type EdbInfoCalculateZjpjDetail struct {
 
 // RefreshAllCalculateZjpj 刷新所有 直接拼接 数据
 func RefreshAllCalculateZjpj(edbInfo *EdbInfo) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
+	o := orm.NewOrmUsingDB("data")
+	tx,err:=o.Begin()
+	if err!=nil {
+		return err
+	}
 	defer func() {
 		if err != nil {
-			o.Rollback()
+			tx.Rollback()
 		} else {
-			o.Commit()
+			tx.Commit()
 		}
 	}()
 
@@ -213,7 +215,7 @@ func RefreshAllCalculateZjpj(edbInfo *EdbInfo) (err error) {
 	}
 	//最后如果还有需要新增的数据,那么就统一入库
 	if len(tmpAddDataList) > 0 {
-		_, tmpErr := o.InsertMulti(len(tmpAddDataList), tmpAddDataList)
+		_, tmpErr := tx.InsertMulti(len(tmpAddDataList), tmpAddDataList)
 		if tmpErr != nil {
 			err = tmpErr
 			return

+ 35 - 69
models/data_source_longzhong.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -38,8 +38,7 @@ type Longzhonginfo struct {
 }
 
 func GetLongzhonginfoBySecName(secName string) (item *Longzhongdata, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhonginfo WHERE sec_name=? `
 	err = o.Raw(sql, secName).QueryRow(&item)
 	return
@@ -47,23 +46,20 @@ func GetLongzhonginfoBySecName(secName string) (item *Longzhongdata, err error)
 
 //判断指标数据是否已经录入
 func GetLongzhongdataCount(longzhonginfoId int, dt string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhongdata WHERE longzhonginfo_id=? AND dt=? `
 	err = o.Raw(sql, longzhonginfoId, dt).QueryRow(&count)
 	return
 }
 
 func AddLongzhongdata(item *Longzhongdata) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Insert(item)
 	return
 }
 
 func ModifyLongzhongdata(item *Longzhongdata) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` UPDATE  longzhongdata
 			SET
 			  close = ?,
@@ -79,15 +75,13 @@ func ModifyLongzhongdata(item *Longzhongdata) (err error) {
 }
 
 func AddLongzhonginfo(item *Longzhonginfo) (newId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	newId, err = o.Insert(item)
 	return
 }
 
 func ModifyLongzhonginfo(item *Longzhonginfo) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `UPDATE  longzhonginfo
 		SET
 		  sec_name = ?,
@@ -107,8 +101,7 @@ func ModifyLongzhonginfo(item *Longzhonginfo) (err error) {
 
 //判断指标数据是否已经录入
 func GetLongzhonginfoCount(classifyId int, unitid int64) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhonginfo WHERE classify_id=? AND unitid=? `
 	err = o.Raw(sql, classifyId, unitid).QueryRow(&count)
 	return
@@ -116,8 +109,7 @@ func GetLongzhonginfoCount(classifyId int, unitid int64) (count int, err error)
 
 //判断指标数据是否已经录入
 func GetLongzhonginfoBySecNameCount(secName string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhonginfo WHERE sec_name=? `
 	err = o.Raw(sql, secName).QueryRow(&count)
 	return
@@ -143,8 +135,7 @@ type LzProductInfo struct {
 }
 
 func GetLongzhonginfoMaxId() (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT MAX(longzhonginfo_id) AS count FROM longzhonginfo`
 	err = o.Raw(sql).QueryRow(&count)
 	return
@@ -175,24 +166,21 @@ type LzProductInfoDetailResp struct {
 }
 
 func GetLongzhonginfoByUnitId(classifyName string, unitId int64) (item *Longzhonginfo, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhonginfo WHERE unitid=? AND classify_name=?`
 	err = o.Raw(sql, unitId, classifyName).QueryRow(&item)
 	return
 }
 
 func GetLongzhongDataById(lzInfoId int) (items []*Longzhongdata, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhongdata WHERE longzhonginfo_id=? ORDER BY dt DESC `
 	_, err = o.Raw(sql, lzInfoId).QueryRows(&items)
 	return
 }
 
 func GetLongzhongDataMaxCount(classifyId int) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT MAX(t.num) AS count FROM (
 				SELECT COUNT(1) AS num  FROM longzhonginfo AS a
 				INNER JOIN longzhongdata AS b ON a.longzhonginfo_id=b.longzhonginfo_id
@@ -217,16 +205,14 @@ type LongzhonginfoList struct {
 }
 
 func GetLongzhonginfoList() (items []*LongzhonginfoList, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` SELECT * FROM longzhonginfo AS a `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
 func ModifyLongzhonginfoIsNormal(longzhonginfoId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` UPDATE longzhonginfo SET is_normal=0 WHERE longzhonginfo_id=? `
 	_, err = o.Raw(sql, longzhonginfoId).Exec()
 	return
@@ -268,16 +254,14 @@ type Longzhongpriceinfo struct {
 }
 
 func AddLongzhongpriceinfo(item *Longzhongpriceinfo) (newId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	newId, err = o.Insert(item)
 	return
 }
 
 //判断指标数据是否已经录入
 func GetLongzhongpriceinfoCount(unitid string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhongpriceinfo WHERE price_id=? `
 	err = o.Raw(sql, unitid).QueryRow(&count)
 	return
@@ -285,8 +269,7 @@ func GetLongzhongpriceinfoCount(unitid string) (count int, err error) {
 
 //判断指标数据是否已经录入
 func GetLongzhongpriceinfo() (items []*Longzhongpriceinfo, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhongpriceinfo `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
@@ -310,16 +293,14 @@ type Longzhongpricedata struct {
 }
 
 func AddLongzhongpricedata(item *Longzhongpricedata) (newId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	newId, err = o.Insert(item)
 	return
 }
 
 //判断指标数据是否已经录入
 func GetLongzhongpricedataCount(longzhongpriceinfoId int, priceDate string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhongpricedata WHERE longzhongpriceinfo_id=? AND price_date=? `
 	err = o.Raw(sql, longzhongpriceinfoId, priceDate).QueryRow(&count)
 	return
@@ -348,8 +329,7 @@ type LzPriceDataResp struct {
 }
 
 func GetLongzhongPriceDataMaxCount(productName string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT MAX(t.num) AS count FROM (
 				SELECT COUNT(1) AS num  FROM longzhongpriceinfo AS a
 				INNER JOIN longzhongpricedata AS b ON a.longzhongpriceinfo_id=b.longzhongpriceinfo_id
@@ -378,16 +358,14 @@ type LongzhongpricedataItems struct {
 }
 
 func GetLongzhongPriceDataById(lzPriceInfoId int) (items []*LongzhongpricedataItems, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhongpricedata WHERE longzhongpriceinfo_id=? ORDER BY price_date DESC `
 	_, err = o.Raw(sql, lzPriceInfoId).QueryRows(&items)
 	return
 }
 
 func ModifyLongzhongpriceinfo(item *Longzhongpriceinfo) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `UPDATE  longzhongpriceinfo
 SET
   standard = ?,
@@ -404,8 +382,7 @@ WHERE price_id = ? `
 }
 
 func GetDisplayTime(longzhonginfoId int) (display_time string, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` SELECT max(a.display_time) AS display_time FROM longzhongdata AS a WHERE a.longzhonginfo_id=? `
 	err = o.Raw(sql, longzhonginfoId).QueryRow(&display_time)
 	return
@@ -486,23 +463,20 @@ type LongzhongSurveyProduct struct {
 
 //判断指标数据是否已经录入
 func GetLongzhongSurveyProductCount(quotaSampleId int64) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhong_survey_product WHERE quota_sample_id=? `
 	err = o.Raw(sql, quotaSampleId).QueryRow(&count)
 	return
 }
 
 func AddLongzhongSurveyProduct(item *LongzhongSurveyProduct) (lastId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	lastId, err = o.Insert(item)
 	return
 }
 
 func ModifLongzhongSurveyProduct(item *LongzhongSurveyProduct) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `UPDATE  longzhong_survey_product
 			SET
 			  breed_id = ?,
@@ -519,8 +493,7 @@ func ModifLongzhongSurveyProduct(item *LongzhongSurveyProduct) (err error) {
 
 //判断指标数据是否已经录入
 func GetLongzhongSurveyList() (items []*LongzhongSurveyProduct, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhong_survey_product ORDER BY survey_product_id ASC`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
@@ -561,8 +534,7 @@ type LongzhongSurveyData struct {
 }
 
 func AddLongzhongSurveyData(item *LongzhongSurveyData) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Insert(item)
 	return
 }
@@ -611,8 +583,7 @@ type LzSurveyData struct {
 
 //判断指标数据是否已经录入
 func GetLzSurveyDataCount(surveyProductId, quotaSampleId int, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM longzhong_survey_data WHERE survey_product_id=? AND quota_sample_id=? AND data_time=? `
 	err = o.Raw(sql, surveyProductId, quotaSampleId, dataTime).QueryRow(&count)
 	return
@@ -626,8 +597,7 @@ type LzSurveyMaxAndMinInfo struct {
 }
 
 func GetLzSurveyMaxAndMinInfo(surveyProductId, quotaSampleId int) (item *LzSurveyMaxAndMinInfo, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ``
 	sql = ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(input_value) AS min_value,MAX(input_value) AS max_value 
            FROM longzhong_survey_data WHERE survey_product_id=? AND quota_sample_id=? `
@@ -636,16 +606,14 @@ func GetLzSurveyMaxAndMinInfo(surveyProductId, quotaSampleId int) (item *LzSurve
 }
 
 func ModifyLzSurveyMaxAndMinInfo(item *LzSurveyMaxAndMinInfo, surveyProductId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` UPDATE longzhong_survey_product SET start_date=?,end_date=?,min_value=?,max_value=? WHERE survey_product_id=? `
 	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, surveyProductId).Exec()
 	return
 }
 
 func ModifLongzhongSurveyProductCode(lzCode string, surveyProductId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `UPDATE  longzhong_survey_product
 			SET lz_code= ?,modify_time=NOW()
 			WHERE survey_product_id = ? `
@@ -655,16 +623,14 @@ func ModifLongzhongSurveyProductCode(lzCode string, surveyProductId int) (err er
 
 //判断指标数据是否已经录入
 func GetLongzhongSurveyProductItem(quotaSampleId int64) (item *LongzhongSurveyProduct, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM longzhong_survey_product WHERE quota_sample_id=? `
 	err = o.Raw(sql, quotaSampleId).QueryRow(&item)
 	return
 }
 
 func ModifyLzSurveyData(inputValue string, surveyDataId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` UPDATE longzhong_survey_data SET input_value=? WHERE survey_data_id=? `
 	_, err = o.Raw(sql, inputValue, surveyDataId).Exec()
 	return

+ 2 - 1
models/db.go

@@ -10,7 +10,7 @@ import (
 	"hongze/hongze_task/utils"
 	"time"
 
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 func init() {
@@ -96,6 +96,7 @@ func init() {
 		new(data_manage.EdbDataLt),               //路透指标数据表
 		new(CompanyProductUpdateLog),             //客户产品状态变更表
 		new(roadshow.RsReportRecord),             //路演记录
+		new(CompanyReportRecord),
 		new(CompanyViewStatistics),
 	)
 }

+ 2 - 3
models/edbdata.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -15,8 +15,7 @@ type Edbdata struct {
 // GetLastEdbdataInfo 根据指标编号获取指标最近的一条数据
 func GetLastEdbdataInfo(tradeCode string) (item *Edbdata, err error) {
 	sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? order by DT desc `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	err = o.Raw(sql, tradeCode).QueryRow(&item)
 	return
 }

+ 5 - 9
models/edbdata_classify.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -15,23 +15,20 @@ type EdbdataClassify struct {
 
 func GetEdbdataClassifyByClassifyName(classifyName string) (item *EdbdataClassify, err error) {
 	sql := `SELECT * FROM edbdata_classify WHERE classify_name=? `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	err = o.Raw(sql, classifyName).QueryRow(&item)
 	return
 }
 
 func AddEdbdataClassify(item *EdbdataClassify) (newId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	newId, err = o.Insert(item)
 	return
 }
 
 func GetEdbdataClassifyByParentId(parentId int) (items []*EdbdataClassify, err error) {
 	sql := ` SELECT * FROM edbdata_classify WHERE parent_id=? `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	o.Raw(sql, parentId).QueryRows(&items)
 	return
 }
@@ -42,8 +39,7 @@ type LzPriceClassify struct {
 
 func GetLzPriceClassify() (items []*LzPriceClassify, err error) {
 	sql := ` SELECT product_name  FROM longzhongpriceinfo GROUP BY product_name ORDER BY product_name DESC `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	o.Raw(sql).QueryRows(&items)
 	return
 }

+ 2 - 3
models/edbinfo_longzhong.go

@@ -1,6 +1,6 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import "github.com/beego/beego/v2/client/orm"
 
 type DataSourceLongzhong struct {
 	Id int `orm:"column(id);pk"`
@@ -14,8 +14,7 @@ type DataSourceLongzhong struct {
 }
 
 func AddDataSourceLongzhong(item *DataSourceLongzhong) (newId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	newId, err = o.Insert(item)
 	return
 }

+ 3 - 5
models/edbinfo_send_msg_record.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -13,15 +13,13 @@ type EdbinfoSendMsgRecord struct {
 }
 
 func AddEdbinfoSendMsgRecord(item *EdbinfoSendMsgRecord) (err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Insert(item)
 	return err
 }
 
 func GetEdbinfoSendMsgCount(userId int, tradeCode string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT COUNT(1) AS count FROM edbinfo_send_msg_record WHERE user_id=? AND trade_code=? AND create_time=DATE(NOW()) `
 	err = o.Raw(sql, userId, tradeCode).QueryRow(&count)
 	return

+ 42 - 22
models/free_viewer.go

@@ -1,39 +1,59 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
 
 type FreeViewerDetails struct {
 	UserId         int
 	RealName       string
 	Mobile         string
-	Note           string
-	CreatedTime    string
-	MaxCreatedTime string
+	CompanyName    string
+	LastTime       string
 	Email          string
+	ApplyRecordId  int
 }
 
 func GetFreeViewerDetails(startTime, endTime string) (items []*FreeViewerDetails, err error) {
-	sql := `select u.user_id,u.real_name,u.mobile,u.note,u.created_time,max(uvh.created_time) as max_created_time,u.email
-	from wx_user u
-	LEFT JOIN user_view_history uvh on u.user_id = uvh.user_id
-    INNER JOIN user_record AS c ON u.user_id=c.user_id
-	where u.company_id = 1
-	and u.is_deal=0
-	and u.apply_method<>2
-	and u.mobile is not null
-	AND u.mobile<>''
-	and u.created_time > ?
-	and u.created_time <= ?
-	AND c.create_platform<>4
-    AND u.is_deal = 0
-	group by u.user_id`
-	_, err = orm.NewOrm().Raw(sql, startTime, endTime).QueryRows(&items)
+	sql := `SELECT
+	a.user_id,
+	a.real_name,
+	a.mobile,
+	a.email,
+    y.apply_record_id,
+    IF(a.company_id > 1,b.company_name,a.note) AS company_name,
+	IF(y.apply_record_id > 0,y.create_time, a.created_time) as last_time
+FROM
+	wx_user AS a
+	LEFT JOIN company AS b ON a.company_id = b.company_id
+  LEFT JOIN (SELECT * from company_product where product_id = 1) AS bp ON a.company_id = bp.company_id
+	LEFT JOIN (SELECT user_record_id, create_platform, user_id from user_record) AS c ON a.user_id = c.user_id 
+	LEFT JOIN (SELECT * from yb_apply_record where apply_record_id in (SELECT max(apply_record_id) from yb_apply_record GROUP BY user_id)) as y on a.user_id = y.user_id
+WHERE
+	b.enabled = 1 
+	AND ( y.apply_record_id > 0 or a.company_id=1 or bp.company_product_id is null)
+	AND ( a.mobile IS NOT NULL ) 
+	AND ( a.mobile <> '' ) 
+	AND ( c.create_platform <> 4 OR c.create_platform IS NULL )
+    AND (y.status = "潜在用户" or y.status is null or y.status = "权益用户" or y.status = "流失" )
+	AND ((y.apply_record_id > 0 and y.create_time > ? and y.create_time <= ?) OR (y.apply_record_id is null AND a.created_time > ? and a.created_time <= ?) )
+  GROUP BY a.user_id ORDER BY last_time asc
+	`
+	_, err = orm.NewOrm().Raw(sql, startTime, endTime, startTime, endTime).QueryRows(&items)
 	return
 }
 
 // DealWxUser 处理用户标记状态
-func DealWxUser(userId int) (err error) {
-	sql := `update wx_user set is_deal = 1 where user_id=?`
-	_, err = orm.NewOrm().Raw(sql, userId).Exec()
+func DealWxUsers(userIds string) (err error) {
+	sql := `update wx_user set is_deal = 1 where user_id in (`+userIds+`) and is_deal=0`
+	_, err = orm.NewOrm().Raw(sql).Exec()
+	return
+}
+
+// DealFiccApply 处理用户申请标记状态
+func DealFiccApply(applyRecordIds string, dealTime time.Time) (err error) {
+	sql := `update yb_apply_record set op_status = 1, deal_time=?  where apply_record_id in (`+applyRecordIds+`) and op_status=0`
+	_, err = orm.NewOrm().Raw(sql, dealTime).Exec()
 	return
 }

+ 3 - 5
models/longzhong.go

@@ -1,11 +1,10 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import "github.com/beego/beego/v2/client/orm"
 
 func GetLongzhonginfoByClassifyId(classifyId int) (items []*Longzhonginfo, err error) {
 	sql := `SELECT * FROM longzhonginfo WHERE classify_id=? ORDER BY longzhonginfo_id ASC `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
 	return
 }
@@ -13,8 +12,7 @@ func GetLongzhonginfoByClassifyId(classifyId int) (items []*Longzhonginfo, err e
 
 func GetLongzhongpriceinfoByClassifyName(productName string) (items []*Longzhongpriceinfo, err error) {
 	sql := `SELECT * FROM longzhongpriceinfo WHERE product_name=? ORDER BY longzhongpriceinfo_id ASC `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, productName).QueryRows(&items)
 	return
 }

+ 10 - 13
models/report.go

@@ -3,7 +3,7 @@ package models
 import (
 	"fmt"
 	"hongze/hongze_task/utils"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -29,11 +29,13 @@ type Report struct {
 	VideoName          string    `description:"音频文件名称"`
 	VideoPlaySeconds   string    `description:"音频播放时长"`
 	ContentSub         string    `description:"内容前两个章节"`
+	HasChapter         int       `description:"是否有章节 0-否 1-是"`
+	ChapterType        string    `description:"章节类型 day-晨报 week-周报"`
+	OldReportId        int       `description:"research_report表ID(后续一两个版本过渡需要,之后可移除)"`
 }
 
 func GetReportById(reportId int) (item *Report, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT * FROM report WHERE id=?`
 	err = o.Raw(sql, reportId).QueryRow(&item)
 	return
@@ -41,31 +43,27 @@ func GetReportById(reportId int) (item *Report, err error) {
 
 func GetReport() (items []*Report, err error) {
 	sql := `SELECT * FROM report ORDER BY id ASC `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
 func ModifyReportContentSub(id int, contentSub string) (err error) {
 	sql := `UPDATE report SET content_sub=? WHERE id=? `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql, contentSub, id).Exec()
 	return
 }
 
 func GetReportLimit() (items []*Report, err error) {
 	sql := `SELECT * FROM report WHERE state=2 ORDER BY id DESC LIMIT 50 `
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
 func EditReportContent(reportId int, content, contentSub string) (err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
 	_, err = o.Raw(sql, content, contentSub, reportId).Exec()
 	return
@@ -78,8 +76,7 @@ func DeleteReportSaveLog() {
 }
 
 func EditReportContentHtml(reportId int, content string) (err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	sql := ` UPDATE report SET content=?,modify_time=NOW() WHERE id=? `
 	_, err = o.Raw(sql, content, reportId).Exec()
 	return

+ 1 - 1
models/report_send_ths_detail.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 2 - 3
models/report_view.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 type ResearchReportViewers struct {
@@ -31,8 +31,7 @@ func GetRddpReportViewers() (items []*ResearchReportViewers, err error) {
 			group by b.id
 			order by b.create_time desc
 			`
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 1 - 1
models/roadshow/calendar.go

@@ -1,7 +1,7 @@
 package roadshow
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/roadshow/public_meeting.go

@@ -1,7 +1,7 @@
 package roadshow
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 //公开会议总览

+ 1 - 1
models/roadshow/report.go

@@ -2,7 +2,7 @@ package roadshow
 
 import (
 	"time"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 type RsReportRecord struct {

+ 1 - 1
models/stack_company_statistic.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 4 - 7
models/user_view_statistics.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -134,16 +134,14 @@ func GetCountUserViewHistoryByEmails(date string) (items []*UserViewEmailTotalSl
 }
 
 func GetReportViewMaxTimeByMobiles(date string) (items []*UserViewMobileTotalSlice, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	rddpSql := `SELECT mobile,company_name,real_name,COUNT(1) AS total,max(create_time) view_time FROM report_view_record WHERE create_time >= ? and create_time <= ? and mobile != ""  group by mobile`
 	_, err = o.Raw(rddpSql, date+" 00:00:00", date+" 23:59:59").QueryRows(&items)
 	return
 }
 
 func GetReportViewMaxTimeByEmails(date string) (items []*UserViewEmailTotalSlice, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	rddpSql := `SELECT email,company_name,real_name,COUNT(1) AS total,max(create_time) view_time FROM report_view_record WHERE create_time >= ? and create_time <= ? and email != "" group by email`
 	_, err = o.Raw(rddpSql, date+" 00:00:00", date+" 23:59:59").QueryRows(&items)
 	return
@@ -174,8 +172,7 @@ func GetMaxUserViewHistoryByMobiles() (items []*UserViewMobileTotalSlice, err er
 }
 
 func GetMaxReportViewMaxTimeByMobiles() (items []*UserViewMobileTotalSlice, err error) {
-	o := orm.NewOrm()
-	o.Using("rddp")
+	o := orm.NewOrmUsingDB("rddp")
 	rddpSql := `SELECT mobile,company_name,real_name,COUNT(1) AS total,max(create_time) view_time FROM report_view_record WHERE  create_time <= "2022-02-15 00:00:00" and  mobile != ""  group by mobile`
 	_, err = o.Raw(rddpSql).QueryRows(&items)
 	return

+ 1 - 1
models/users.go

@@ -1,7 +1,7 @@
 package models
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strings"
 )
 

+ 1 - 1
models/wechat.go

@@ -5,7 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_task/utils"
 	"github.com/rdlucklib/rdluck_tools/http"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )

+ 1 - 1
models/wx_template_msg.go

@@ -1,6 +1,6 @@
 package models
 
-import "github.com/rdlucklib/rdluck_tools/orm"
+import "github.com/beego/beego/v2/client/orm"
 
 type SendTemplateResponse struct {
 	Errcode int    `json:"errcode"`

+ 1 - 1
models/yb/activity.go

@@ -1,7 +1,7 @@
 package yb
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/yb/activity_register.go

@@ -1,7 +1,7 @@
 package yb
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/yb/activity_remind.go

@@ -1,7 +1,7 @@
 package yb
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/yb/activity_type.go

@@ -1,7 +1,7 @@
 package yb
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/yb/activity_voice.go

@@ -1,7 +1,7 @@
 package yb
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 

+ 1 - 1
models/yb/yb_speaker.go

@@ -1,7 +1,7 @@
 package yb
 
 import (
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 // Speaker 活动表

+ 29 - 0
services/alarm_msg/alarm_msg.go

@@ -0,0 +1,29 @@
+package alarm_msg
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/http"
+	"hongze/hongze_task/utils"
+)
+
+var (
+	AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
+)
+
+//projectName-项目名称
+//runMode-运行模式
+//msgBody-消息内容
+//level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
+func SendAlarmMsg(msgBody string, level int) {
+	params := make(map[string]interface{})
+	params["ProjectName"] = utils.APPNAME
+	params["RunMode"] = utils.RunMode
+	params["MsgBody"] = msgBody
+	params["Level"] = level
+	param, err := json.Marshal(params)
+	if err != nil {
+		utils.FileLog.Info("SendAlarmMsg json.Marshal Err:" + err.Error())
+		return
+	}
+	http.Post(AlarmMsgUrl, string(param))
+}

+ 76 - 0
services/company/company_report_record.go

@@ -0,0 +1,76 @@
+package company
+
+import (
+	"context"
+	"fmt"
+	"hongze/hongze_task/models"
+	"hongze/hongze_task/utils"
+	"strconv"
+	"sync"
+	"time"
+)
+
+var companyLock sync.Mutex
+
+func AddCompanyReportRecord(cont context.Context) (err error) {
+	companyLock.Lock()
+	defer func() {
+		if err != nil {
+			fmt.Println("AddReportRecord Err:" + err.Error())
+		}
+	}()
+
+	endDate := time.Now().Format(utils.FormatDate)
+
+	existList, err := models.GetExistCompanyReportRecord(endDate)
+	if err != nil {
+		return
+	}
+	existMap := make(map[int]*models.CompanyReportRecord)
+	for _, v := range existList {
+		existMap[v.CompanyId] = v
+	}
+	list, err := models.GetCompanyList(endDate)
+	if err != nil {
+		return
+	}
+	for _, v := range list {
+		if _, ok := existMap[v.CompanyId]; ok { //修改
+			utils.FileLog.Info("update company:" + strconv.Itoa(v.CompanyId))
+			recordWhereParams := make(map[string]interface{})
+			recordWhereParams["company_id"] = v.CompanyId
+
+			recordUpdateParams := make(map[string]interface{})
+			recordUpdateParams["company_name"] = v.CompanyName
+			recordUpdateParams["status"] = v.Status
+			recordUpdateParams["start_date"] = v.StartDate
+			recordUpdateParams["end_date"] = v.EndDate
+			recordUpdateParams["seller_id"] = v.SellerId
+			recordUpdateParams["seller_name"] = v.SellerName
+			recordUpdateParams["credit_code"] = v.CreditCode
+			recordUpdateParams["modify_time"] = time.Now()
+			err = models.UpdateCompanyReportRecord(recordWhereParams, recordUpdateParams)
+		} else { //新增
+			utils.FileLog.Info("add company:" + strconv.Itoa(v.CompanyId))
+			item := new(models.CompanyReportRecord)
+			item.CompanyId = v.CompanyId
+			item.CompanyProductId = v.CompanyProductId
+			item.CompanyName = v.CompanyName
+			item.Status = v.Status
+			item.StartDate = v.StartDate
+			item.EndDate = v.EndDate
+			item.SellerId = v.SellerId
+			item.SellerName = v.SellerName
+			item.CreditCode = v.CreditCode
+			item.CreateDate = time.Now().Format(utils.FormatDate)
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			_, err = models.AddCompanyReportRecord(item)
+			if err != nil {
+				return
+			}
+		}
+	}
+	companyLock.Unlock()
+	return err
+}

+ 31 - 14
services/data/edb_info.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/http"
 	"hongze/hongze_task/models/data_manage"
+	"hongze/hongze_task/services/alarm_msg"
 	"hongze/hongze_task/utils"
 	"sync"
 )
@@ -161,17 +162,17 @@ func RefreshDataFromPb(wg *sync.WaitGroup) (err error) {
 	for _, v := range items {
 		startDate := ""
 		if v.Frequency == "日度" {
-			startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDateUnSpace)
+			startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
 		} else if v.Frequency == "周度" {
-			startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDateUnSpace)
+			startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
 		} else if v.Frequency == "月度" {
-			startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDateUnSpace)
+			startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
 		} else if v.Frequency == "季度" {
-			startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDateUnSpace)
+			startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
 		} else if v.Frequency == "年度" {
-			startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDateUnSpace)
+			startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
 		} else {
-			startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDateUnSpace)
+			startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
 		}
 		//err = SyncEdbDataByPb(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
 		//if err != nil {
@@ -214,11 +215,15 @@ func CheckDataInterface(cont context.Context) (err error) {
 			checkUrl := utils.Hz_Data_Url + `hz_server`
 			body, err := http.Get(checkUrl)
 			if err != nil {
-				go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+				//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+				msg := "检测wind数据服务器失败:CheckDataInterface ErrMsg:" + err.Error()
+				go alarm_msg.SendAlarmMsg(msg, 3)
 			} else {
 				result := string(body)
 				if result != "1" {
-					go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+					//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+					msg := "检测wind数据服务器失败:CheckDataInterface ErrMsg:" + string(body)
+					go alarm_msg.SendAlarmMsg(msg, 3)
 				}
 			}
 		}
@@ -228,11 +233,15 @@ func CheckDataInterface(cont context.Context) (err error) {
 			checkUrl2 := utils.Hz_Server_Data_Url + `hz_server`
 			body, err := http.Get(checkUrl2)
 			if err != nil {
-				go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测服务器数据接口:失败提醒", "CheckDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+				//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测服务器数据接口:失败提醒", "CheckDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+				msg := "检测同花顺数据-阿里云服务器失败:CheckPbDataInterface ErrMsg:" + err.Error()
+				go alarm_msg.SendAlarmMsg(msg, 3)
 			} else {
 				result := string(body)
 				if result != "1" {
-					go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测服务器数据接口:失败提醒", "CheckDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+					//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测服务器数据接口:失败提醒", "CheckDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+					msg := "检测同花顺数据-阿里云服务器失败:CheckPbDataInterface ErrMsg:" + err.Error()
+					go alarm_msg.SendAlarmMsg(msg, 3)
 				}
 			}
 		}
@@ -245,11 +254,15 @@ func CheckPbDataInterface(cont context.Context) (err error) {
 		checkUrl := utils.Hz_Data_PB_Url + `hz_server`
 		body, err := http.Get(checkUrl)
 		if err != nil {
-			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckPbDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckPbDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+			msg := "检测彭博数据服务器失败:CheckPbDataInterface ErrMsg:" + err.Error()
+			go alarm_msg.SendAlarmMsg(msg, 3)
 		} else {
 			result := string(body)
 			if result != "1" {
-				go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckPbDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+				//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckPbDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+				msg := "检测彭博数据服务器失败:CheckPbDataInterface ErrMsg:" + string(body)
+				go alarm_msg.SendAlarmMsg(msg, 3)
 			}
 		}
 	}()
@@ -262,11 +275,15 @@ func CheckLtDataInterface(cont context.Context) (err error) {
 		checkUrl := utils.Hz_Data_LT_Url + `hz_server`
 		body, err := http.Get(checkUrl)
 		if err != nil {
-			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+			msg := "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:" + err.Error()
+			go alarm_msg.SendAlarmMsg(msg, 3)
 		} else {
 			result := string(body)
 			if result != `"ek true"` {
-				go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+				//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
+				msg := "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:" + string(body)
+				go alarm_msg.SendAlarmMsg(msg, 3)
 			}
 		}
 	}()

+ 24 - 5
services/free_viewer.go

@@ -7,6 +7,8 @@ import (
 	"hongze/hongze_task/models"
 	"hongze/hongze_task/utils"
 	"os"
+	"strconv"
+	"strings"
 	"time"
 )
 
@@ -23,6 +25,8 @@ func FreeViewerDetail(cont context.Context) (err error) {
 	startTime := time.Now().AddDate(0, 0, -7).Format(utils.FormatDateTime)
 	endTime := time.Now().Format(utils.FormatDateTime)
 
+	userIdsStr := ""
+	applyRecordIdsStr := ""
 	items, err := models.GetFreeViewerDetails(startTime, endTime)
 	if err != nil {
 		return
@@ -54,14 +58,18 @@ func FreeViewerDetail(cont context.Context) (err error) {
 		cellB := row.AddCell()
 		cellB.Value = item.Mobile
 		cellC := row.AddCell()
-		cellC.Value = item.Note
+		cellC.Value = item.CompanyName
 		cellD := row.AddCell()
-		cellD.Value = item.CreatedTime
+		cellD.Value = item.LastTime
 		cellE := row.AddCell()
 		cellE.Value = item.Email
 
-		models.DealWxUser(item.UserId)
+		userIdsStr += ","+strconv.Itoa(item.UserId)
+		applyRecordIdsStr += ","+strconv.Itoa(item.ApplyRecordId)
 	}
+	userIdsStr = strings.Trim(userIdsStr, ",")
+	applyRecordIdsStr = strings.Trim(applyRecordIdsStr, ",")
+	_ = dealUser(userIdsStr, applyRecordIdsStr)
 
 	savePath := "free_viewer_details" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
 	err = file.Save("./" + savePath)
@@ -71,11 +79,22 @@ func FreeViewerDetail(cont context.Context) (err error) {
 	//发送邮件
 	fmt.Println("start send email")
 	sendResult := utils.SendEmailByHongze(title, "潜在客户回访记录',\"你好,上周潜在客户回访记录见附件。", utils.EmailSendToHzUsers, savePath, title+".xlsx")
-	//sendResult:=utils.SendEmailByHongze(title,"你好,上周研报阅读统计见附件。",utils.EmailSendToMe,savePath)
+	//sendResult:=utils.SendEmailByHongze(title,"潜在客户回访记录',\"你好,上周潜在客户回访记录见附件。",utils.EmailSendToMe,savePath, title+".xlsx")
 	if sendResult {
-		os.Remove(savePath)
+		_ = os.Remove(savePath)
 	}
 	//fmt.Println("send result:", sendResult)
 	fmt.Println("end send email")
 	return nil
 }
+
+func dealUser(userIds, applyRecordIds string) (err error) {
+	if userIds !="" {
+		_ = models.DealWxUsers(userIds)
+	}
+	if applyRecordIds != "" {
+		nowTime := time.Now()
+		_ = models.DealFiccApply(applyRecordIds, nowTime)
+	}
+	return
+}

+ 70 - 3
services/report_push.go

@@ -11,6 +11,7 @@ import (
 	"io/ioutil"
 	"net/http"
 	"net/url"
+	"strconv"
 	"time"
 )
 
@@ -157,6 +158,11 @@ func SendToThs(sendDetailId, reportId int, reportType string) (err error) {
 		if tmpErr != nil {
 			err = tmpErr
 		}
+	case "研报小程序":
+		tmpErr := SendReportMiniToThs(reportId)
+		if tmpErr != nil {
+			err = tmpErr
+		}
 	default:
 		err = errors.New("异常类型")
 	}
@@ -237,13 +243,13 @@ func SendReportToThs(reportId int) (err error) {
 	abstract := report.Abstract
 
 	// 实际推送到同花顺
-	err = SendThs(title, permissionStr, abstract, jumpUrl, logoUrl)
+	err = SendThs(title, permissionStr, abstract, jumpUrl, logoUrl, "1")
 
 	return
 }
 
 // SendThs 发送消息到同花顺
-func SendThs(title, labelStr, abstract, jumpBaseUrl, logoUrl string) (err error) {
+func SendThs(title, labelStr, abstract, jumpBaseUrl, logoUrl, dataType string) (err error) {
 	defer func() {
 		if err != nil {
 			//fmt.Println(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "发送消息至同花顺失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
@@ -286,7 +292,6 @@ func SendThs(title, labelStr, abstract, jumpBaseUrl, logoUrl string) (err error)
 		return
 	}
 
-	dataType := "1" //内容类型:1文字 2小程序
 	dataTypeEncript, err := gorsa.PublicEncrypt(dataType, pubKey)
 	if err != nil {
 		return
@@ -387,3 +392,65 @@ func SyncWxGroup(openCompanyCode, deadline string) (err error) {
 	}
 	return
 }
+
+// SendReportMiniToThs 发送报告小程序到同花顺
+func SendReportMiniToThs(reportId int) (err error) {
+	defer func() {
+		if err != nil {
+			//fmt.Println(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "发送消息至同花顺失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "SendReportMiniToThs延时任务发送报告至同花顺失败, ReportId:" + strconv.Itoa(reportId) + ", ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+		}
+	}()
+
+	report, tmpErr := models.GetReportById(reportId)
+	if tmpErr != nil {
+		err = tmpErr
+		return
+	}
+
+	//小程序跳转地址
+	jumpBaseUrl := utils.WxYbAppId + `/pages-report/reportDetail?reportId=`
+	jumpUrl := fmt.Sprint(jumpBaseUrl, report.Id)
+	logoUrl := `https://hongze.oss-cn-shanghai.aliyuncs.com/hzyj.png`
+
+	var permissionStr string
+	if report.HasChapter == 0 {
+		// 获取分类信息(标签)
+		permissionName := report.ClassifyNameSecond
+		classifyItem, tmpErr := models.GetClassifyById(report.ClassifyIdSecond)
+		if tmpErr != nil {
+			err = errors.New(fmt.Sprint("获取分类失败:", permissionName))
+			return
+		}
+		// 获取权限标签名称
+		if classifyItem != nil {
+			permissionStr = classifyItem.ClassifyLabel
+			if permissionStr == "" {
+				var isOk bool
+				permissionStr, isOk = permissionMap[permissionName]
+				if !isOk {
+					err = errors.New(fmt.Sprint("没有该权限的标签,权限名:", permissionName))
+					return
+				}
+			}
+		} else {
+			var isOk bool
+			permissionStr, isOk = permissionMap[permissionName]
+			if !isOk {
+				err = errors.New(fmt.Sprint("没有该权限的标签,权限名:", permissionName))
+				return
+			}
+		}
+		if permissionStr == "" {
+			err = errors.New(fmt.Sprint("没有该权限的标签,权限名:", permissionName))
+			return
+		}
+	} else {
+		// 同php的
+		permissionStr = "宏观,利率债,原油,PTA,MEG,织造终端,甲醇,聚烯烃,沥青,橡胶,苯乙烯,玻璃纯碱,钢材,铁矿,双焦(焦煤、焦炭),有色(铜、铝),有色(锌、铅),镍+不锈钢"
+	}
+	// 实际推送到同花顺
+	err = SendThs(report.Title, permissionStr, report.Abstract, jumpUrl, logoUrl, "2")
+
+	return
+}

+ 1 - 1
services/roadshow/company_product.go

@@ -2,7 +2,7 @@ package roadshow
 
 import (
 	"context"
-	"github.com/rdlucklib/rdluck_tools/orm"
+	"github.com/beego/beego/v2/client/orm"
 )
 
 func RoadShow(cont context.Context) (err error) {

+ 4 - 2
services/roadshow/report.go

@@ -11,7 +11,7 @@ import (
 	"context"
 )
 
-func AddReportRecord(cont context.Context)(err error) {
+func AddReportRecord(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
 			fmt.Println("AddReportRecord Err:" + err.Error())
@@ -36,7 +36,7 @@ func AddReportRecord(cont context.Context)(err error) {
 		companyMap[v.CompanyId] = v
 	}
 
-	endDate := time.Now().Format(utils.FormatDate)
+	endDate := time.Now().AddDate(-1, 0, 0).Format(utils.FormatDate)
 
 	existList, err := roadshow.GetExistRsReportRecord(endDate)
 	if err != nil {
@@ -72,6 +72,7 @@ func AddReportRecord(cont context.Context)(err error) {
 
 		key := strconv.Itoa(v.RsCalendarId) + "_" + strconv.Itoa(v.RsCalendarResearcherId)
 		if _, ok := existMap[key]; ok { //修改
+			utils.FileLog.Info("update:" + strconv.Itoa(v.RsCalendarId))
 			reportWhereParams := make(map[string]interface{})
 			reportWhereParams["rs_calendar_id"] = v.RsCalendarId
 			reportWhereParams["rs_calendar_researcher_id"] = v.RsCalendarResearcherId
@@ -147,6 +148,7 @@ func AddReportRecord(cont context.Context)(err error) {
 				item.SellerGroupId = 0
 				item.SellerGroupName = ""
 			}
+			utils.FileLog.Info("add:" + strconv.Itoa(v.RsCalendarId))
 			item.RsCalendarId = v.RsCalendarId
 			item.RsCalendarResearcherId = v.RsCalendarResearcherId
 			item.StartDate = v.StartDate

+ 10 - 3
services/task.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"github.com/beego/beego/v2/task"
 	"hongze/hongze_task/models"
+	"hongze/hongze_task/services/company"
 	"hongze/hongze_task/services/company_contract"
 	"hongze/hongze_task/services/data"
 	"hongze/hongze_task/services/roadshow"
@@ -97,17 +98,23 @@ func Task() {
 	addReportRecord := task.NewTask("addReportRecord", "0 0 */1 * * *", roadshow.AddReportRecord)
 	task.AddTask("addReportRecord", addReportRecord)
 
+	//存量客户数据统计
+	addCompanyReportRecord := task.NewTask("addCompanyReportRecord", "0 0 */1 * * *", company.AddCompanyReportRecord)
+	task.AddTask("addCompanyReportRecord", addCompanyReportRecord)
+
 	//CRM 6.3 客户列表路演次数统计
 	roadShowTotal := task.NewTask("roadShowTotal", "0 */30 * * * *", roadshow.RoadShow)
 	task.AddTask("roadShowTotal", roadShowTotal)
 
+	//每半个小时用户阅读数据统计
+	statisticsUserView1Hour := task.NewTask("statisticsUserView1Hour", "0 */30 * * * *", StatisticsUserView1Hour)
+	task.AddTask("每半个小时用户阅读数据统计", statisticsUserView1Hour)
+
 	//路演公开会议合并
 	setPublicMeetingUnionCode := task.NewTask("setPublicMeetingUnionCode", "0 */10 * * * *", roadshow.SetPublicMeetingUnionCode)
 	task.AddTask("setPublicMeetingUnionCode", setPublicMeetingUnionCode)
 
-	//每半个小时用户阅读数据统计
-	statisticsUserView1Hour := task.NewTask("statisticsUserView1Hour", "0 */30 * * * *", StatisticsUserView1Hour)
-	task.AddTask("每半个小时用户阅读数据统计", statisticsUserView1Hour)
+	task.StartTask()
 
 	task.StartTask()
 	fmt.Println("task end")

+ 9 - 0
utils/constants.go

@@ -113,4 +113,13 @@ var (
 var (
 	APP_EDB_LIB_NAME_EN = "hongze_edb_lib"
 	EDB_LIB_Md5_KEY     = "GuRaB6dY1bXOJcwG"
+)
+
+// 研报类型标识
+var (
+	REPORT_TYPE_DAY      = "day"
+	REPORT_TYPE_WEEK     = "week"
+	REPORT_TYPE_TWO_WEEK = "two_week"
+	REPORT_TYPE_MONTH    = "month"
+	REPORT_TYPE_OTHER    = "other"
 )

+ 2 - 2
utils/email.go

@@ -29,7 +29,7 @@ func SendEmail(title, content string, touser string) bool {
 
 	m := gomail.NewMessage()
 	//m.SetHeader("From", mailConn["user"])
-	m.SetHeader("From", m.FormatAddress("317699326@qq.com", APPNAME)) //这种方式可以添加别名,即“XX官方”
+	m.SetHeader("From", m.FormatAddress("qunao007@qq.com", APPNAME)) //这种方式可以添加别名,即“XX官方”
 	// 说明:如果是用网易邮箱账号发送,以下方法别名可以是中文,如果是qq企业邮箱,以下方法用中文别名,会报错,需要用上面此方法转码
 	//m.SetHeader("From", "FB Sample"+"<"+mailConn["user"]+">") //这种方式可以添加别名,即“FB Sample”, 也可以直接用<code>m.SetHeader("From",mailConn["user"])</code> 读者可以自行实验下效果
 	//m.SetHeader("From", mailConn["user"])
@@ -37,7 +37,7 @@ func SendEmail(title, content string, touser string) bool {
 	m.SetHeader("To", arr...)
 	m.SetHeader("Subject", title+" "+GetRandString(16))
 	m.SetBody("text/html", content)
-	d := gomail.NewDialer("smtp.qq.com", 587, "317699326@qq.com", "oqdypwfcvruwcbea")
+	d := gomail.NewDialer("smtp.qq.com", 587, "qunao007@qq.com", "cyhjgffhaobteihd")
 	//d := gomail.NewDialer(mailConn["host"], mailPort, mailConn["user"], mailConn["pass"])
 
 	if err := d.DialAndSend(m); err != nil {