|
@@ -3,6 +3,7 @@ package services
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"hongze/hongze_clpt/models"
|
|
"hongze/hongze_clpt/models"
|
|
"hongze/hongze_clpt/utils"
|
|
"hongze/hongze_clpt/utils"
|
|
@@ -13,7 +14,7 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-
|
|
+
|
|
func PublicGetDate(url, authorization string) (body []byte, err error) {
|
|
func PublicGetDate(url, authorization string) (body []byte, err error) {
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -39,7 +40,7 @@ func PublicGetDate(url, authorization string) (body []byte, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func GetChartListByApi(cont context.Context) (err error) {
|
|
func GetChartListByApi(cont context.Context) (err error) {
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -190,7 +191,7 @@ func GetChartListByApi(cont context.Context) (err error) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func GetChartPtagByApi() (items []*models.ChartPtagResp, err error) {
|
|
func GetChartPtagByApi() (items []*models.ChartPtagResp, err error) {
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -225,7 +226,7 @@ func GetChartPtagByApi() (items []*models.ChartPtagResp, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func GetUserTokenByMobile(mobile string) (token string, err error) {
|
|
func GetUserTokenByMobile(mobile string) (token string, err error) {
|
|
|
|
|
|
cacheKey := fmt.Sprint("xygx_chart:chart_token:add:", "Mobile", mobile)
|
|
cacheKey := fmt.Sprint("xygx_chart:chart_token:add:", "Mobile", mobile)
|
|
@@ -270,7 +271,7 @@ func GetUserTokenByMobile(mobile string) (token string, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func GetChartCollectionByApi(mobile string, take, skip int) (items []*models.HomeChartListResp, err error, total int) {
|
|
func GetChartCollectionByApi(mobile string, take, skip int) (items []*models.HomeChartListResp, err error, total int) {
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -309,7 +310,7 @@ func GetChartCollectionByApi(mobile string, take, skip int) (items []*models.Hom
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func GetIsCollectionChart(mobile string, chartId int) (isCollection bool, err error) {
|
|
func GetIsCollectionChart(mobile string, chartId int) (isCollection bool, err error) {
|
|
|
|
|
|
list, err, _ := GetChartCollectionByApi(mobile, 9999, 0)
|
|
list, err, _ := GetChartCollectionByApi(mobile, 9999, 0)
|
|
@@ -324,7 +325,7 @@ func GetIsCollectionChart(mobile string, chartId int) (isCollection bool, err er
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func AddCollectionChart(mobile string, chartId int) (err error) {
|
|
func AddCollectionChart(mobile string, chartId int) (err error) {
|
|
authorization, err := GetUserTokenByMobile(mobile)
|
|
authorization, err := GetUserTokenByMobile(mobile)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -356,7 +357,7 @@ func AddCollectionChart(mobile string, chartId int) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
func DeleteCollectionChart(mobile string, chartId int) (err error) {
|
|
func DeleteCollectionChart(mobile string, chartId int) (err error) {
|
|
authorization, err := GetUserTokenByMobile(mobile)
|
|
authorization, err := GetUserTokenByMobile(mobile)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -384,129 +385,32 @@ func DeleteCollectionChart(mobile string, chartId int) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func DoCompany() {
|
|
+
|
|
-
|
|
+func ServerAddCygxChartRecord(wxUser *models.WxUserItem, ctagId int) {
|
|
-
|
|
+ if wxUser.CompanyId < 1 {
|
|
-
|
|
+ return
|
|
-
|
|
+ }
|
|
-
|
|
+ var err error
|
|
-
|
|
+ defer func() {
|
|
-
|
|
+ if err != nil {
|
|
-
|
|
+ fmt.Println(err)
|
|
-
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("用户阅读图表,添加浏览记录失败 ctagId", ctagId, "userId", wxUser.UserId, err.Error()), 2)
|
|
-
|
|
+ }
|
|
-
|
|
+ }()
|
|
-
|
|
+ item := new(models.CygxChartRecord)
|
|
-
|
|
+ item.ChartId = ctagId
|
|
-
|
|
+ item.UserId = wxUser.UserId
|
|
-
|
|
+ item.RealName = wxUser.RealName
|
|
-
|
|
+ item.Mobile = wxUser.Mobile
|
|
-
|
|
+ item.Email = wxUser.Email
|
|
-
|
|
+ item.CompanyId = wxUser.CompanyId
|
|
-
|
|
+ item.CompanyName = wxUser.CompanyName
|
|
-
|
|
+ item.CreateTime = time.Now()
|
|
-
|
|
+ item.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
-
|
|
+ _, e := models.AddCygxChartRecord(item)
|
|
-
|
|
+ if e != nil {
|
|
-
|
|
+ err = errors.New("AddCygxChartRecord" + e.Error())
|
|
-
|
|
+ return
|
|
-
|
|
+ }
|
|
-
|
|
+ return
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|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