yidong.go 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "hongze/hz_crm_api/models/cygx"
  7. "hongze/hz_crm_api/services/alarm_msg"
  8. "hongze/hz_crm_api/utils"
  9. "io/ioutil"
  10. "net/http"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type ApifoxModalSingUpClass struct {
  16. ErrorCode *string `json:"errorCode"` // 错误码,001:活动不存在;002:该活动不支持此渠道报名;003:该手机号或邮箱已经被其他账号提交报名;004:不在报名时间;005:报名人数已满
  17. ErrorMsg *string `json:"errorMsg"` // 错误信息
  18. Result SingUpMap `json:"result"` // 结果Map,成功
  19. Success bool `json:"success"` // 成功标识,true:成功;false:失败。可作为判断报名是否成功的标识
  20. Timestamp float64 `json:"timestamp"` // 时间戳
  21. }
  22. type SingUpMap struct {
  23. Msg string `json:"msg"` // 请求信息,成功信息
  24. }
  25. type GetYidongTokenResp struct {
  26. Success bool `json:"success"` // 请求信息,成功信息
  27. AccessToken string `json:"access_token"` // token
  28. ExpiresIn int `json:"expires_in"` // 过期时间
  29. }
  30. // 易董建会成功返回的结构体
  31. type YiDongSaveRoadshowDetailResp struct {
  32. ErrorCode string `json:"errorCode"` // 错误码
  33. ErrorMsg string `json:"errorMsg"` // 错误信息
  34. Success bool `json:"success"` // 请求信息,成功信息
  35. Result YiDongSaveRoadshowDetailIdResp `json:"result"` // 返回信息
  36. }
  37. type YiDongSaveRoadshowDetailIdResp struct {
  38. ActivityId string `json:"activityId"` //易董返回的活动ID
  39. }
  40. type YiDongUpdateActivityPublishResp struct {
  41. Id string `description:"易董活动ID,为空时新增,非空时修改" json:"id"`
  42. PublishFlag string `description:"发布状态,1发布 0 取消发布" json:"publishFlag"`
  43. }
  44. // 获取路演详细信息(2.0)结构体
  45. type YiDongGetRoadshowDetailResp struct {
  46. ErrorCode string `json:"errorCode"` // 错误码
  47. ErrorMsg string `json:"errorMsg"` // 错误信息
  48. Success bool `json:"success"` // 请求信息,成功信息
  49. Result YiDongGetRoadshowDetailRespResult `json:"result"` // 返回信息
  50. }
  51. type YiDongGetRoadshowDetailRespResult struct {
  52. MeetingCode string `json:"meetingCode"` //腾讯会议号
  53. }
  54. // 获取创建人信息列表(新)结构体
  55. type YiDongGetCreateUserListResp struct {
  56. ErrorCode string `json:"errorCode"` // 错误码
  57. ErrorMsg string `json:"errorMsg"` // 错误信息
  58. Success bool `json:"success"` // 请求信息,成功信息
  59. Result YiDongGetCreateUserListResult `json:"result"` // 返回信息
  60. }
  61. type YiDongGetCreateUserListResult struct {
  62. PersonList []*PersonUser
  63. }
  64. type PersonUser struct {
  65. Id string `description:"人员id" json:"id"`
  66. PersonName string `description:"姓名" json:"personName"`
  67. JobName string `description:"职务" json:"jobName"`
  68. UserId string `description:"用户id" json:"userId"`
  69. UserName string `description:"用户账号" json:"userName"`
  70. IdentityType string `description:"身份类型:0 不可用,1可用" json:"identityType"`
  71. Lock bool `description:"锁定状态:true 锁定 false 未锁定" json:"lock"`
  72. CreatePersonName string `description:"创建人姓名:创建时必填" json:"createPersonName"`
  73. }
  74. type YidongActivityResult struct {
  75. ActivityJoinType string `json:"activityJoinType"` // 活动入会类型,01报名审核后可入会 02预约即可入会 03仅定向邀请人员可入会
  76. Banner string `json:"banner"` // 宣传图
  77. BusinessCardOpen string `json:"businessCardOpen"` // 上传名片是否开启,1是 0否
  78. BusinessCardRequired string `json:"businessCardRequired"` // 上传名片是否必填,1是 0否
  79. CertificateInformationOpen string `json:"certificateInformationOpen"` // 证件信息是否开启,1是 0否
  80. CertificateInformationRequired string `json:"certificateInformationRequired"` // 证件信息是否必填,1是 0否
  81. CompanyCodeOpen string `json:"companyCodeOpen"` // 公司代码是否开启,1是 0否
  82. CompanyCodeRequired string `json:"companyCodeRequired"` // 公司代码是否必填,1是 0否
  83. CompanyInfo string `json:"companyInfo"` // 公司名称
  84. CompanyShortNameOpen string `json:"companyShortNameOpen"` // 公司名称是否开启,1是 0否
  85. CompanyShortNameRequired string `json:"companyShortNameRequired"` // 公司名称是否必填,1是 0否
  86. End string `json:"end"` // 活动结束时间
  87. ID string `json:"id"` // 活动主键id
  88. IndustrySwName string `json:"industrySwName"` // 行业
  89. InviteeOpen *string `json:"inviteeOpen"` // 邀请机构是否开启,1是 0否
  90. InviteeRequired *string `json:"inviteeRequired"` // 邀请机构是否必填,1是 0否
  91. JobNameOpen string `json:"jobNameOpen"` // 职务是否开启,1是 0否
  92. JobNameRequired string `json:"jobNameRequired"` // 职务是否必填,1是 0否
  93. MailOpen string `json:"mailOpen"` // 邮箱是否开启,1是 0否
  94. MailRequired string `json:"mailRequired"` // 邮箱是否必填,1是 0否
  95. PersonNameOpen string `json:"personNameOpen"` // 姓名是否开启,1是 0否
  96. PersonNameRequired string `json:"personNameRequired"` // 姓名是否必填,1是 0否
  97. PersonTelephoneOpen string `json:"personTelephoneOpen"` // 手机号是否开启,1是 0否
  98. PersonTelephoneRequired string `json:"personTelephoneRequired"` // 手机号是否必填,1是 0否
  99. SignUpEnd string `json:"signUpEnd"` // 报名结束时间,适应于报名审核后可入会,为空表示不限制报名时间
  100. SignUpStart string `json:"signUpStart"` // 报名开始时间,适应于报名审核后可入会,为空表示不限制报名时间
  101. Start string `json:"start"` // 活动开始时间
  102. SyncFlag string `json:"syncFlag"` // 同步有效性,同步有效性 1有效,0失效
  103. Title string `json:"title"` // 活动主题
  104. Type string `json:"type"` // 路演类型
  105. URL string `json:"url"` // 活动短链接
  106. }
  107. type YidongApifoxModal struct {
  108. ErrorCode interface{} `json:"errorCode"`
  109. ErrorMsg interface{} `json:"errorMsg"`
  110. Result []YidongActivityResult `json:"result"`
  111. Success bool `json:"success"`
  112. Timestamp int64 `json:"timestamp"`
  113. }
  114. type YidongResultuser struct {
  115. DeviceType string `json:"deviceType"` // 参会方式,1-PC,2-Mac,3-Android,4-IOS,5-Web,6-iPad,7-Android Pad,8-小程序,0-PSTN
  116. Duration string `json:"duration"` // 云会议参会时长
  117. DurationInteract string `json:"durationInteract"` // 互动交流参会时长
  118. DurationLive string `json:"durationLive"` // 直播参会时长
  119. DurationReview string `json:"durationReview"` // 回看参会时长
  120. EndTime string `json:"endTime"` // 云会议最后退会时间
  121. EndTimeInteract string `json:"endTimeInteract"` // 互动交流最后退会时间
  122. EndTimeLive string `json:"endTimeLive"` // 直播最后退会时间
  123. EndTimeReview string `json:"endTimeReview"` // 回看最后退会时间
  124. ID string `json:"id"` // 主键id
  125. Mail string `json:"mail" comment:"电子邮件"`
  126. CompanyName string `json:"company_name" comment:"公司名称"`
  127. JobName string `json:"jobName"` // 职务
  128. MobileCountryCode string `json:"mobileCountryCode"` // 手机号国际区号码
  129. PersonName string `json:"personName"` // 姓名
  130. PersonTelephone string `json:"personTelephone"` // 用户手机号
  131. StartTime string `json:"startTime"` // 云会议最早入会时间
  132. StartTimeInteract string `json:"startTimeInteract"` // 互动交流最早入会时间
  133. StartTimeLive string `json:"startTimeLive"` // 直播最早入会时间
  134. StartTimeReview string `json:"startTimeReview"` // 回看最早入会时间
  135. Status string `json:"status"` // 状态,D表示被删除
  136. UserID string `json:"userId,omitempty"` // 用户id
  137. SignUpStatus string `json:"sign_up_status" comment:"报名状态"`
  138. }
  139. // CheckYidongActivitySignupTime 校验易董的活动是否可以 添加报名
  140. func CheckYidongActivitySignupTime(activityInfo *cygx.ActivityDetail) (errstr string) {
  141. if activityInfo.YidongSignUpEnd == "0000-00-00 00:00:00" {
  142. return
  143. }
  144. timeStart := activityInfo.YidongSignUpStart
  145. timeEnd := activityInfo.YidongSignUpEnd
  146. resultTimeStart := utils.StrTimeToTime(timeStart) //时间字符串格式转时间格式
  147. resStart := time.Now().Before(resultTimeStart)
  148. if resStart {
  149. errstr = "当前时间不可报名!"
  150. }
  151. resultTimeEnd := utils.StrTimeToTime(timeEnd) //时间字符串格式转时间格式
  152. resend := time.Now().After(resultTimeEnd)
  153. if resend {
  154. errstr = "当前时间不可报名!"
  155. }
  156. return
  157. }
  158. // YidongActivityUserSingnUp 易董的活动添加报名
  159. func YidongActivityUserSingnUp(items []*cygx.YidongActivitySignup) (err error) {
  160. url := utils.YiDongHuaWeiYunUrl + "app/hz/signAppointmentsForThird"
  161. method := "POST"
  162. for _, v := range items {
  163. defer func() {
  164. if err != nil {
  165. go alarm_msg.SendAlarmMsg("易董的活动添加报名消息失败,Err:"+err.Error(), 3)
  166. }
  167. }()
  168. payload := strings.NewReader(`{
  169. "activityId": "` + v.YidongActivityId + `",
  170. "personTelephone":"` + v.Mobile + `",
  171. "personName": "` + v.RealName + `",
  172. "companyName": "` + v.CompanyName + `",
  173. "mobileCountryCode": "+` + v.CountryCode + `",
  174. "thirdPartySource": "01"
  175. }`)
  176. client := &http.Client{}
  177. req, err := http.NewRequest(method, url, payload)
  178. if err != nil {
  179. fmt.Println(err)
  180. utils.FileLog.Info(err.Error())
  181. return err
  182. }
  183. req.Header.Add("Content-Type", "application/json")
  184. res, err := client.Do(req)
  185. if err != nil {
  186. fmt.Println(err)
  187. utils.FileLog.Info(err.Error())
  188. return err
  189. }
  190. defer res.Body.Close()
  191. var ApifoxModal *ApifoxModalSingUpClass
  192. body, err := ioutil.ReadAll(res.Body)
  193. if err != nil {
  194. fmt.Println(err)
  195. utils.FileLog.Info(err.Error())
  196. return err
  197. }
  198. itemApiLog := new(cygx.CygxThreeApiLog)
  199. itemApiLog.CreateTime = time.Now()
  200. itemApiLog.Source = 1
  201. itemApiLog.Url = url
  202. itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(payload))
  203. itemApiLog.Result = string(body)
  204. go cygx.AddCygxThreeApiLog(itemApiLog)
  205. err = json.Unmarshal(body, &ApifoxModal)
  206. }
  207. return
  208. }
  209. // GetYidongToken 获取易董证通云接口的token
  210. func GetYidongToken() (token string, err error) {
  211. defer func() {
  212. if err != nil {
  213. go alarm_msg.SendAlarmMsg("获取易董证通云接口的token失败;err:"+err.Error(), 3)
  214. }
  215. }()
  216. cacheKey := utils.YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY
  217. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  218. if ttlTime > 0 {
  219. token, _ = utils.Rc.RedisString(cacheKey)
  220. if token != "" {
  221. return
  222. }
  223. }
  224. url := utils.YiDongZhengTongYunUrl + "oauth/token?grant_type=client_credentials&response_type=token&client_id=" + utils.YiDongZhengTongYunClientId + "&client_secret=" + utils.YiDongZhengTongYunClientSecret
  225. method := "GET"
  226. client := &http.Client{}
  227. req, err := http.NewRequest(method, url, nil)
  228. if err != nil {
  229. return
  230. }
  231. res, err := client.Do(req)
  232. if err != nil {
  233. return
  234. }
  235. defer res.Body.Close()
  236. body, err := ioutil.ReadAll(res.Body)
  237. if err != nil {
  238. return
  239. }
  240. itemApiLog := new(cygx.CygxThreeApiLog)
  241. itemApiLog.CreateTime = time.Now()
  242. itemApiLog.Source = 1
  243. itemApiLog.Url = url
  244. itemApiLog.Body = ""
  245. itemApiLog.Result = string(body)
  246. go cygx.AddCygxThreeApiLog(itemApiLog)
  247. var yidongTokenResp *GetYidongTokenResp
  248. err = json.Unmarshal(body, &yidongTokenResp)
  249. if err != nil {
  250. return
  251. }
  252. token = yidongTokenResp.AccessToken
  253. err = utils.Rc.Put(cacheKey, token, time.Second*7000)
  254. if err != nil {
  255. return
  256. }
  257. return
  258. }
  259. // 易董创建/更新路演活动结构体
  260. type SaveRoadshowDetaiParam struct {
  261. Id string `description:"易董活动ID,为空时新增,非空时修改" json:"id"`
  262. PublishFlag string `description:"发布状态,1发布 0 取消发布" json:"publishFlag"`
  263. Title string `description:"主题" json:"title"`
  264. Type string `description:"类型:投资策略、深度解读、行业分析、公司分析、自定义活动" json:"type"`
  265. Start string `description:"开始时间:开始时间与结束时间,日期必须相同" json:"start"`
  266. End string `description:"结束时间:开始时间与结束时间,日期必须相同" json:"end"`
  267. CreateUserId string `description:"创建人userId:创建时必填" json:"createUserId"`
  268. CreatePersonName string `description:"创建人姓名:创建时必填" json:"createPersonName"`
  269. }
  270. // 获取创建人信息列表(新)
  271. func YiDongGetCreateUserList() (userId string) {
  272. var err error
  273. defer func() {
  274. if err != nil {
  275. fmt.Println(err)
  276. go alarm_msg.SendAlarmMsg("获取创建人信息列表(新)失败;err:"+err.Error(), 3)
  277. }
  278. }()
  279. token, _ := GetYidongToken()
  280. if token == "" {
  281. return
  282. }
  283. url := utils.YiDongZhengTongYunUrl + "interact/activityThirdApi/getCreateUserList" + "?access_token=" + token
  284. method := "POST"
  285. client := &http.Client{}
  286. req, err := http.NewRequest(method, url, strings.NewReader(""))
  287. if err != nil {
  288. fmt.Println(err)
  289. return
  290. }
  291. req.Header.Add("Content-Type", "application/json")
  292. res, err := client.Do(req)
  293. if err != nil {
  294. fmt.Println(err)
  295. return
  296. }
  297. defer res.Body.Close()
  298. body, err := ioutil.ReadAll(res.Body)
  299. if err != nil {
  300. fmt.Println(err)
  301. return
  302. }
  303. itemApiLog := new(cygx.CygxThreeApiLog)
  304. itemApiLog.CreateTime = time.Now()
  305. itemApiLog.Source = 1
  306. itemApiLog.Url = url
  307. itemApiLog.Body = ""
  308. itemApiLog.Result = string(body)
  309. go cygx.AddCygxThreeApiLog(itemApiLog)
  310. var yidongResp *YiDongGetCreateUserListResp
  311. err = json.Unmarshal(body, &yidongResp)
  312. if err != nil {
  313. return
  314. }
  315. if !yidongResp.Success {
  316. err = errors.New("获取创建人信息列表(新) 接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
  317. return
  318. }
  319. if len(yidongResp.Result.PersonList) > 0 {
  320. for _, v := range yidongResp.Result.PersonList {
  321. if v.PersonName == "高亦文" {
  322. userId = v.UserId
  323. }
  324. }
  325. }
  326. if userId == "" {
  327. err = errors.New("获取创建人信息列表(新) 接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg + string(body))
  328. return
  329. }
  330. return
  331. }
  332. //func init() {
  333. // YiDongUpdateActivityPublish(2149)
  334. //}
  335. // YiDongSaveRoadshowDetail 创建/更新路演活动(新)
  336. func YiDongSaveRoadshowDetail(activityId int) {
  337. var err error
  338. defer func() {
  339. if err != nil {
  340. fmt.Println(err)
  341. go alarm_msg.SendAlarmMsg("活动同步到易董失败;err:"+err.Error(), 3)
  342. }
  343. }()
  344. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  345. if err != nil {
  346. fmt.Println(err)
  347. return
  348. }
  349. if activityInfo == nil {
  350. return
  351. }
  352. if activityInfo.IsYidongConduct == 0 {
  353. return
  354. }
  355. token, _ := GetYidongToken()
  356. if token == "" {
  357. return
  358. }
  359. //C类分析师电话会 不对外发布
  360. if activityInfo.ActivityTypeId == 7 || activityInfo.IsBClass == 1 {
  361. activityInfo.PublishStatus = 0
  362. }
  363. //if activityInfo.PublishStatus == 0 {
  364. // return
  365. //}
  366. //获取高亦文在易董的用户ID
  367. var createUserId string
  368. createUserId = YiDongGetCreateUserList()
  369. url := utils.YiDongZhengTongYunUrl + "interact/activityThirdApi/saveRoadshowDetail" + "?access_token=" + token
  370. startTime := activityInfo.ActivityTime
  371. endTime := utils.StrTimeToTime(startTime).Add(time.Minute * 60).Format(utils.FormatDateTime) // 30分钟后为结束时间
  372. params := SaveRoadshowDetaiParam{
  373. Id: activityInfo.YidongActivityIdByCygx,
  374. PublishFlag: strconv.Itoa(activityInfo.PublishStatus),
  375. Title: activityInfo.ActivityName,
  376. Type: "行业分析",
  377. Start: startTime,
  378. End: endTime,
  379. CreateUserId: createUserId,
  380. CreatePersonName: "高亦文",
  381. }
  382. postData, err := json.Marshal(params)
  383. if err != nil {
  384. fmt.Println("PostData json.Marshal Err:" + err.Error())
  385. utils.FileLogCygx.Info("PostData json.Marshal Err:" + err.Error())
  386. return
  387. }
  388. method := "POST"
  389. client := &http.Client{}
  390. req, err := http.NewRequest(method, url, strings.NewReader(string(postData)))
  391. if err != nil {
  392. fmt.Println(err)
  393. return
  394. }
  395. req.Header.Add("Content-Type", "application/json")
  396. res, err := client.Do(req)
  397. if err != nil {
  398. fmt.Println(err)
  399. return
  400. }
  401. defer res.Body.Close()
  402. body, err := ioutil.ReadAll(res.Body)
  403. if err != nil {
  404. fmt.Println(err)
  405. return
  406. }
  407. itemApiLog := new(cygx.CygxThreeApiLog)
  408. itemApiLog.CreateTime = time.Now()
  409. itemApiLog.Source = 1
  410. itemApiLog.Url = url
  411. itemApiLog.Body = string(postData)
  412. itemApiLog.Result = string(body)
  413. go cygx.AddCygxThreeApiLog(itemApiLog)
  414. var yidongResp *YiDongSaveRoadshowDetailResp
  415. err = json.Unmarshal(body, &yidongResp)
  416. if err != nil {
  417. return
  418. }
  419. if !yidongResp.Success {
  420. err = errors.New("更新易董建会接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
  421. return
  422. }
  423. yidongActivityIdByCygx := yidongResp.Result.ActivityId
  424. YiDongGetRoadshowDetail(activityId, yidongActivityIdByCygx) //获取易董创建的腾讯会议详情,并写入到我们自己的小程序
  425. YiDongSignAppointmentsForThirdSpeaker(activityId) // 根据填入的主讲人姓名 以嘉宾的身份自动报名
  426. }
  427. // YiDongGetRoadshowDetail 获取易董创建的腾讯会议详情,并写入到我们自己的小程序
  428. func YiDongGetRoadshowDetail(activityId int, yidongActivityIdByCygx string) {
  429. var err error
  430. defer func() {
  431. if err != nil {
  432. fmt.Println(err)
  433. go alarm_msg.SendAlarmMsg("易董获取路演详细信息(2.0);err:"+err.Error(), 3)
  434. }
  435. }()
  436. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  437. if err != nil {
  438. fmt.Println(err)
  439. return
  440. }
  441. if activityInfo == nil {
  442. return
  443. }
  444. token, _ := GetYidongToken()
  445. if token == "" {
  446. return
  447. }
  448. activityInfo.YidongActivityIdByCygx = yidongActivityIdByCygx
  449. url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getRoadshowDetail" + "?access_token=" + token
  450. if activityInfo.IsYidongConduct == 0 {
  451. return
  452. }
  453. params := YiDongSaveRoadshowDetailIdResp{
  454. ActivityId: yidongActivityIdByCygx,
  455. }
  456. postData, err := json.Marshal(params)
  457. if err != nil {
  458. fmt.Println("PostData json.Marshal Err:" + err.Error())
  459. utils.FileLogCygx.Info("PostData json.Marshal Err:" + err.Error())
  460. return
  461. }
  462. method := "POST"
  463. client := &http.Client{}
  464. req, err := http.NewRequest(method, url, strings.NewReader(string(postData)))
  465. if err != nil {
  466. fmt.Println(err)
  467. return
  468. }
  469. req.Header.Add("Content-Type", "application/json")
  470. res, err := client.Do(req)
  471. if err != nil {
  472. fmt.Println(err)
  473. return
  474. }
  475. defer res.Body.Close()
  476. body, err := ioutil.ReadAll(res.Body)
  477. if err != nil {
  478. fmt.Println(err)
  479. return
  480. }
  481. itemApiLog := new(cygx.CygxThreeApiLog)
  482. itemApiLog.CreateTime = time.Now()
  483. itemApiLog.Source = 1
  484. itemApiLog.Url = url
  485. itemApiLog.Body = string(postData)
  486. itemApiLog.Result = string(body)
  487. go cygx.AddCygxThreeApiLog(itemApiLog)
  488. var yidongResp *YiDongGetRoadshowDetailResp
  489. err = json.Unmarshal(body, &yidongResp)
  490. if err != nil {
  491. return
  492. }
  493. if !yidongResp.Success {
  494. err = errors.New("易董获取路演详细信息(2.0)接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
  495. return
  496. }
  497. MeetingCode := yidongResp.Result.MeetingCode
  498. if activityInfo.TencentConferenceNumber != "" {
  499. activityInfo.Body = strings.Replace(activityInfo.Body, activityInfo.TencentConferenceNumber, MeetingCode, -1)
  500. } else {
  501. activityInfo.Body += "<p>腾讯会议号:" + MeetingCode + "</p>"
  502. }
  503. activityInfo.TencentConferenceNumber = MeetingCode
  504. err = cygx.UpdateCygxActivityTencentConferenceNumber(activityInfo)
  505. return
  506. }
  507. // 发布路演到活动广场(新)
  508. func YiDongUpdateActivityPublish(activityId int) {
  509. var err error
  510. defer func() {
  511. if err != nil {
  512. fmt.Println(err)
  513. go alarm_msg.SendAlarmMsg("发布路演到活动广场(新);err:"+err.Error(), 3)
  514. }
  515. }()
  516. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  517. if err != nil {
  518. fmt.Println(err)
  519. return
  520. }
  521. if activityInfo == nil {
  522. return
  523. }
  524. //C类分析师电话会 不对外发布
  525. if activityInfo.ActivityTypeId == 7 {
  526. activityInfo.PublishStatus = 0
  527. }
  528. token, _ := GetYidongToken()
  529. if token == "" {
  530. return
  531. }
  532. url := utils.YiDongZhengTongYunUrl + "interact/activityThirdApi/updateActivityPublish" + "?access_token=" + token
  533. if activityInfo.IsYidongConduct == 0 || activityInfo.YidongActivityIdByCygx == "" {
  534. return
  535. }
  536. params := YiDongUpdateActivityPublishResp{
  537. Id: activityInfo.YidongActivityIdByCygx,
  538. PublishFlag: strconv.Itoa(activityInfo.PublishStatus),
  539. }
  540. postData, err := json.Marshal(params)
  541. if err != nil {
  542. fmt.Println("PostData json.Marshal Err:" + err.Error())
  543. utils.FileLogCygx.Info("PostData json.Marshal Err:" + err.Error())
  544. return
  545. }
  546. method := "POST"
  547. client := &http.Client{}
  548. req, err := http.NewRequest(method, url, strings.NewReader(string(postData)))
  549. if err != nil {
  550. fmt.Println(err)
  551. return
  552. }
  553. req.Header.Add("Content-Type", "application/json")
  554. res, err := client.Do(req)
  555. if err != nil {
  556. fmt.Println(err)
  557. return
  558. }
  559. defer res.Body.Close()
  560. body, err := ioutil.ReadAll(res.Body)
  561. if err != nil {
  562. fmt.Println(err)
  563. return
  564. }
  565. itemApiLog := new(cygx.CygxThreeApiLog)
  566. itemApiLog.CreateTime = time.Now()
  567. itemApiLog.Source = 1
  568. itemApiLog.Url = url
  569. itemApiLog.Body = string(postData)
  570. itemApiLog.Result = string(body)
  571. go cygx.AddCygxThreeApiLog(itemApiLog)
  572. var yidongResp *YiDongGetRoadshowDetailResp
  573. err = json.Unmarshal(body, &yidongResp)
  574. if err != nil {
  575. return
  576. }
  577. if !yidongResp.Success {
  578. err = errors.New("发布路演到活动广场(新) 接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
  579. return
  580. }
  581. if activityInfo.PublishStatus == 0 {
  582. YiDongUpdateActivityStatus(activityId)
  583. }
  584. return
  585. }
  586. // 易董创建/更新路演活动结构体
  587. type SignAppointmentsForThirdParam struct {
  588. ActivityId string `description:"易董活动ID" json:"activityId"`
  589. MobileCountryCode string `description:"国际区号注意要带前面+号 " json:"mobileCountryCode"`
  590. PersonTelephone string `description:"手机号" json:"personTelephone"`
  591. ThirdPartySource string `description:"第三方来源;弘则固定:01" json:"thirdPartySource"`
  592. InvestorType string `description:"投资者类型 0个人1机构" json:"investorType"`
  593. PersonName string `description:"姓名" json:"personName"`
  594. CompanyName string `description:"公司名" json:"companyName"`
  595. JoinRole string `description:"1:嘉宾, 2:普通参会人员, 3:会议助理。不传默认取值2" json:"joinRole"`
  596. OutCallStatus string `description:"1:需要,0:不需要。不传取默认值0" json:"outCallStatus"`
  597. }
  598. type YiDongSignAppointmentsForThirdResp struct {
  599. ErrorCode string `json:"errorCode"` // 错误码,001:活动不存在;002:该活动不支持此渠道报名;003:该手机号或邮箱已经被其他账号提交报名;004:不在报名时间;005:报名人数已满
  600. ErrorMsg string `json:"errorMsg"` // 错误信息
  601. Success bool `json:"success"` // 成功标识,true:成功;false:失败。可作为判断报名是否成功的标识
  602. Timestamp float64 `json:"timestamp"` // 时间戳
  603. }
  604. // 根据填入的主讲人姓名 以嘉宾的身份自动报名
  605. func YiDongSignAppointmentsForThirdSpeaker(activityId int) {
  606. var err error
  607. defer func() {
  608. if err != nil {
  609. fmt.Println(err)
  610. go alarm_msg.SendAlarmMsg("易董获取路演详细信息(2.0);err:"+err.Error(), 3)
  611. }
  612. }()
  613. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  614. if err != nil {
  615. fmt.Println(err)
  616. return
  617. }
  618. if activityInfo == nil {
  619. return
  620. }
  621. speaker := activityInfo.Speaker
  622. if speaker == "" {
  623. return
  624. }
  625. // 获取admin列表-匹配联系人是否为admin用户
  626. sysUserList, err := cygx.GetAskEmail()
  627. var personNameites []*cygx.AskEmailRep
  628. if err != nil {
  629. return
  630. }
  631. //var personName string
  632. //var personTelephone string
  633. for _, v := range sysUserList {
  634. if strings.Contains(speaker, v.Name) && v.Mobile != "" {
  635. personNameites = append(personNameites, &cygx.AskEmailRep{
  636. Name: v.Name,
  637. Mobile: v.Mobile,
  638. })
  639. }
  640. }
  641. if activityInfo.IsYidongConduct == 0 || len(personNameites) == 0 {
  642. return
  643. }
  644. url := utils.YiDongHuaWeiYunUrl + "app/hz/signAppointmentsForThird"
  645. for _, v := range personNameites {
  646. params := SignAppointmentsForThirdParam{
  647. ActivityId: activityInfo.YidongActivityIdByCygx,
  648. MobileCountryCode: "+86",
  649. PersonTelephone: v.Mobile,
  650. ThirdPartySource: "01",
  651. InvestorType: "0",
  652. PersonName: v.Name,
  653. JoinRole: "1",
  654. CompanyName: "弘则研究",
  655. OutCallStatus: "0",
  656. }
  657. postData, err := json.Marshal(params)
  658. if err != nil {
  659. fmt.Println("PostData json.Marshal Err:" + err.Error())
  660. utils.FileLogCygx.Info("PostData json.Marshal Err:" + err.Error())
  661. return
  662. }
  663. method := "POST"
  664. client := &http.Client{}
  665. req, err := http.NewRequest(method, url, strings.NewReader(string(postData)))
  666. if err != nil {
  667. fmt.Println(err)
  668. return
  669. }
  670. req.Header.Add("Content-Type", "application/json")
  671. res, err := client.Do(req)
  672. if err != nil {
  673. fmt.Println(err)
  674. return
  675. }
  676. defer res.Body.Close()
  677. body, err := ioutil.ReadAll(res.Body)
  678. if err != nil {
  679. fmt.Println(err)
  680. return
  681. }
  682. itemApiLog := new(cygx.CygxThreeApiLog)
  683. itemApiLog.CreateTime = time.Now()
  684. itemApiLog.Source = 1
  685. itemApiLog.Url = url
  686. itemApiLog.Body = string(postData)
  687. itemApiLog.Result = string(body)
  688. go cygx.AddCygxThreeApiLog(itemApiLog)
  689. var yidongResp *YiDongSignAppointmentsForThirdResp
  690. err = json.Unmarshal(body, &yidongResp)
  691. if err != nil {
  692. return
  693. }
  694. if !yidongResp.Success {
  695. err = errors.New(" 根据填入的主讲人姓名 以嘉宾的身份自动报名 接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
  696. return
  697. }
  698. }
  699. return
  700. }
  701. //func init() {
  702. // YiDongUpdateActivityStatus(2180)
  703. //}
  704. // 删除路演活动(新)
  705. func YiDongUpdateActivityStatus(activityId int) {
  706. var err error
  707. defer func() {
  708. if err != nil {
  709. fmt.Println(err)
  710. go alarm_msg.SendAlarmMsg(" 删除路演活动(新);err:"+err.Error(), 3)
  711. }
  712. }()
  713. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  714. if err != nil {
  715. fmt.Println(err)
  716. return
  717. }
  718. if activityInfo == nil {
  719. return
  720. }
  721. //C类分析师电话会 不对外发布
  722. if activityInfo.ActivityTypeId == 7 {
  723. activityInfo.PublishStatus = 0
  724. }
  725. //如果关联的易董活动ID为空,那么不做处理
  726. if activityInfo.YidongActivityIdByCygx == "" {
  727. return
  728. }
  729. //如果状态是已发布,而且是易董办会那么就不做处理
  730. if activityInfo.IsYidongConduct == 1 && activityInfo.PublishStatus == 1 {
  731. return
  732. }
  733. token, _ := GetYidongToken()
  734. if token == "" {
  735. return
  736. }
  737. url := utils.YiDongZhengTongYunUrl + "interact/activityThirdApi/updateActivityStatus" + "?access_token=" + token
  738. //if activityInfo.IsYidongConduct == 0 || activityInfo.YidongActivityIdByCygx == "" {
  739. // return
  740. //}
  741. params := YiDongUpdateActivityPublishResp{
  742. Id: activityInfo.YidongActivityIdByCygx,
  743. }
  744. postData, err := json.Marshal(params)
  745. if err != nil {
  746. fmt.Println("PostData json.Marshal Err:" + err.Error())
  747. utils.FileLogCygx.Info("PostData json.Marshal Err:" + err.Error())
  748. return
  749. }
  750. method := "POST"
  751. client := &http.Client{}
  752. req, err := http.NewRequest(method, url, strings.NewReader(string(postData)))
  753. if err != nil {
  754. fmt.Println(err)
  755. return
  756. }
  757. req.Header.Add("Content-Type", "application/json")
  758. res, err := client.Do(req)
  759. if err != nil {
  760. fmt.Println(err)
  761. return
  762. }
  763. defer res.Body.Close()
  764. body, err := ioutil.ReadAll(res.Body)
  765. if err != nil {
  766. fmt.Println(err)
  767. return
  768. }
  769. itemApiLog := new(cygx.CygxThreeApiLog)
  770. itemApiLog.CreateTime = time.Now()
  771. itemApiLog.Source = 1
  772. itemApiLog.Url = url
  773. itemApiLog.Body = string(postData)
  774. itemApiLog.Result = string(body)
  775. go cygx.AddCygxThreeApiLog(itemApiLog)
  776. var yidongResp *YiDongGetRoadshowDetailResp
  777. err = json.Unmarshal(body, &yidongResp)
  778. if err != nil {
  779. return
  780. }
  781. if !yidongResp.Success {
  782. err = errors.New("删除路演活动 接口失败," + yidongResp.ErrorCode + yidongResp.ErrorMsg)
  783. return
  784. }
  785. activityInfo.Body = strings.Replace(activityInfo.Body, "腾讯会议号:"+activityInfo.TencentConferenceNumber, "", -1)
  786. activityInfo.Body = strings.Replace(activityInfo.Body, "<p></p>", "", -1)
  787. activityInfo.YidongActivityIdByCygx = ""
  788. activityInfo.TencentConferenceNumber = ""
  789. err = cygx.UpdateCygxActivityTencentConferenceNumber(activityInfo)
  790. return
  791. }
  792. // GetLoginAuthCodeReq 获取登录编码请求体
  793. type GetYiDongActivityByApiReq struct {
  794. MeetingStatus string `json:"meetingStatus" description:"会议状态必需(0未开始1进行中2已结束)多个逗号分隔"`
  795. ConveneStartStr string `json:"conveneStartStr" description:"活动日期范围开始"`
  796. ConveneEndStr string `json:"conveneEndStr" description:"活动日期范围结束"`
  797. LastUpdateTime string `json:"lastUpdateTime" description:"上次同步时间(用于筛选更新时间大于同步时间的活动数据)"`
  798. }
  799. // 根据条件获取易董建会列表信息
  800. func GetYiDongActivityListByApi(param *GetYiDongActivityByApiReq) (yiDongResult []YidongActivityResult) {
  801. var err error
  802. defer func() {
  803. if err != nil {
  804. fmt.Println(err)
  805. go alarm_msg.SendAlarmMsg(fmt.Sprint("根据条件获取易董建会列表信息 GetYiDongActivityListByApi"+err.Error(), param), 2)
  806. }
  807. }()
  808. var token string
  809. token, _ = GetYidongToken()
  810. url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getRoadshowList?access_token=" + token
  811. method := "POST"
  812. data, e := json.Marshal(param)
  813. if e != nil {
  814. err = errors.New("data json marshal err: " + e.Error())
  815. return
  816. }
  817. payload := strings.NewReader(string(data))
  818. client := &http.Client{}
  819. req, e := http.NewRequest(method, url, payload)
  820. if e != nil {
  821. err = errors.New(" http.NewRequest err: " + e.Error())
  822. return
  823. }
  824. req.Header.Add("Content-Type", "application/json")
  825. res, e := client.Do(req)
  826. if e != nil {
  827. err = errors.New(" client.Do err: " + e.Error())
  828. return
  829. }
  830. defer res.Body.Close()
  831. var ApifoxModal *YidongApifoxModal
  832. body, e := ioutil.ReadAll(res.Body)
  833. if e != nil {
  834. err = errors.New(" ioutil.ReadAll: " + e.Error())
  835. return
  836. }
  837. //添加请求日志记录
  838. itemApiLog := new(cygx.CygxThreeApiLog)
  839. itemApiLog.CreateTime = time.Now()
  840. itemApiLog.Source = 1
  841. itemApiLog.Url = url
  842. itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(payload))
  843. itemApiLog.Result = string(body)
  844. go cygx.AddCygxThreeApiLog(itemApiLog)
  845. err = json.Unmarshal(body, &ApifoxModal)
  846. if err != nil {
  847. fmt.Println("Getres.PublicGetDate Err:", err.Error())
  848. return
  849. }
  850. if len(ApifoxModal.Result) > 0 {
  851. yiDongResult = ApifoxModal.Result
  852. } else {
  853. yiDongResult = make([]YidongActivityResult, 0)
  854. }
  855. return
  856. }
  857. type GetYiDongActivityMeetByActivityIdReq struct {
  858. ActivityId string `json:"activityId" description:"活动ID"`
  859. }
  860. type YidongApifoxModaluser struct {
  861. ErrorCode interface{} `json:"errorCode"`
  862. ErrorMsg interface{} `json:"errorMsg"`
  863. Result []YidongResultuser `json:"result"`
  864. Success bool `json:"success"`
  865. Timestamp int64 `json:"timestamp"`
  866. }
  867. // 根据条件获取易董活动ID获取到会信息
  868. func GetYiDongActivityMeetDataByaAtivityId(ativityId string) (yiDongResult []YidongResultuser) {
  869. var err error
  870. defer func() {
  871. if err != nil {
  872. fmt.Println(err)
  873. go alarm_msg.SendAlarmMsg(fmt.Sprint("根据条件获取易董建会列表信息 GetYiDongActivityListByApi"+err.Error(), ativityId), 2)
  874. }
  875. }()
  876. var token string
  877. token, _ = GetYidongToken()
  878. url := utils.YiDongZhengTongYunUrl + "interact/activityManageApi/getAttendPersonList?access_token=" + token
  879. method := "POST"
  880. param := new(GetYiDongActivityMeetByActivityIdReq)
  881. param.ActivityId = ativityId
  882. data, e := json.Marshal(param)
  883. if e != nil {
  884. err = errors.New("data json marshal err: " + e.Error())
  885. return
  886. }
  887. payload := strings.NewReader(string(data))
  888. client := &http.Client{}
  889. req, e := http.NewRequest(method, url, payload)
  890. if e != nil {
  891. err = errors.New(" http.NewRequest err: " + e.Error())
  892. return
  893. }
  894. req.Header.Add("Content-Type", "application/json")
  895. res, e := client.Do(req)
  896. if e != nil {
  897. err = errors.New(" client.Do err: " + e.Error())
  898. return
  899. }
  900. defer res.Body.Close()
  901. var ApifoxModal *YidongApifoxModaluser
  902. body, e := ioutil.ReadAll(res.Body)
  903. if e != nil {
  904. err = errors.New(" ioutil.ReadAll err: " + e.Error())
  905. return
  906. }
  907. e = json.Unmarshal(body, &ApifoxModal)
  908. if e != nil {
  909. err = errors.New(" json.Unmarshal err: " + e.Error())
  910. return
  911. }
  912. //添加请求日志记录
  913. itemApiLog := new(cygx.CygxThreeApiLog)
  914. itemApiLog.CreateTime = time.Now()
  915. itemApiLog.Source = 1
  916. itemApiLog.Url = url
  917. itemApiLog.Body = utils.ReplaceSpaceAndWrap(fmt.Sprint(payload))
  918. itemApiLog.Result = string(body)
  919. go cygx.AddCygxThreeApiLog(itemApiLog)
  920. err = json.Unmarshal(body, &ApifoxModal)
  921. if err != nil {
  922. fmt.Println("Getres.PublicGetDate Err:", err.Error())
  923. return
  924. }
  925. if len(ApifoxModal.Result) > 0 {
  926. yiDongResult = ApifoxModal.Result
  927. } else {
  928. yiDongResult = make([]YidongResultuser, 0)
  929. }
  930. return
  931. }
  932. // 根据条件获取易董活动ID获取到会信息
  933. func GetYiDongActivityMeeting(yidongActivityId string, cygxActivityId int) (yiDongResult []YidongResultuser) {
  934. var err error
  935. defer func() {
  936. if err != nil {
  937. fmt.Println(err)
  938. go alarm_msg.SendAlarmMsg(fmt.Sprint("根据条件获取易董建会列表信息 GetYiDongActivityMeeting"+err.Error(), cygxActivityId), 2)
  939. }
  940. }()
  941. //跟易董返回的用户状态修改活动以提交到会状态
  942. e := cygx.UpdateCygxActivitySubmitMeetingByYidong(yidongActivityId)
  943. if e != nil {
  944. err = errors.New("UpdateCygxActivitySubmitMeetingByYidong err: " + e.Error())
  945. return
  946. }
  947. meetDataList := GetYiDongActivityMeetDataByaAtivityId(yidongActivityId)
  948. var mobiles []string
  949. var mobileStr string
  950. var mobileStrMeet string
  951. mapActivityAttendanceDetail := make(map[string]*cygx.CygxActivityAttendanceDetail)
  952. if len(meetDataList) > 0 {
  953. var itemsUpdate []*cygx.CygxActivitySignupDetail
  954. needAddAttendanc := make([]*cygx.CygxActivityAttendanceDetail, 0)
  955. for _, vresult := range meetDataList {
  956. if vresult.PersonTelephone == "" {
  957. continue
  958. }
  959. if vresult.Duration != "" || vresult.DurationReview != "" {
  960. mobiles = append(mobiles, vresult.PersonTelephone)
  961. var itemDetail = new(cygx.CygxActivitySignupDetail)
  962. if vresult.Duration != "" {
  963. itemDetail.FirstMeetingTime = vresult.StartTime
  964. itemDetail.LastMeetingTime = vresult.EndTime
  965. itemDetail.Duration = vresult.Duration
  966. itemDetail.MeetingStatusStr = "直播"
  967. } else if vresult.DurationReview != "" {
  968. itemDetail.FirstMeetingTime = vresult.StartTimeReview
  969. itemDetail.LastMeetingTime = vresult.EndTimeReview
  970. itemDetail.Duration = vresult.DurationReview
  971. itemDetail.MeetingStatusStr = "回放"
  972. }
  973. itemDetail.Position = vresult.JobName
  974. itemDetail.RealName = vresult.PersonName
  975. itemDetail.Mobile = vresult.PersonTelephone
  976. itemDetail.OutboundMobile = vresult.PersonTelephone
  977. itemDetail.IsMeeting = 1
  978. itemDetail.ActivityId = cygxActivityId
  979. mapActivityAttendanceDetail[vresult.PersonTelephone] = new(cygx.CygxActivityAttendanceDetail)
  980. mapActivityAttendanceDetail[vresult.PersonTelephone].FirstMeetingTime = vresult.StartTime
  981. mapActivityAttendanceDetail[vresult.PersonTelephone].LastMeetingTime = vresult.EndTime
  982. mapActivityAttendanceDetail[vresult.PersonTelephone].Duration = utils.GetAttendanceDetailSecondsByYiDong(vresult.Duration)
  983. itemsUpdate = append(itemsUpdate, itemDetail)
  984. }
  985. item := new(cygx.CygxActivityAttendanceDetail)
  986. item.ActivityId = cygxActivityId
  987. item.Mobile = vresult.PersonTelephone
  988. if vresult.Duration != "" {
  989. if vresult.Duration != "" {
  990. item.FirstMeetingTime = vresult.StartTime
  991. item.LastMeetingTime = vresult.EndTime
  992. item.Duration = vresult.Duration
  993. item.MeetingStatusStr = "直播"
  994. } else if vresult.DurationReview != "" {
  995. item.FirstMeetingTime = vresult.StartTimeReview
  996. item.LastMeetingTime = vresult.EndTimeReview
  997. item.Duration = vresult.DurationReview
  998. item.MeetingStatusStr = "回放"
  999. }
  1000. item.Position = vresult.JobName
  1001. item.RealName = vresult.PersonName
  1002. item.FirstMeetingTime = vresult.StartTime
  1003. item.LastMeetingTime = vresult.EndTime
  1004. item.Duration = vresult.Duration
  1005. item.IsMeetingStr = 1
  1006. mobileStrMeet += "'" + vresult.PersonTelephone + "'" + ","
  1007. item.CreateTime = time.Now()
  1008. needAddAttendanc = append(needAddAttendanc, item)
  1009. }
  1010. mobileStr += "'" + vresult.PersonTelephone + "'" + ","
  1011. }
  1012. lenmobiles := len(mobiles)
  1013. if lenmobiles > 0 {
  1014. var parsYd []interface{}
  1015. var conditionYd string
  1016. conditionYd = ` AND mobile IN (` + utils.GetOrmInReplace(lenmobiles) + `) AND activity_id=? `
  1017. parsYd = append(parsYd, mobiles, cygxActivityId)
  1018. e = cygx.UpdateCygxActivitySignupisMeetList(conditionYd, parsYd)
  1019. if e != nil {
  1020. err = errors.New("UpdateCygxActivitySignupisMeetList err: " + e.Error())
  1021. return
  1022. }
  1023. e = cygx.UpdateActivitySignupDetailMultiByYiDong(itemsUpdate)
  1024. if e != nil {
  1025. err = errors.New("UpdateActivitySignupDetailMultiByYiDong err: " + e.Error())
  1026. return
  1027. }
  1028. }
  1029. mobileStr = strings.TrimRight(mobileStr, ",")
  1030. if mobileStr == "" {
  1031. mobileStr = "1"
  1032. }
  1033. mobileStrMeet = strings.TrimRight(mobileStrMeet, ",")
  1034. if mobileStrMeet == "" {
  1035. mobileStrMeet = "1"
  1036. }
  1037. listUser, e := cygx.GetWxUserOutboundMobile(mobileStr)
  1038. if e != nil {
  1039. err = errors.New("GetWxUserOutboundMobile err: " + e.Error())
  1040. return
  1041. }
  1042. for kAdd, vAdd := range needAddAttendanc {
  1043. for _, v2 := range listUser {
  1044. if v2.OutboundMobile == vAdd.Mobile || v2.Mobile == vAdd.Mobile {
  1045. if needAddAttendanc[kAdd].CompanyId <= 1 {
  1046. needAddAttendanc[kAdd].CompanyId = v2.CompanyId
  1047. needAddAttendanc[kAdd].SellerName = v2.SellerName
  1048. needAddAttendanc[kAdd].CompanyName = v2.CompanyName
  1049. //needAddAttendanc[k].IsMeetingStr = 1
  1050. }
  1051. }
  1052. }
  1053. }
  1054. //参会记录
  1055. e = cygx.AddAttendancDetail(needAddAttendanc, cygxActivityId, mobileStrMeet)
  1056. if e != nil {
  1057. err = errors.New("AddAttendancDetail err: " + e.Error())
  1058. return
  1059. }
  1060. ////处理是否限制报名
  1061. e = AddCygxActivityRestrictSignupByAdmin(cygxActivityId)
  1062. if e != nil {
  1063. err = errors.New("AddCygxActivityRestrictSignupByAdmin err: " + e.Error())
  1064. return
  1065. }
  1066. AddctivitySignupDetailListByHand(needAddAttendanc, cygxActivityId)
  1067. }
  1068. return
  1069. }