|
@@ -127,6 +127,12 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
return
|
|
|
}
|
|
|
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
|
|
@@ -143,6 +149,56 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
itemBill.RegisterPlatform = 1
|
|
|
itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
itemBill.AdminId = AdminUser.AdminId
|
|
|
+
|
|
|
+ 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.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
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.OutboundMobile = infoUser.Mobile
|
|
|
+ if infoUser.CountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ } else {
|
|
|
+ item.CountryCode = infoUser.CountryCode
|
|
|
+ }
|
|
|
+ }
|
|
|
+ items = append(items, item)
|
|
|
+ } else {
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+ updateParams["IsValid"] = 1
|
|
|
+ updateParams["CreateTime"] = time.Now()
|
|
|
+ updateParams["IsCancel"] = 0
|
|
|
+ whereParam := map[string]interface{}{"user_id": uid, "activity_id": activityId}
|
|
|
+ err = cygx.UpdateByExpr(cygx.CygxActivitySpecialTrip{}, whereParam, updateParams)
|
|
|
+ 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小时之内,取消报名之后二次报名,不扣除流水记录
|
|
|
+ }
|
|
|
+ }
|
|
|
userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取专项调研剩余次数失败"
|
|
@@ -150,49 +206,17 @@ func (this *ActivitySpecialTripCoAntroller) AddUser() {
|
|
|
return
|
|
|
}
|
|
|
if userType == 2 {
|
|
|
- tripRemaining = tripRemaining-1-i
|
|
|
+ tripRemaining = tripRemaining-itemBill.BillDetailed-i
|
|
|
itemBill.Total = strconv.Itoa(tripRemaining) + "次"
|
|
|
} else {
|
|
|
for k, num := range mapChartName {
|
|
|
if activityInfo.ChartPermissionName == k {
|
|
|
- num = num- 1 - i
|
|
|
+ num = num- itemBill.BillDetailed - i
|
|
|
}
|
|
|
itemBill.Total += k + strconv.Itoa(num) + "次+"
|
|
|
}
|
|
|
itemBill.Total = strings.TrimRight(itemBill.Total, "+")
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- 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.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
|
|
|
- }
|
|
|
- } else {
|
|
|
- item.OutboundMobile = infoUser.Mobile
|
|
|
- if infoUser.CountryCode == "" {
|
|
|
- item.CountryCode = "86"
|
|
|
- } else {
|
|
|
- item.CountryCode = infoUser.CountryCode
|
|
|
- }
|
|
|
- }
|
|
|
- items = append(items, item)
|
|
|
itemsBill = append(itemsBill, itemBill)
|
|
|
}
|
|
|
|