|
@@ -3,6 +3,7 @@ package services
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/utils"
|
|
"hongze/hongze_cygx/utils"
|
|
@@ -245,6 +246,19 @@ func GetYiDongActivity(cont context.Context) (err error) {
|
|
mapOldYiDong[v.YidongActivityId] = v.YidongActivityId
|
|
mapOldYiDong[v.YidongActivityId] = v.YidongActivityId
|
|
mapOldYiDongBody[v.YidongActivityId] = fmt.Sprint(v.ActivityName, v.Label, v.ChartPermissionId, v.ActivityTime, v.YidongActivityEndTime, v.DistinguishedGuest)
|
|
mapOldYiDongBody[v.YidongActivityId] = fmt.Sprint(v.ActivityName, v.Label, v.ChartPermissionId, v.ActivityTime, v.YidongActivityEndTime, v.DistinguishedGuest)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 通过查研观向观向建会的易董活动
|
|
|
|
+ yiDongByCygxList, err := models.GetActivityListByYiDongByCygx()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ utils.FileLog.Info(string(err.Error()))
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ yiDongByCygxMap := make(map[string]string)
|
|
|
|
+ for _, v := range yiDongByCygxList {
|
|
|
|
+ yiDongByCygxMap[v.YidongActivityIdByCygx] = v.YidongActivityIdByCygx
|
|
|
|
+ }
|
|
|
|
+
|
|
var itemsAdd []*models.CygxActivity
|
|
var itemsAdd []*models.CygxActivity
|
|
if len(ApifoxModal.Result) > 0 {
|
|
if len(ApifoxModal.Result) > 0 {
|
|
actList := ApifoxModal.Result
|
|
actList := ApifoxModal.Result
|
|
@@ -253,6 +267,10 @@ func GetYiDongActivity(cont context.Context) (err error) {
|
|
if v.SyncFlag == "0" {
|
|
if v.SyncFlag == "0" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ //如果是通过查研观向观向建会的易董活动,就不进行更新的操作
|
|
|
|
+ if _, ok := yiDongByCygxMap[v.ID]; ok {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
var item = new(models.CygxActivity)
|
|
var item = new(models.CygxActivity)
|
|
item.YidongActivityId = v.ID
|
|
item.YidongActivityId = v.ID
|
|
item.ActivityTypeId = 3
|
|
item.ActivityTypeId = 3
|
|
@@ -550,6 +568,7 @@ func init232() {
|
|
|
|
|
|
// GetYiDongActivityMeeting获取易董到会详情
|
|
// GetYiDongActivityMeeting获取易董到会详情
|
|
func GetYiDongActivityMeeting(cont context.Context) (err error) {
|
|
func GetYiDongActivityMeeting(cont context.Context) (err error) {
|
|
|
|
+ //func GetYiDongActivityMeeting() (err error) {
|
|
var condition string
|
|
var condition string
|
|
|
|
|
|
startDate := time.Now().AddDate(0, 0, -2).Format(utils.FormatDateTime)
|
|
startDate := time.Now().AddDate(0, 0, -2).Format(utils.FormatDateTime)
|
|
@@ -579,9 +598,16 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
+ var yidongActivityId string
|
|
|
|
+ if v.YidongActivityId != "" {
|
|
|
|
+ yidongActivityId = v.YidongActivityId
|
|
|
|
+ } else if v.YidongActivityIdByCygx != "" {
|
|
|
|
+ yidongActivityId = v.YidongActivityIdByCygx
|
|
|
|
+ }
|
|
|
|
+
|
|
url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getAttendPersonList?access_token=" + token
|
|
url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getAttendPersonList?access_token=" + token
|
|
method := "POST"
|
|
method := "POST"
|
|
- payload := strings.NewReader(`{"activityId":"` + v.YidongActivityId + `"}`)
|
|
|
|
|
|
+ payload := strings.NewReader(`{"activityId":"` + yidongActivityId + `"}`)
|
|
client := &http.Client{}
|
|
client := &http.Client{}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
req, err := http.NewRequest(method, url, payload)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -614,7 +640,7 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
//跟易董返回的用户状态修改活动以提交到会状态
|
|
//跟易董返回的用户状态修改活动以提交到会状态
|
|
- err = models.UpdateCygxActivitySubmitMeetingByYidong(v.YidongActivityId)
|
|
|
|
|
|
+ err = models.UpdateCygxActivitySubmitMeetingByYidong(yidongActivityId)
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("UpdateCygxActivitySubmitMeetingByYidong Err:", err.Error())
|
|
fmt.Println("UpdateCygxActivitySubmitMeetingByYidong Err:", err.Error())
|
|
return err
|
|
return err
|
|
@@ -622,7 +648,7 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
|
|
var mobiles []string
|
|
var mobiles []string
|
|
if len(ApifoxModal.Result) > 0 {
|
|
if len(ApifoxModal.Result) > 0 {
|
|
itemlog := new(models.CygxYidongActivityMeetingApiLog)
|
|
itemlog := new(models.CygxYidongActivityMeetingApiLog)
|
|
- itemlog.YidongActivityId = v.YidongActivityId
|
|
|
|
|
|
+ itemlog.YidongActivityId = yidongActivityId
|
|
itemlog.Data = string(body)
|
|
itemlog.Data = string(body)
|
|
itemlog.CreateTime = time.Now()
|
|
itemlog.CreateTime = time.Now()
|
|
err = models.AddCygxYidongActivityMeetingApiLog(itemlog)
|
|
err = models.AddCygxYidongActivityMeetingApiLog(itemlog)
|
|
@@ -718,3 +744,115 @@ func YidongActivityGroup(subjectName string, activityId int) (err error) {
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 会前一小时将,报名信息同步到易董
|
|
|
|
+func YiDongSignAppointmentsForThird(cont context.Context) (err error) {
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ go utils.SendAlarmMsg("会前一小时将,报名信息同步到易董,同步失败"+err.Error(), 2)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ var pars []interface{}
|
|
|
|
+ var condition string
|
|
|
|
+ startDate := time.Now().Add(+time.Minute * 45).Format(utils.FormatDateTime)
|
|
|
|
+ endDate := time.Now().Add(+time.Minute * 60).Format(utils.FormatDateTime)
|
|
|
|
+ condition = " AND yidong_activity_id_by_cygx != '' AND activity_time BETWEEN ? AND ? "
|
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
|
+ activityList, err := models.GetActivityListByCondition(condition, pars)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ url := utils.YiDongHuaWeiYunUrl + "app/hz/signAppointmentsForThird"
|
|
|
|
+ for _, v := range activityList {
|
|
|
|
+ var parsSignUp []interface{}
|
|
|
|
+ var conditionSignUp string
|
|
|
|
+ conditionSignUp += ` AND activity_id = ?`
|
|
|
|
+ parsSignUp = append(parsSignUp, v.ActivityId)
|
|
|
|
+ conditionSignUp += ` AND do_fail_type = 0 `
|
|
|
|
+ listSignUp, e := models.GetActivitySignuListByUser(conditionSignUp, parsSignUp)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = errors.New("GetActivitySignuListByUser, Err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(listSignUp) == 0 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ for _, vS := range listSignUp {
|
|
|
|
+ params := SignAppointmentsForThirdParam{
|
|
|
|
+ ActivityId: v.YidongActivityIdByCygx,
|
|
|
|
+ MobileCountryCode: "+" + vS.CountryCode,
|
|
|
|
+ PersonTelephone: vS.OutboundMobile,
|
|
|
|
+ ThirdPartySource: "01",
|
|
|
|
+ InvestorType: "0",
|
|
|
|
+ PersonName: vS.RealName,
|
|
|
|
+ JoinRole: "2",
|
|
|
|
+ CompanyName: vS.CompanyName,
|
|
|
|
+ OutCallStatus: "1",
|
|
|
|
+ }
|
|
|
|
+ postData, e := json.Marshal(params)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = e
|
|
|
|
+ fmt.Println("PostData json.Marshal Err:" + err.Error())
|
|
|
|
+ utils.FileLog.Info("PostData json.Marshal Err:" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ method := "POST"
|
|
|
|
+ client := &http.Client{}
|
|
|
|
+ req, e := http.NewRequest(method, url, strings.NewReader(string(postData)))
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = e
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ req.Header.Add("Content-Type", "application/json")
|
|
|
|
+ res, e := client.Do(req)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = e
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ defer res.Body.Close()
|
|
|
|
+ body, e := ioutil.ReadAll(res.Body)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = e
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ itemApiLog := new(models.CygxThreeApiLog)
|
|
|
|
+ itemApiLog.CreateTime = time.Now()
|
|
|
|
+ itemApiLog.Source = 1
|
|
|
|
+ itemApiLog.Url = url
|
|
|
|
+ itemApiLog.Body = string(postData)
|
|
|
|
+ itemApiLog.Result = string(body)
|
|
|
|
+ go models.AddCygxThreeApiLog(itemApiLog)
|
|
|
|
+ var yidongResp *YiDongSignAppointmentsForThirdResp
|
|
|
|
+ err = json.Unmarshal(body, &yidongResp)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if !yidongResp.Success {
|
|
|
|
+ err = errors.New(" 会前一小时将,报名信息同步到易董,同步失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type SignAppointmentsForThirdParam struct {
|
|
|
|
+ ActivityId string `description:"易董活动ID" json:"activityId"`
|
|
|
|
+ MobileCountryCode string `description:"国际区号注意要带前面+号 " json:"mobileCountryCode"`
|
|
|
|
+ PersonTelephone string `description:"手机号" json:"personTelephone"`
|
|
|
|
+ ThirdPartySource string `description:"第三方来源;弘则固定:01" json:"thirdPartySource"`
|
|
|
|
+ InvestorType string `description:"投资者类型 0个人1机构" json:"investorType"`
|
|
|
|
+ PersonName string `description:"姓名" json:"personName"`
|
|
|
|
+ CompanyName string `description:"公司名" json:"companyName"`
|
|
|
|
+ JoinRole string `description:"1:嘉宾, 2:普通参会人员, 3:会议助理。不传默认取值2" json:"joinRole"`
|
|
|
|
+ OutCallStatus string `description:"1:需要,0:不需要。不传取默认值0" json:"outCallStatus"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type YiDongSignAppointmentsForThirdResp struct {
|
|
|
|
+ ErrorCode string `json:"errorCode"` // 错误码,001:活动不存在;002:该活动不支持此渠道报名;003:该手机号或邮箱已经被其他账号提交报名;004:不在报名时间;005:报名人数已满
|
|
|
|
+ ErrorMsg string `json:"errorMsg"` // 错误信息
|
|
|
|
+ Success bool `json:"success"` // 成功标识,true:成功;false:失败。可作为判断报名是否成功的标识
|
|
|
|
+ Timestamp float64 `json:"timestamp"` // 时间戳
|
|
|
|
+}
|