|
@@ -63,7 +63,7 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
uids += strconv.Itoa(v.UserId) + ","
|
|
|
}
|
|
|
uids = strings.TrimRight(uids, ",")
|
|
|
- for i, v := range uidList {
|
|
|
+ for _, v := range uidList {
|
|
|
uid := v.UserId
|
|
|
wxUser, userErr := models.GetWxUserByUserId(uid)
|
|
|
if userErr != nil {
|
|
@@ -115,106 +115,138 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- total, errtotal := cygx.GetActivitySpecialTripCount(uid, activityId)
|
|
|
- if errtotal != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + errtotal.Error()
|
|
|
- return
|
|
|
- }
|
|
|
+ //total, errtotal := cygx.GetActivitySpecialTripCount(uid, activityId)
|
|
|
+ //if errtotal != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + errtotal.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
infoUser, err := cygx.GetUserAndCompanyNameList(uid)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- if total == 0 {
|
|
|
- totalAll, err := cygx.GetUserActivitySpecialTripCount(uid, activityId)
|
|
|
+ //if total == 0 {
|
|
|
+ totalAll, err := cygx.GetUserActivitySpecialTripCount(uid, activityId)
|
|
|
+ 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 = 1
|
|
|
+ itemBill.BillDetailed = -1 // 流水减一
|
|
|
+ itemBill.RegisterPlatform = 3
|
|
|
+ itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ itemBill.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
+ itemBill.AdminId = AdminUser.AdminId
|
|
|
+
|
|
|
+ if activityInfo.ChartPermissionName == utils.CE_LUE_NAME {
|
|
|
+ //如果是策略行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
|
|
|
+ maxChartPermissionId, maxChartPermissionName, err := cygxService.GetSpecialBillMaxChartPermissionId(infoUser)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取销售信息失败,GetSpecialBillMaxChartPermissionId 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 = 1
|
|
|
- itemBill.BillDetailed = -1 // 流水减一
|
|
|
- itemBill.RegisterPlatform = 1
|
|
|
- itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
- itemBill.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
- itemBill.AdminId = AdminUser.AdminId
|
|
|
+ itemBill.ChartPermissionId = maxChartPermissionId
|
|
|
+ itemBill.ChartPermissionName = maxChartPermissionName
|
|
|
+ }
|
|
|
|
|
|
- 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
|
|
|
- }
|
|
|
+ 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.OutboundMobile = infoUser.Mobile
|
|
|
- if infoUser.CountryCode == "" {
|
|
|
- item.CountryCode = "86"
|
|
|
- } else {
|
|
|
- item.CountryCode = infoUser.CountryCode
|
|
|
- }
|
|
|
+ item.CountryCode = infoUser.OutboundCountryCode
|
|
|
}
|
|
|
- items = append(items, item)
|
|
|
} else {
|
|
|
- err = cygx.UpdateSpecialTrip(1, 0, uid, activityId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "报名失败,"
|
|
|
- br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
|
|
|
- //48小时之内的取消也扣除一次参会记录
|
|
|
- if time.Now().Add(+time.Hour * 48).After(resultTime) {
|
|
|
- itemBill.BillDetailed = 0 //48小时之内,取消报名之后二次报名,不扣除流水记录
|
|
|
+ item.OutboundMobile = infoUser.Mobile
|
|
|
+ if infoUser.CountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = infoUser.CountryCode
|
|
|
}
|
|
|
}
|
|
|
- userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
|
|
|
+ items = append(items, item)
|
|
|
+ err = cygxService.DeductTripRemainingtimesByUser(infoUser, activityInfo) //扣除用户专项调研剩余次数
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取专项调研剩余次数失败"
|
|
|
- br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- if userType == 2 {
|
|
|
- tripRemaining = tripRemaining + itemBill.BillDetailed - i
|
|
|
- itemBill.Total = strconv.Itoa(tripRemaining) + "次"
|
|
|
+ } else {
|
|
|
+ err = cygx.UpdateSpecialTrip(1, 0, uid, activityId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "报名失败,"
|
|
|
+ br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
|
|
|
+ //48小时之内的取消也扣除一次参会记录
|
|
|
+ if time.Now().Add(+time.Hour * 48).After(resultTime) {
|
|
|
+ itemBill.BillDetailed = 0 //48小时之内,取消报名之后二次报名,不扣除流水记录
|
|
|
} else {
|
|
|
- for k, num := range mapChartName {
|
|
|
- if activityInfo.ChartPermissionName == k {
|
|
|
- num = num + itemBill.BillDetailed - i
|
|
|
- }
|
|
|
- itemBill.Total += k + strconv.Itoa(num) + "次+"
|
|
|
+ err = cygxService.DeductTripRemainingtimesByUser(infoUser, activityInfo) //扣除用户专项调研剩余次数
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
}
|
|
|
- itemBill.Total = strings.TrimRight(itemBill.Total, "+")
|
|
|
}
|
|
|
- itemsBill = append(itemsBill, itemBill)
|
|
|
}
|
|
|
+ //userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取专项调研剩余次数失败"
|
|
|
+ // br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //if userType == 2 {
|
|
|
+ // tripRemaining = tripRemaining + itemBill.BillDetailed - i
|
|
|
+ // itemBill.Total = strconv.Itoa(tripRemaining) + "次"
|
|
|
+ //} else {
|
|
|
+ // for k, num := range mapChartName {
|
|
|
+ // if activityInfo.ChartPermissionName == k {
|
|
|
+ // num = num + itemBill.BillDetailed - i
|
|
|
+ // }
|
|
|
+ // itemBill.Total += k + strconv.Itoa(num) + "次+"
|
|
|
+ // }
|
|
|
+ // itemBill.Total = strings.TrimRight(itemBill.Total, "+")
|
|
|
+ //}
|
|
|
+ totalText, err := cygxService.HandleActivitySpecialTripBillTotalText(infoUser)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "报名失败,"
|
|
|
+ br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ itemBill.Total = totalText
|
|
|
+ itemsBill = append(itemsBill, itemBill)
|
|
|
+ //}
|
|
|
|
|
|
var itemMeeting = new(cygx.CygxActivitySpecialMeetingDetail)
|
|
|
itemMeeting.UserId = v.UserId
|
|
@@ -530,16 +562,36 @@ func (this *ActivitySpecialTripCoAntroller) TripCancel() {
|
|
|
itemBill.Source = 2
|
|
|
itemBill.DoType = 2
|
|
|
itemBill.BillDetailed = 1 // 流水加一
|
|
|
- itemBill.RegisterPlatform = 1
|
|
|
+ itemBill.RegisterPlatform = 3
|
|
|
itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
itemBill.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
itemBill.AdminId = sysUser.AdminId
|
|
|
+
|
|
|
+ if activityInfo.ChartPermissionName == utils.CE_LUE_NAME {
|
|
|
+ //如果是策略行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
|
|
|
+ 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 {
|
|
@@ -547,24 +599,31 @@ func (this *ActivitySpecialTripCoAntroller) TripCancel() {
|
|
|
br.ErrMsg = "修改失败 Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
|
|
|
+ //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)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取专项调研剩余次数失败"
|
|
|
- br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
|
|
|
+ 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, "+")
|
|
|
- }
|
|
|
+ itemBill.Total = totalText
|
|
|
err = cygx.AddCygxActivitySpecialTripBill(itemBill)
|
|
|
if err != nil {
|
|
|
br.Msg = "修改失败"
|