|
@@ -1,10 +1,17 @@
|
|
|
package report
|
|
|
|
|
|
import (
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_yb/models/tables/company"
|
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
|
"hongze/hongze_yb/models/tables/research_report"
|
|
|
"hongze/hongze_yb/models/tables/research_report_type"
|
|
|
+ "hongze/hongze_yb/models/tables/user_record"
|
|
|
+ "hongze/hongze_yb/models/tables/wx_user"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type ResearchReportInfo struct {
|
|
@@ -60,6 +67,45 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 联系人信息
|
|
|
+ strInt64 := strconv.FormatUint(userId, 10)
|
|
|
+ id, _ := strconv.Atoi(strInt64)
|
|
|
+ wxUserInfo, err := wx_user.GetByUserId(id)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetByUserId:", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyInfo, tmpErr := company.GetByCompanyId(wxUserInfo.CompanyID)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ if tmpErr == utils.ErrNoRow {
|
|
|
+ err = errors.New("找不到该客户")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userViewHistory := &user_record.UserViewHistory{
|
|
|
+ ViewHistoryId: 0,
|
|
|
+ UserId: userId,
|
|
|
+ Mobile: wxUserInfo.Mobile,
|
|
|
+ Email: wxUserInfo.Email,
|
|
|
+ RealName: wxUserInfo.RealName,
|
|
|
+ CompanyName: companyInfo.CompanyName,
|
|
|
+ ViewTitle: "",
|
|
|
+ ViewPage: "",
|
|
|
+ ReportChapterModule: "",
|
|
|
+ CreatedTime: time.Now(),
|
|
|
+ LastUpdatedTime: time.Now(),
|
|
|
+ Type: "weekly_report",
|
|
|
+ ResearchReportId: 0,
|
|
|
+ ResearchReportTypeId: 0,
|
|
|
+ }
|
|
|
+ historyId, err := user_record.AddUserViewHistory(userViewHistory)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("AddUserViewHistory err", err.Error())
|
|
|
+ }
|
|
|
+ fmt.Println("new historyId:", historyId)
|
|
|
+
|
|
|
result = ResearchReportInfo{
|
|
|
ResearchReportInfo: reportInfo,
|
|
|
ResearchReportTypeList: researchReportTypeList,
|
|
@@ -141,7 +187,44 @@ func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (resu
|
|
|
if len(researchReportTypeContentList) > 0 {
|
|
|
add = 0
|
|
|
}
|
|
|
-
|
|
|
+ // 联系人信息
|
|
|
+ strInt64 := strconv.FormatUint(userId, 10)
|
|
|
+ id, _ := strconv.Atoi(strInt64)
|
|
|
+ wxUserInfo, err := wx_user.GetByUserId(id)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("GetByUserId:", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyInfo, tmpErr := company.GetByCompanyId(wxUserInfo.CompanyID)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ if tmpErr == utils.ErrNoRow {
|
|
|
+ err = errors.New("找不到该客户")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userViewHistory := &user_record.UserViewHistory{
|
|
|
+ ViewHistoryId: 0,
|
|
|
+ UserId: userId,
|
|
|
+ Mobile: wxUserInfo.Mobile,
|
|
|
+ Email: wxUserInfo.Email,
|
|
|
+ RealName: wxUserInfo.RealName,
|
|
|
+ CompanyName: companyInfo.CompanyName,
|
|
|
+ ViewTitle: "",
|
|
|
+ ViewPage: "",
|
|
|
+ ReportChapterModule: "",
|
|
|
+ CreatedTime: time.Now(),
|
|
|
+ LastUpdatedTime: time.Now(),
|
|
|
+ Type: "weekly_report",
|
|
|
+ ResearchReportId: 0,
|
|
|
+ ResearchReportTypeId: 0,
|
|
|
+ }
|
|
|
+ historyId, err := user_record.AddUserViewHistory(userViewHistory)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("AddUserViewHistory err", err.Error())
|
|
|
+ }
|
|
|
+ fmt.Println("new historyId:", historyId)
|
|
|
result = ResearchReportTypeContentInfo{
|
|
|
ResearchReportTypeContentList: researchReportTypeContentList,
|
|
|
ResearchReportTypeInfo: researchReportTypeInfo,
|