Răsfoiți Sursa

Merge branch 'fic_bug_2024-11-08-roadshow' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 6 zile în urmă
părinte
comite
f69d32cf7e

+ 9 - 0
controllers/roadshow/calendar.go

@@ -1746,6 +1746,15 @@ func (this *CalendarController) Delete() {
 			br.ErrMsg = "删除失败!UpdateCalendarResearcher:" + err.Error()
 			return
 		}
+
+		itemApiLog := new(roadshow.RsCalendarApiLog)
+		itemApiLog.CreateTime = time.Now()
+		itemApiLog.Remark = "CRM手动删除"
+		itemApiLog.Url = sysUser.RealName
+		itemApiLog.Body = ""
+		itemApiLog.Result = ""
+		itemApiLog.RsCalendarResearcherId = req.RsCalendarResearcherId
+		go roadshow.AddRsCalendarApiLog(itemApiLog)
 	}
 	//`status` int(11) DEFAULT '0' COMMENT '1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束',
 	//待接受、已接受的情况,需要同步删除上海那边的日程

+ 1 - 0
models/db.go

@@ -387,6 +387,7 @@ func initRoadShow() {
 		new(roadshow.RsReportRecord),              //路演统计表
 		new(roadshow.RsCalendarMeetingUser),       //路演参会名单表
 		new(roadshow.RsCalendarMeetingLabelGroup), //路演参会名单关联的标签表
+		new(roadshow.RsCalendarApiLog),            //上海路演三方接口请求记录日志表
 	)
 }
 

+ 34 - 0
models/roadshow/rs_calendar_api_log.go

@@ -0,0 +1,34 @@
+package roadshow
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type RsCalendarApiLog struct {
+	Id                     int       `orm:"column(id);pk"`
+	Url                    string    `description:"链接"`
+	Body                   string    `description:"请求参数"`
+	Result                 string    `description:"返回参数"`
+	CreateTime             time.Time `description:"创建时间"`
+	Remark                 string    `description:"备注说明"`
+	RsCalendarResearcherId int       `description:"表rs_calendar 主键ID"`
+}
+
+// 添加日志记录
+func AddRsCalendarApiLog(item *RsCalendarApiLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 批量添加
+func AddRsCalendarApiLogList(items []*RsCalendarApiLog) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(lenitems, items)
+	return
+}

+ 31 - 1
services/roadshow/calendar.go

@@ -294,6 +294,15 @@ func getCurl(urlStr string, params url.Values, num int) (body []byte, err error)
 		err = errors.New(response.Msg)
 		return
 	}
+
+	itemApiLog := new(roadshow.RsCalendarApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Remark = "get请求上海接口"
+	itemApiLog.Url = getUrl
+	itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(params))
+	itemApiLog.Result = string(body)
+	go roadshow.AddRsCalendarApiLog(itemApiLog)
+
 	return
 }
 
@@ -357,6 +366,14 @@ func postCurl(urlStr string, form url.Values, num int) (body []byte, err error,
 		err = errors.New(response.Msg)
 		return
 	}
+
+	itemApiLog := new(roadshow.RsCalendarApiLog)
+	itemApiLog.CreateTime = time.Now()
+	itemApiLog.Remark = "post请求上海接口"
+	itemApiLog.Url = urlStr
+	itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(form))
+	itemApiLog.Result = string(body)
+	go roadshow.AddRsCalendarApiLog(itemApiLog)
 	return
 }
 
@@ -930,6 +947,7 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 		}
 	}
 
+	var itemsApiLog []*roadshow.RsCalendarApiLog
 	//上海那边已经删除了路演,这边也要同步删除
 	for _, deleteRsCalendarResearcherList := range deleteRsCalendarResearcherMap {
 		for _, deleteRsCalendarResearcher := range deleteRsCalendarResearcherList {
@@ -945,7 +963,14 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 				errMsgList = append(errMsgList, fmt.Sprint("第三方日历ID:", deleteRsCalendarResearcher.ThirdCalendarId, "删除关联关系失败;err:"+tmpErr.Error(), ";"))
 				continue
 			}
-
+			itemApiLog := new(roadshow.RsCalendarApiLog)
+			itemApiLog.CreateTime = time.Now()
+			itemApiLog.Remark = "对比上海接口之后手动删除"
+			itemApiLog.Url = fmt.Sprint("userPhone", userPhone, "currDay", currDay, "endDate", endDate)
+			itemApiLog.Body = ""
+			itemApiLog.Result = ""
+			itemApiLog.RsCalendarResearcherId = deleteRsCalendarResearcher.RsCalendarResearcherId
+			itemsApiLog = append(itemsApiLog, itemApiLog)
 			// 更新路演的同步字段
 			//calWhereParams := make(map[string]interface{})
 			//calUpdateParams := make(map[string]interface{})
@@ -954,6 +979,11 @@ func SyncCalendarFromShanghai(userPhone, startDate, endDate string) (err error)
 			//err = roadshow.UpdateRsCalendar(calWhereParams, calUpdateParams)
 		}
 	}
+
+	if len(itemsApiLog) > 0 {
+		go roadshow.AddRsCalendarApiLogList(itemsApiLog)
+	}
+
 	return
 }