|
@@ -2,15 +2,21 @@ 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 {
|
|
|
- BaseAuth
|
|
|
+ BaseCommon
|
|
|
}
|
|
|
|
|
|
// YiDongController
|
|
@@ -18,25 +24,109 @@ type YiDongController struct {
|
|
|
// @Description 易董提交报名用户审核接口
|
|
|
// @Param request body yidong.ActivityExamineReq true "type json string"
|
|
|
// @Success 200 创建成功
|
|
|
-// @router /activity/examine [post]
|
|
|
+// @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
|
|
|
}
|
|
|
- //appid权限校验
|
|
|
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
|
|
|
- list := req.List
|
|
|
+ var itemsAdd []*cygxActivity.CygxActivitySignup
|
|
|
+
|
|
|
for _, v := range list {
|
|
|
item := new(cygxActivity.ExamineStatusReq)
|
|
|
//encryptMobile := string(utils.DesBase64Encrypt([]byte(v.Mobile)))
|
|
@@ -51,10 +141,17 @@ func (c *YiDongController) ActivityExamine() {
|
|
|
go alarm_msg.SendAlarmMsg("加密手机号解密失败:"+v.Mobile, 3)
|
|
|
return
|
|
|
}
|
|
|
- item.ActivityId = activityId
|
|
|
- item.Mobile = deMobile
|
|
|
- item.ExamineStatus = v.ExamineStatus
|
|
|
- items = append(items, item)
|
|
|
+ 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 {
|
|
@@ -62,5 +159,11 @@ func (c *YiDongController) ActivityExamine() {
|
|
|
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("操作成功")
|
|
|
}
|