123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "hongze/hongze_open_api/models/request/yidong"
- cygxActivity "hongze/hongze_open_api/models/tables/cygx_activity"
- "hongze/hongze_open_api/services/alarm_msg"
- servicesYidong "hongze/hongze_open_api/services/yidong"
- "hongze/hongze_open_api/utils"
- "math"
- "strconv"
- "strings"
- "time"
- )
- // 易董
- type YiDongController struct {
- BaseCommon
- }
- // YiDongController
- // @Title 易董提交报名用户审核接口
- // @Description 易董提交报名用户审核接口
- // @Param request body yidong.ActivityExamineReq true "type json string"
- // @Success 200 创建成功
- // @router /activity/examine/signup [post]
- func (c *YiDongController) ActivityExamine() {
- var req yidong.ActivityExamineReq
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
- if err != nil {
- c.FailWithMessage("参数解析异常")
- return
- }
- activityIdYiDong := req.ActivityId
- timeInt := req.Time
- list := req.List
- appid := req.Appid
- timeUnix := time.Now().Unix() //当前格林威治时间,int64类型
- timestamp := int64(timeInt)
- if math.Abs(float64(timeUnix-timestamp)) > 600 {
- c.FailWithMessage("当前时间异常,请调整设备时间与北京时间一致:" + strconv.Itoa(timeInt))
- return
- }
- //校验 APPID 与ip白名单
- ip := c.Ctx.Input.IP()
- err = servicesYidong.CheckAppidAndIp(appid, ip)
- if err != nil {
- c.FailWithMessage(err.Error())
- return
- }
- //校验 签名
- paramStr := fmt.Sprintf(`activity_id=%stime=%s`, activityIdYiDong, strconv.Itoa(timeInt))
- signStr := servicesYidong.GetSign(paramStr)
- fmt.Println("____")
- fmt.Println(signStr)
- ownSign := req.Sign
- if ownSign != signStr {
- c.FailWithMessage("签名错误!")
- return
- }
- activityInfo, err := cygxActivity.GetAddActivityInfoById(activityIdYiDong)
- if err != nil {
- c.FailWithMessage("会议id异常:" + activityIdYiDong)
- return
- }
- activityId := activityInfo.ActivityId
- signupList, err := cygxActivity.GetActivitySignupListByActivity(activityId)
- if err != nil {
- c.FailWithMessage("会议id异常:" + activityIdYiDong)
- return
- }
- mapSignUp := make(map[string]string)
- for _, v := range signupList {
- mapSignUp[v.Mobile] = v.Mobile
- }
- var examineMobile string
- for _, v := range list {
- var dateTxt = []byte(v.Mobile)
- resultDe := utils.DesBase64Decrypt(dateTxt)
- deMobile := string(resultDe)
- if deMobile == "" {
- go alarm_msg.SendAlarmMsg("加密手机号解密失败:"+v.Mobile, 3)
- c.FailWithMessage("加密手机号解密失败:" + v.Mobile)
- return
- }
- examineMobile += "'" + deMobile + "'" + ","
- }
- examineMobile = strings.TrimRight(examineMobile, ",")
- userList, err := cygxActivity.GetUserListByMobile(examineMobile)
- if err != nil {
- c.FailWithMessage("操作失败,用户信息不存在")
- return
- }
- mapUserinfo := make(map[string]*cygxActivity.CygxActivitySignup)
- for _, v := range userList {
- item := new(cygxActivity.CygxActivitySignup)
- item.UserId = v.UserId
- item.RealName = v.RealName
- item.SellerName = v.SellerName
- item.ActivityId = activityId
- item.CreateTime = time.Now()
- item.Mobile = v.Mobile
- item.Email = v.Email
- item.CompanyId = v.CompanyId
- item.CompanyName = v.CompanyName
- item.Source = 3
- //优先绑定用户修改过的外呼手机号
- if v.OutboundMobile != "" {
- item.OutboundMobile = v.OutboundMobile
- if v.OutboundCountryCode == "" {
- item.CountryCode = "86"
- } else {
- item.CountryCode = v.OutboundCountryCode
- }
- } else {
- item.OutboundMobile = v.Mobile
- if v.CountryCode == "" {
- item.CountryCode = "86"
- } else {
- item.CountryCode = v.CountryCode
- }
- }
- item.SignupType = 1
- mapUserinfo[v.Mobile] = item
- }
- var items []*cygxActivity.ExamineStatusReq
- var itemsAdd []*cygxActivity.CygxActivitySignup
- for _, v := range list {
- item := new(cygxActivity.ExamineStatusReq)
- //encryptMobile := string(utils.DesBase64Encrypt([]byte(v.Mobile)))
- //fmt.Println(encryptMobile)
- //continue
- //encryptMobile := string(utils.DesBase64Encrypt([]byte(v.Mobile)))
- var dateTxt = []byte(v.Mobile)
- resultDe := utils.DesBase64Decrypt(dateTxt)
- deMobile := string(resultDe)
- if deMobile == "" {
- c.FailWithMessage("加密手机号解密失败:" + v.Mobile)
- go alarm_msg.SendAlarmMsg("加密手机号解密失败:"+v.Mobile, 3)
- return
- }
- if mapSignUp[deMobile] != "" {
- item.ActivityId = activityId
- item.Mobile = deMobile
- item.ExamineStatus = v.ExamineStatus
- items = append(items, item)
- } else {
- if mapUserinfo[deMobile] != nil {
- mapUserinfo[deMobile].YidongExamineStatus = v.ExamineStatus
- itemsAdd = append(itemsAdd, mapUserinfo[deMobile])
- }
- }
- }
- err = cygxActivity.UpdateActivitySignupNumMulti(items)
- if err != nil {
- c.FailWithMessage("修改活动审核状态失败:" + activityIdYiDong)
- go alarm_msg.SendAlarmMsg("修改活动审核状态失败:"+err.Error()+"活动ID"+activityIdYiDong, 3)
- return
- }
- err = cygxActivity.AddActivitySignupNumMulti(itemsAdd)
- if err != nil {
- c.FailWithMessage("修改活动审核状态失败:" + activityIdYiDong)
- go alarm_msg.SendAlarmMsg("修改活动审核状态失败:"+err.Error()+"活动ID"+activityIdYiDong, 3)
- return
- }
- c.OkWithMessage("操作成功")
- }
|