|
@@ -49,6 +49,7 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
}
|
|
|
roleTypeCode := AdminUser.RoleTypeCode
|
|
|
var items []*cygx.CygxActivitySpecialTrip
|
|
|
+ var itemsRedis []*cygx.CygxActivitySpecialTrip
|
|
|
var itemsBill []*cygx.CygxActivitySpecialTripBill
|
|
|
var itemsMeet []*cygx.CygxActivitySpecialMeetingDetail
|
|
|
activityIds := req.ActivityIds
|
|
@@ -64,6 +65,16 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
uids += strconv.Itoa(v.UserId) + ","
|
|
|
}
|
|
|
uids = strings.TrimRight(uids, ",")
|
|
|
+
|
|
|
+ if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
|
|
|
+ err = cygxService.CheckSpecialActivityPointsByUserIds(uids, len(activityIdList)) //根据用户ID,活动场次,校验用户是否有剩余点数报名专项调研活动
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for _, v := range uidList {
|
|
|
uid := v.UserId
|
|
|
wxUser, userErr := models.GetWxUserByUserId(uid)
|
|
@@ -82,7 +93,7 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
}
|
|
|
limitPeopleNum := activityInfo.LimitPeopleNum
|
|
|
if limitPeopleNum > 0 {
|
|
|
- if AdminUser.RoleTypeCode != "admin" {
|
|
|
+ if AdminUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
|
|
|
havePower, err := cygxService.GetSpecialDetailUserPower(wxUser, activityInfo)
|
|
|
if err != nil {
|
|
|
br.Msg = "用户权限校验失败!"
|
|
@@ -129,46 +140,38 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- if totalAll > 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
|
|
|
- if totalAll == 0 {
|
|
|
- item := new(cygx.CygxActivitySpecialTrip)
|
|
|
- item.UserId = infoUser.UserId
|
|
|
- item.RealName = infoUser.RealName
|
|
|
- item.SellerName = infoUser.SellerName
|
|
|
- item.ActivityId = activityId
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.Mobile = infoUser.Mobile
|
|
|
- item.Email = infoUser.Email
|
|
|
- item.CompanyId = infoUser.CompanyId
|
|
|
- item.CompanyName = infoUser.CompanyName
|
|
|
- item.AdminId = AdminUser.AdminId
|
|
|
- item.Source = 2
|
|
|
- //优先绑定用户修改过的外呼手机号
|
|
|
- if infoUser.OutboundMobile != "" {
|
|
|
- item.OutboundMobile = infoUser.OutboundMobile
|
|
|
- if infoUser.OutboundCountryCode == "" {
|
|
|
- item.CountryCode = "86"
|
|
|
- } else {
|
|
|
- item.CountryCode = infoUser.OutboundCountryCode
|
|
|
- }
|
|
|
+ item := new(cygx.CygxActivitySpecialTrip)
|
|
|
+ item.UserId = infoUser.UserId
|
|
|
+ item.RealName = infoUser.RealName
|
|
|
+ item.SellerName = infoUser.SellerName
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = infoUser.Mobile
|
|
|
+ item.Email = infoUser.Email
|
|
|
+ item.CompanyId = infoUser.CompanyId
|
|
|
+ item.CompanyName = infoUser.CompanyName
|
|
|
+ item.AdminId = AdminUser.AdminId
|
|
|
+ item.Source = 2
|
|
|
+ //优先绑定用户修改过的外呼手机号
|
|
|
+ if infoUser.OutboundMobile != "" {
|
|
|
+ item.OutboundMobile = infoUser.OutboundMobile
|
|
|
+ if infoUser.OutboundCountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
} else {
|
|
|
- item.OutboundMobile = infoUser.Mobile
|
|
|
- if infoUser.CountryCode == "" {
|
|
|
- item.CountryCode = "86"
|
|
|
- } else {
|
|
|
- item.CountryCode = infoUser.CountryCode
|
|
|
- }
|
|
|
+ item.CountryCode = infoUser.OutboundCountryCode
|
|
|
}
|
|
|
- items = append(items, item)
|
|
|
- err = cygxService.DeductTripRemainingtimesByUser(infoUser, activityInfo, roleTypeCode) //扣除用户专项调研剩余次数
|
|
|
- if err != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ } else {
|
|
|
+ item.OutboundMobile = infoUser.Mobile
|
|
|
+ if infoUser.CountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = infoUser.CountryCode
|
|
|
}
|
|
|
+ }
|
|
|
+ itemsRedis = append(itemsRedis, item)
|
|
|
+ if totalAll == 0 {
|
|
|
+ items = append(items, item)
|
|
|
} else {
|
|
|
err = cygx.UpdateSpecialTrip(1, 0, uid, activityId)
|
|
|
if err != nil {
|
|
@@ -197,9 +200,9 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
br.ErrMsg = "新增用户失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- if len(items) > 0 {
|
|
|
+ if len(itemsRedis) > 0 {
|
|
|
//9用户报名添加到处理研选扣点
|
|
|
- for _, v := range items {
|
|
|
+ for _, v := range itemsRedis {
|
|
|
time.Sleep(100 * time.Millisecond) // 添加0.1秒的延时
|
|
|
cygxService.SpecialActivityPointsBillSignupAddSpecial(v.ActivityId, v.UserId, AdminUser.AdminId)
|
|
|
}
|
|
@@ -480,57 +483,11 @@ func (this *ActivitySpecialTripCoAntroller) TripCancel() {
|
|
|
br.ErrMsg = "操作失败,Err:" + errInfo.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- infoUser, err := cygx.GetUserAndCompanyNameList(userId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- //流水记录表
|
|
|
- //itemBill := new(cygx.CygxActivitySpecialTripBill)
|
|
|
- //itemBill.UserId = infoUser.UserId
|
|
|
- //itemBill.ActivityId = activityInfo.ActivityId
|
|
|
- //itemBill.CreateTime = time.Now()
|
|
|
- //itemBill.Mobile = infoUser.Mobile
|
|
|
- //itemBill.Email = infoUser.Email
|
|
|
- //itemBill.CompanyId = infoUser.CompanyId
|
|
|
- //itemBill.CompanyName = infoUser.CompanyName
|
|
|
- //itemBill.RealName = infoUser.RealName
|
|
|
- //itemBill.Source = 2
|
|
|
- //itemBill.DoType = 2
|
|
|
- //itemBill.BillDetailed = 1 // 流水加一
|
|
|
- //itemBill.RegisterPlatform = 3
|
|
|
- //itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
- //itemBill.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
- //itemBill.AdminId = sysUser.AdminId
|
|
|
-
|
|
|
- //if activityInfo.ChartPermissionName == utils.CE_LUE_NAME || activityInfo.ChartPermissionName == utils.GU_SHOU_NAME {
|
|
|
- //if utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
|
|
|
- // //如果是策略、固收行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
|
|
|
- // lastTripBill, err := cygx.GetCygxActivitySpecialTripBillLastDetialByActivityId(activityInfo.ActivityId, userId)
|
|
|
- // if err != nil {
|
|
|
- // br.Msg = "操作失败"
|
|
|
- // br.ErrMsg = "获取销售信息失败,GetCygxActivitySpecialTripBillLastDetialByActivityId Err:" + err.Error()
|
|
|
- // return
|
|
|
- // }
|
|
|
- // itemBill.ChartPermissionId = lastTripBill.ChartPermissionId
|
|
|
- // itemBill.ChartPermissionName = lastTripBill.ChartPermissionName
|
|
|
- //}
|
|
|
-
|
|
|
resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
|
|
|
//48小时之内的取消也扣除一次参会记录
|
|
|
var isValid int
|
|
|
if time.Now().Add(+time.Hour * 48).After(resultTime) {
|
|
|
isValid = 1
|
|
|
- //itemBill.BillDetailed = 0 // 48小时之内取消的,照样扣点,流水不进行加一
|
|
|
- } else {
|
|
|
- err = cygxService.RebateTripRemainingtimesByUser(infoUser, activityInfo) // 返点
|
|
|
- if err != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,RebateTripRemainingtimesByUserErr:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
}
|
|
|
err = cygx.ActivitySpecialTripCancel(isValid, activityId, userId)
|
|
|
if err != nil {
|
|
@@ -538,37 +495,6 @@ func (this *ActivitySpecialTripCoAntroller) TripCancel() {
|
|
|
br.ErrMsg = "修改失败 Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- //userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
|
|
|
- //if err != nil {
|
|
|
- // br.Msg = "获取专项调研剩余次数失败"
|
|
|
- // br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if userType == 2 {
|
|
|
- // tripRemaining += itemBill.BillDetailed
|
|
|
- // itemBill.Total = strconv.Itoa(tripRemaining) + "次"
|
|
|
- //} else {
|
|
|
- // for k, num := range mapChartName {
|
|
|
- // if activityInfo.ChartPermissionName == k {
|
|
|
- // num += itemBill.BillDetailed
|
|
|
- // }
|
|
|
- // itemBill.Total += k + strconv.Itoa(num) + "次+"
|
|
|
- // }
|
|
|
- // itemBill.Total = strings.TrimRight(itemBill.Total, "+")
|
|
|
- //}
|
|
|
- //totalText, err := cygxService.HandleActivitySpecialTripBillTotalText(infoUser.CompanyId)
|
|
|
- //if err != nil {
|
|
|
- // br.Msg = "报名失败,"
|
|
|
- // br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //itemBill.Total = totalText
|
|
|
- //err = cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
- //if err != nil {
|
|
|
- // br.Msg = "修改失败"
|
|
|
- // br.ErrMsg = "修改失败流水记录添加失败 Err:" + err.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
go cygxService.ActivityPointsBillSignupCancelSpecial(activityId, userId, sysUser.AdminId) // 用户取消报名专项调研活动扣点处理
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -800,12 +726,12 @@ func (this *ActivitySpecialTripCoAntroller) MeetingDo() {
|
|
|
return
|
|
|
}
|
|
|
if userType == 2 {
|
|
|
- tripRemaining += itemBill.BillDetailed
|
|
|
+ //tripRemaining += itemBill.BillDetailed要处理
|
|
|
itemBill.Total = strconv.Itoa(tripRemaining) + "次"
|
|
|
} else {
|
|
|
for k, num := range mapChartName {
|
|
|
if activityInfo.ChartPermissionName == k {
|
|
|
- num += itemBill.BillDetailed
|
|
|
+ //num += itemBill.BillDetailed要处理
|
|
|
}
|
|
|
itemBill.Total += k + strconv.Itoa(num) + "次+"
|
|
|
}
|