|
@@ -136,6 +136,46 @@ func YanXuanActivityPointsBillSubmitMeeting(activityId, adminId int) (err error)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 用户报名专项调研活动扣点处理
|
|
|
+func SpecialActivityPointsBillSignupAddSpecial(activityId, uid int) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
|
|
|
+ go utils.SendAlarmMsg("用户报名专项调研活动扣点处理,写入Redis队列消息失败 SpecialActivityPointsBillSignupAddSpecial :"+err.Error()+msg, 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
|
|
|
+ log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 9, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
|
|
|
+ if utils.Re == nil {
|
|
|
+ err = utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户取消报名专项调研活动扣点处理
|
|
|
+func ActivityPointsBillSignupCancelSpecial(activityId, uid int) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
|
|
|
+ go utils.SendAlarmMsg("用户取消报名专项调研活动扣点处理,写入Redis队列消息失败 ActivityPointsBillSignupCancelSpecial :"+err.Error()+msg, 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
|
|
|
+ log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 10, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
|
|
|
+ if utils.Re == nil {
|
|
|
+ err = utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// YanXuanActivityPointsBillReduce 处理研选活动扣点
|
|
|
func YanXuanActivityPointsBillReduce() (err error) {
|
|
|
for {
|
|
@@ -167,17 +207,34 @@ func YanXuanActivityPointsBillReduce() (err error) {
|
|
|
go YanXuanActivityPointsBillSubmitMeetingReduce(log)
|
|
|
fmt.Println("5:活动到会研选扣点处理。")
|
|
|
case 6:
|
|
|
- go YanXuanCompanyApprovalReduce(log)
|
|
|
+ //go YanXuanCompanyApprovalReduce(log)
|
|
|
fmt.Println("6:研选审批通过的时候研选扣点更新。")
|
|
|
break
|
|
|
case 7:
|
|
|
- go YanXuanCompanyCompanyTryOutReduce(log)
|
|
|
+ //go YanXuanCompanyCompanyTryOutReduce(log)
|
|
|
fmt.Println("7:正式专试用定时任务更新研选扣点。")
|
|
|
break
|
|
|
case 8:
|
|
|
- go YanXuanActivityVivoPointsBillSignupReduce(log)
|
|
|
+ //go YanXuanActivityVivoPointsBillSignupReduce(log)
|
|
|
fmt.Println("8:播放研选扣点音视频。")
|
|
|
break
|
|
|
+ case 9:
|
|
|
+ go YanXuanActivityPointsBillSignupAddReduceSpecial(log)
|
|
|
+ fmt.Println("9:报名专项调研活动。")
|
|
|
+ break
|
|
|
+ case 10:
|
|
|
+ go SpecialActivityPointsBillSignupCancelReduce(log)
|
|
|
+ fmt.Println(" 10:取消报名专项调研活动")
|
|
|
+ break
|
|
|
+ case 11:
|
|
|
+ go ActivitySpecialCompanyApprovalReduce(log)
|
|
|
+ fmt.Println("11:合同审批通过的时候,专项调研点数更新。")
|
|
|
+ break
|
|
|
+ case 12:
|
|
|
+ go ActivitySpecialPointsBillSubmitMeetingReduce(log)
|
|
|
+ fmt.Println("12,专项调研活动提交到会点数更新。")
|
|
|
+ break
|
|
|
+
|
|
|
default:
|
|
|
fmt.Println(string(b))
|
|
|
go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+string(b), 2)
|
|
@@ -229,7 +286,7 @@ func YanXuanActivityPointsBillSignupAddReduce(log models.YanXuanActivityPointsRe
|
|
|
}
|
|
|
companyId := user.CompanyId
|
|
|
//判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
|
|
|
- total, e := models.GetCygxActivityPointsCompanyCountByCompanyId(companyId)
|
|
|
+ total, e := models.GetCygxActivitySpecialPermissionPointsCountByCompanyId(companyId)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetCygxActivityPointsCompanyCountByCompanyId, Err: " + e.Error())
|
|
|
return
|
|
@@ -237,31 +294,30 @@ func YanXuanActivityPointsBillSignupAddReduce(log models.YanXuanActivityPointsRe
|
|
|
var companyPointsNum float64
|
|
|
if total == 0 {
|
|
|
companyPointsNum = 0
|
|
|
- itemPointsCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemPointsCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
|
|
|
itemPointsCompany.CompanyId = companyId
|
|
|
itemPointsCompany.CompanyName = user.CompanyName
|
|
|
itemPointsCompany.CreateTime = time.Now()
|
|
|
itemPointsCompany.ModifyTime = time.Now()
|
|
|
|
|
|
- e = models.AddCygxActivityPointsCompany(itemPointsCompany)
|
|
|
+ e = models.AddCygxActivitySpecialPermissionPoints(itemPointsCompany)
|
|
|
if e != nil {
|
|
|
- err = errors.New("AddCygxActivityPointsCompany, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
// 获取用户所在公司剩余的点
|
|
|
- companyPointsNum, e = models.GetCompanyPoints(user.CompanyId)
|
|
|
+ companyPointsNum, e = models.GetCygxActivitySpecialPermissionPoints(user.CompanyId)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//获取需要添加的流水信息
|
|
|
- var items []*models.CygxActivityPointsBill
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.UserId = user.UserId
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
@@ -275,20 +331,22 @@ func YanXuanActivityPointsBillSignupAddReduce(log models.YanXuanActivityPointsRe
|
|
|
item.AdminId = log.AdminId
|
|
|
item.Source = log.Source
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
item.DoType = 1
|
|
|
item.Content = activityInfo.ActivityName + "--报名"
|
|
|
- item.Points = companyPointsNum - activityPointsSetDetail.UserPointsNum
|
|
|
+ item.Total = fmt.Sprint(companyPointsNum-activityPointsSetDetail.UserPointsNum, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
- var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemCompany.CompanyId = user.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = companyPointsNum - activityPointsSetDetail.UserPointsNum
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
|
|
|
- err = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -333,7 +391,7 @@ func YanXuanActivityPointsBillSignupCancelReduce(log models.YanXuanActivityPoint
|
|
|
}
|
|
|
|
|
|
// 获取用户所在公司剩余的点
|
|
|
- companyPointsNum, e := models.GetCompanyPoints(user.CompanyId)
|
|
|
+ companyPointsNum, e := models.GetCygxActivitySpecialPermissionPoints(user.CompanyId)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
return
|
|
@@ -342,17 +400,17 @@ func YanXuanActivityPointsBillSignupCancelReduce(log models.YanXuanActivityPoint
|
|
|
//查询最新的一条针对这个用户的扣点记录
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
- condition += ` AND activity_id = ? AND user_id = ? AND bill_detailed < 0 ORDER BY id DESC LIMIT 1 `
|
|
|
+ condition += ` AND activity_id = ? AND user_id = ? AND table_source = 'activity' AND bill_detailed < 0 ORDER BY id DESC LIMIT 1 `
|
|
|
pars = append(pars, activityId, userId)
|
|
|
- activityPointsBillDetail, e := models.GetCygxActivityPointsBillDetailByCondition(condition, pars)
|
|
|
+ activityPointsBillDetail, e := models.GetCygxActivitySpecialTripBillByCondition(condition, pars)
|
|
|
if e != nil {
|
|
|
- err = errors.New("activityPointsBillDetail" + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialTripBillByCondition" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//获取需要添加的流水信息
|
|
|
- var items []*models.CygxActivityPointsBill
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.UserId = user.UserId
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
@@ -366,20 +424,22 @@ func YanXuanActivityPointsBillSignupCancelReduce(log models.YanXuanActivityPoint
|
|
|
item.AdminId = log.AdminId
|
|
|
item.Source = log.Source
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
item.DoType = 2
|
|
|
item.Content = activityInfo.ActivityName + "--取消报名"
|
|
|
- item.Points = companyPointsNum - activityPointsBillDetail.BillDetailed
|
|
|
+ item.Total = fmt.Sprint(companyPointsNum-activityPointsBillDetail.BillDetailed, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
- var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemCompany.CompanyId = user.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = companyPointsNum - activityPointsBillDetail.BillDetailed
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
|
|
|
- err = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -431,17 +491,17 @@ func YanXuanActivityPointsBillActivityEditReduce(log models.YanXuanActivityPoint
|
|
|
//查询最新的一条针对这个公司的扣点记录
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
- condition += ` AND activity_id = ? AND company_id = ? AND mobile = '' AND bill_detailed < 0 ORDER BY id DESC LIMIT 1 `
|
|
|
+ condition += ` AND activity_id = ? AND company_id = ? AND mobile = '' AND table_source = 'activity' AND bill_detailed < 0 ORDER BY id DESC LIMIT 1 `
|
|
|
pars = append(pars, activityId, comapnyId)
|
|
|
- activityPointsBillDetail, e := models.GetCygxActivityPointsBillDetailByCondition(condition, pars)
|
|
|
+ activityPointsBillDetail, e := models.GetCygxActivitySpecialTripBillByCondition(condition, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- var items []*models.CygxActivityPointsBill
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
- var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
|
|
|
if activityPointsBillDetail == nil { //如果是空的就添加
|
|
|
//获取需要添加的流水信息
|
|
@@ -460,17 +520,19 @@ func YanXuanActivityPointsBillActivityEditReduce(log models.YanXuanActivityPoint
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
item.DoType = 1
|
|
|
item.Content = activityInfo.ActivityName + "--办会"
|
|
|
- item.Points = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
+ //item.Points = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
+ item.Total = fmt.Sprint(companyPointsNum-activityPointsSetDetail.CompanyPointsNum, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
itemCompany.CompanyId = comapny.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- e = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ e = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("AddCygxActivityPointsBillMulti, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxActivitySpecialTripBillMulti, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
@@ -478,17 +540,17 @@ func YanXuanActivityPointsBillActivityEditReduce(log models.YanXuanActivityPoint
|
|
|
if activityPointsSetDetail.CompanyPointsNum != -activityPointsBillDetail.BillDetailed {
|
|
|
item.Id = activityPointsBillDetail.Id
|
|
|
item.BillDetailed = -activityPointsSetDetail.CompanyPointsNum
|
|
|
- item.Points = companyPointsNum - activityPointsBillDetail.BillDetailed - activityPointsSetDetail.CompanyPointsNum
|
|
|
+ item.Total = fmt.Sprint(companyPointsNum-activityPointsBillDetail.BillDetailed-activityPointsSetDetail.CompanyPointsNum, "次")
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
itemCompany.CompanyId = comapny.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = companyPointsNum - activityPointsBillDetail.BillDetailed - activityPointsSetDetail.CompanyPointsNum
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- e = models.UpdateCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ e = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("UpdateCygxActivityPointsBillMulti, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxActivitySpecialTripBillMulti, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -530,9 +592,9 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
}
|
|
|
|
|
|
comapnyId := activityPointsSetDetail.CompanyId
|
|
|
- var items []*models.CygxActivityPointsBill
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
|
|
|
- var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
mapCompanyPoints := make(map[int]float64) //一组公司的剩余点数
|
|
|
if publishStatus == 1 {
|
|
|
fmt.Println("//活动发布")
|
|
@@ -548,7 +610,7 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
|
//item.Mobile = user.Mobile
|
|
@@ -561,18 +623,21 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
item.AdminId = log.AdminId
|
|
|
item.Source = log.Source
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
item.DoType = 1
|
|
|
item.Content = activityInfo.ActivityName + "--办会"
|
|
|
- item.Points = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
+ //item.Points = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
+ item.Total = fmt.Sprint(companyPointsNum-activityPointsSetDetail.CompanyPointsNum, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemCompany.CompanyId = comapny.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- mapCompanyPoints[comapnyId] = item.Points
|
|
|
+ mapCompanyPoints[comapnyId] = companyPointsNum - activityPointsSetDetail.CompanyPointsNum
|
|
|
}
|
|
|
|
|
|
if activityPointsSetDetail.UserPointsNum > 0 && activityPointsSetDetail.PointsType == 1 {
|
|
@@ -597,9 +662,9 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
pars = append(pars, companyIds)
|
|
|
|
|
|
//获取这些公司剩余的点数
|
|
|
- conpanyList, e := models.GetCygxActivityPointsCompanyList(condition, pars)
|
|
|
+ conpanyList, e := models.GetCygxActivitySpecialPermissionPointsList(condition, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCygxActivityPointsCompanyList, Err: " + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsList, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -610,7 +675,7 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
}
|
|
|
|
|
|
for _, user := range listSignup {
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
|
item.Mobile = user.Mobile
|
|
@@ -627,16 +692,18 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
item.DoType = 1
|
|
|
item.Content = activityInfo.ActivityName + "--发布活动"
|
|
|
mapCompanyPoints[user.CompanyId] -= activityPointsSetDetail.UserPointsNum //通过map处理机构剩余点数
|
|
|
- item.Points = mapCompanyPoints[user.CompanyId]
|
|
|
+ //item.Points = mapCompanyPoints[user.CompanyId]
|
|
|
+ item.Total = fmt.Sprint(mapCompanyPoints[user.CompanyId], "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemCompany.CompanyId = user.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = mapCompanyPoints[user.CompanyId]
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
+ mapCompanyPoints[user.CompanyId] = mapCompanyPoints[user.CompanyId]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -657,7 +724,7 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
|
//item.Mobile = user.Mobile
|
|
@@ -672,15 +739,17 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
item.DoType = 2
|
|
|
item.Content = activityInfo.ActivityName + "--取消办会"
|
|
|
- item.Points = companyPointsNum + activityPointsSetDetail.CompanyPointsNum
|
|
|
+ //item.Points = companyPointsNum + activityPointsSetDetail.CompanyPointsNum
|
|
|
+ item.Total = fmt.Sprint(companyPointsNum+activityPointsSetDetail.CompanyPointsNum, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
items = append(items, item)
|
|
|
//更新对应机构的剩余点数
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemCompany.CompanyId = comapny.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = companyPointsNum + activityPointsSetDetail.CompanyPointsNum
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- mapCompanyPoints[comapnyId] = item.Points
|
|
|
+ mapCompanyPoints[comapnyId] = companyPointsNum + activityPointsSetDetail.CompanyPointsNum
|
|
|
}
|
|
|
|
|
|
if activityPointsSetDetail.UserPointsNum > 0 && activityPointsSetDetail.PointsType == 1 {
|
|
@@ -705,9 +774,9 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
pars = append(pars, companyIds)
|
|
|
|
|
|
//获取这些公司剩余的点数
|
|
|
- conpanyList, e := models.GetCygxActivityPointsCompanyList(condition, pars)
|
|
|
+ conpanyList, e := models.GetCygxActivitySpecialPermissionPointsList(condition, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCygxActivityPointsCompanyList, Err: " + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsList, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -718,24 +787,23 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
}
|
|
|
|
|
|
pars = make([]interface{}, 0)
|
|
|
- condition = ` AND activity_id = ? `
|
|
|
+ condition = ` AND activity_id = ? AND table_source = 'activity' `
|
|
|
pars = append(pars, activityId)
|
|
|
//获取扣点的流水记录
|
|
|
- activityPointsBillList, e := models.GetCygxActivityPointsBillList(condition, pars)
|
|
|
+ activityPointsBillList, e := models.GetCygxActivitySpecialTripBill(condition, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCygxActivityPointsBillList" + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialTripBill" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
mapUserBill := make(map[int]bool)
|
|
|
for _, v := range activityPointsBillList {
|
|
|
mapUserBill[v.UserId] = true
|
|
|
}
|
|
|
-
|
|
|
for _, user := range listSignup {
|
|
|
if !mapUserBill[user.UserId] {
|
|
|
continue // 如果用户的扣点记录不存在,那么就不进行返点处理
|
|
|
}
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
|
item.Mobile = user.Mobile
|
|
@@ -752,23 +820,27 @@ func YanXuanActivityPointsBillActivityPublishAndCancelReduce(log models.YanXuanA
|
|
|
item.DoType = 2
|
|
|
item.Content = activityInfo.ActivityName + "--取消活动"
|
|
|
mapCompanyPoints[user.CompanyId] += activityPointsSetDetail.UserPointsNum //通过map处理机构剩余点数
|
|
|
- item.Points = mapCompanyPoints[user.CompanyId]
|
|
|
+ //item.Points = mapCompanyPoints[user.CompanyId]
|
|
|
+
|
|
|
+ item.Total = fmt.Sprint(mapCompanyPoints[user.CompanyId], "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
+
|
|
|
items = append(items, item)
|
|
|
|
|
|
//更新对应机构的剩余点数
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemCompany.CompanyId = user.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
+ itemCompany.Points = mapCompanyPoints[user.CompanyId]
|
|
|
itemCompany.ModifyTime = time.Now()
|
|
|
itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
+ //mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- e = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ e = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("AddCygxActivityPointsBillMulti, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxActivitySpecialTripBillMulti, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
return
|
|
@@ -814,7 +886,7 @@ func YanXuanActivityPointsBillSubmitMeetingReduce(log models.YanXuanActivityPoin
|
|
|
mapCompanyPoints := make(map[int]float64) //一组公司的剩余点数
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
- condition += ` AND activity_id = ? AND is_meeting = 1 `
|
|
|
+ condition += ` AND activity_id = ? `
|
|
|
pars = append(pars, activityId)
|
|
|
|
|
|
//获取提交到会的人员信息
|
|
@@ -831,22 +903,22 @@ func YanXuanActivityPointsBillSubmitMeetingReduce(log models.YanXuanActivityPoin
|
|
|
|
|
|
companyId := v.CompanyId
|
|
|
//判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
|
|
|
- total, e := models.GetCygxActivityPointsCompanyCountByCompanyId(companyId)
|
|
|
+ total, e := models.GetCygxActivitySpecialPermissionPointsCountByCompanyId(companyId)
|
|
|
if e != nil {
|
|
|
- err = errors.New("GetCygxActivityPointsCompanyCountByCompanyId, Err: " + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsCountByCompanyId, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if total == 0 {
|
|
|
- itemPointsCompany := new(models.CygxActivityPointsCompany)
|
|
|
+ itemPointsCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
itemPointsCompany.CompanyId = companyId
|
|
|
itemPointsCompany.CompanyName = v.CompanyName
|
|
|
itemPointsCompany.CreateTime = time.Now()
|
|
|
itemPointsCompany.ModifyTime = time.Now()
|
|
|
|
|
|
- e = models.AddCygxActivityPointsCompany(itemPointsCompany)
|
|
|
+ e = models.AddCygxActivitySpecialPermissionPoints(itemPointsCompany)
|
|
|
if e != nil {
|
|
|
- err = errors.New("AddCygxActivityPointsCompany, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -857,24 +929,26 @@ func YanXuanActivityPointsBillSubmitMeetingReduce(log models.YanXuanActivityPoin
|
|
|
condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
|
|
|
pars = append(pars, companyIds)
|
|
|
//获取这些公司剩余的点数
|
|
|
- conpanyList, e := models.GetCygxActivityPointsCompanyList(condition, pars)
|
|
|
+ conpanyList, e := models.GetCygxActivitySpecialPermissionPointsList(condition, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCygxActivityPointsCompanyList, Err: " + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsList, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
pars = make([]interface{}, 0)
|
|
|
- condition = ` AND activity_id = ? AND mobile != '' `
|
|
|
+ condition = ` AND activity_id = ? AND table_source = 'activity' AND mobile != '' ORDER BY id DESC `
|
|
|
pars = append(pars, activityId)
|
|
|
//获取扣点的流水记录
|
|
|
- activityPointsBillList, e := models.GetCygxActivityPointsBillList(condition, pars)
|
|
|
+ activityPointsBillList, e := models.GetCygxActivitySpecialTripBill(condition, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetCygxActivityPointsBillList" + e.Error())
|
|
|
+ err = errors.New("GetCygxActivitySpecialTripBill" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- mapActivityPointsBill := make(map[string]*models.CygxActivityPointsBill)
|
|
|
- for _, v := range activityPointsBillList {
|
|
|
- mapActivityPointsBill[v.Mobile] = v
|
|
|
+ mapActivityPointsBill := make(map[string]*models.CygxActivitySpecialTripBill)
|
|
|
+ for _, v := range activityPointsBillList { //获取这场活动,某个手机号最后一次的扣点记录
|
|
|
+ if mapActivityPointsBill[v.Mobile] == nil {
|
|
|
+ mapActivityPointsBill[v.Mobile] = v
|
|
|
+ }
|
|
|
}
|
|
|
//return
|
|
|
for _, v := range conpanyList {
|
|
@@ -884,10 +958,10 @@ func YanXuanActivityPointsBillSubmitMeetingReduce(log models.YanXuanActivityPoin
|
|
|
}
|
|
|
|
|
|
//return
|
|
|
- var items []*models.CygxActivityPointsBill
|
|
|
- var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
for _, user := range signUpDetailList {
|
|
|
- item := new(models.CygxActivityPointsBill)
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
item.ActivityId = activityId
|
|
|
item.CreateTime = time.Now()
|
|
|
item.UserId = user.UserId
|
|
@@ -900,42 +974,51 @@ func YanXuanActivityPointsBillSubmitMeetingReduce(log models.YanXuanActivityPoin
|
|
|
item.AdminId = log.AdminId
|
|
|
item.Source = log.Source
|
|
|
item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
- //如果没有扣点记录就对他们进行扣点处理
|
|
|
- if mapActivityPointsBill[user.Mobile] == nil {
|
|
|
- item.BillDetailed = -activityPointsSetDetail.UserPointsNum
|
|
|
- item.DoType = 1
|
|
|
- item.Content = activityInfo.ActivityName + "--活动到会"
|
|
|
- item.Points = mapCompanyPoints[user.CompanyId] - activityPointsSetDetail.UserPointsNum
|
|
|
- items = append(items, item)
|
|
|
- //更新对应机构的剩余点数
|
|
|
- itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
- itemCompany.CompanyId = user.CompanyId
|
|
|
- itemCompany.Points = item.Points
|
|
|
- itemCompany.ModifyTime = time.Now()
|
|
|
- itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
+ if user.IsMeeting == 1 {
|
|
|
+ //如果没有扣点记录就对他们进行扣点处理
|
|
|
+ if mapActivityPointsBill[user.Mobile] == nil || mapActivityPointsBill[user.Mobile].BillDetailed > 0 {
|
|
|
+ points := mapCompanyPoints[user.CompanyId] - activityPointsSetDetail.UserPointsNum
|
|
|
+ item.BillDetailed = -activityPointsSetDetail.UserPointsNum
|
|
|
+ item.DoType = 1
|
|
|
+ item.Content = activityInfo.ActivityName + "--活动到会"
|
|
|
+ item.Total = fmt.Sprint(points, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
+ //item.Points = mapCompanyPoints[user.CompanyId] - activityPointsSetDetail.UserPointsNum
|
|
|
+ items = append(items, item)
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = points
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ mapCompanyPoints[user.CompanyId] = points
|
|
|
+ }
|
|
|
} else {
|
|
|
////第二次提交改成未到会的,对其进行返点处理
|
|
|
- //if mapActivityPointsBill[user.Mobile].BillDetailed < 0 {
|
|
|
- // item.BillDetailed = activityPointsSetDetail.UserPointsNum
|
|
|
- // item.DoType = 2
|
|
|
- // item.Content = activityInfo.ActivityName + "--活动取消到会"
|
|
|
- // item.Points = mapCompanyPoints[user.CompanyId] + activityPointsSetDetail.UserPointsNum
|
|
|
- // items = append(items, item)
|
|
|
- //
|
|
|
- // //更新对应机构的剩余点数
|
|
|
- // itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
- // itemCompany.CompanyId = user.CompanyId
|
|
|
- // itemCompany.Points = item.Points
|
|
|
- // itemCompany.ModifyTime = time.Now()
|
|
|
- // itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- // mapCompanyPoints[user.CompanyId] = item.Points
|
|
|
- //}
|
|
|
+ if mapActivityPointsBill[user.Mobile] != nil && mapActivityPointsBill[user.Mobile].BillDetailed < 0 {
|
|
|
+ fmt.Println("取消到会了")
|
|
|
+ points := mapCompanyPoints[user.CompanyId] + activityPointsSetDetail.UserPointsNum
|
|
|
+ item.BillDetailed = activityPointsSetDetail.UserPointsNum
|
|
|
+ item.DoType = 2
|
|
|
+ item.Content = activityInfo.ActivityName + "--活动取消到会"
|
|
|
+ //item.Points =points
|
|
|
+ item.Total = fmt.Sprint(points, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITY
|
|
|
+ items = append(items, item)
|
|
|
+
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = points
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ mapCompanyPoints[user.CompanyId] = points
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- e = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+ e = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("AddCygxActivityPointsBillMulti, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxActivitySpecialTripBillMulti, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
return
|
|
@@ -1222,3 +1305,597 @@ func YanXuanActivityVivoPointsBillSignupReduce(log models.YanXuanActivityPointsR
|
|
|
err = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 9:用户报名(专项调研活动)
|
|
|
+func YanXuanActivityPointsBillSignupAddReduceSpecial(log models.YanXuanActivityPointsRedis) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("用户报名活动扣点,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("ActivityId", log.ActivityId, "userId", log.UserId), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ //加2000毫秒的延迟
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ activityId := log.ActivityId
|
|
|
+ userId := log.UserId
|
|
|
+ activityInfo, e := models.GetCygxActivitySpecialDetail(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivitySpecialDetail" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ user, e := models.GetWxUserItemByUserId(userId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetWxUserItemByUserId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyId := user.CompanyId
|
|
|
+ //判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
|
|
|
+ total, e := models.GetCygxActivitySpecialPermissionPointsCountByCompanyId(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivityPointsCompanyCountByCompanyId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyPointsNum float64
|
|
|
+ if total == 0 {
|
|
|
+ companyPointsNum = 0
|
|
|
+ itemPointsCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemPointsCompany.CompanyId = companyId
|
|
|
+ itemPointsCompany.CompanyName = user.CompanyName
|
|
|
+ itemPointsCompany.CreateTime = time.Now()
|
|
|
+ itemPointsCompany.ModifyTime = time.Now()
|
|
|
+ e = models.AddCygxActivitySpecialPermissionPoints(itemPointsCompany)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 获取用户所在公司剩余的点
|
|
|
+ companyPointsNum, e = models.GetCygxActivitySpecialPermissionPoints(user.CompanyId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取需要添加的流水信息
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ itemBill := new(models.CygxActivitySpecialTripBill)
|
|
|
+ itemBill.UserId = user.UserId
|
|
|
+ itemBill.ActivityId = activityInfo.ActivityId
|
|
|
+ itemBill.CreateTime = time.Now()
|
|
|
+ itemBill.Mobile = user.Mobile
|
|
|
+ itemBill.Email = user.Email
|
|
|
+ itemBill.CompanyId = user.CompanyId
|
|
|
+ itemBill.CompanyName = user.CompanyName
|
|
|
+ itemBill.RealName = user.RealName
|
|
|
+ itemBill.Source = 1
|
|
|
+ itemBill.DoType = 1
|
|
|
+ itemBill.BillDetailed = -1 // 流水减一
|
|
|
+ itemBill.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+ itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ itemBill.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
+ itemBill.Content = activityInfo.ResearchTheme + "--报名"
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
|
|
|
+ //48小时之内的取消也扣除一次参会记录
|
|
|
+ if time.Now().Add(+time.Hour * 48).After(resultTime) {
|
|
|
+ itemBill.BillDetailed = 0 //48小时之内,取消报名之后二次报名,不扣除流水记录
|
|
|
+ }
|
|
|
+ itemBill.Total = fmt.Sprint(companyPointsNum+itemBill.BillDetailed, "次")
|
|
|
+ itemBill.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ items = append(items, itemBill)
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = companyPointsNum + itemBill.BillDetailed
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+
|
|
|
+ err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 10:用户取消报名(专项调研活动)
|
|
|
+func SpecialActivityPointsBillSignupCancelReduce(log models.YanXuanActivityPointsRedis) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("用户取消报名扣点,处理Redis队列消息失败 SpecialActivityPointsBillSignupCancelReduce:"+err.Error()+fmt.Sprint("ActivityId", log.ActivityId, "userId", log.UserId), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ activityId := log.ActivityId
|
|
|
+ userId := log.UserId
|
|
|
+
|
|
|
+ activityInfo, e := models.GetCygxActivitySpecialDetail(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetAddActivityInfoById" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ user, e := models.GetWxUserItemByUserId(userId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetWxUserItemByUserId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取用户所在公司剩余的点
|
|
|
+ companyPointsNum, e := models.GetCygxActivitySpecialPermissionPoints(user.CompanyId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取需要添加的流水信息
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ //流水记录表
|
|
|
+ itemBill := new(models.CygxActivitySpecialTripBill)
|
|
|
+ itemBill.UserId = user.UserId
|
|
|
+ itemBill.ActivityId = activityInfo.ActivityId
|
|
|
+ itemBill.CreateTime = time.Now()
|
|
|
+ itemBill.Mobile = user.Mobile
|
|
|
+ itemBill.Email = user.Email
|
|
|
+ itemBill.CompanyId = user.CompanyId
|
|
|
+ itemBill.CompanyName = user.CompanyName
|
|
|
+ itemBill.RealName = user.RealName
|
|
|
+ itemBill.Source = 1
|
|
|
+ itemBill.DoType = 2
|
|
|
+ itemBill.BillDetailed = 1 // 流水加一
|
|
|
+ itemBill.RegisterPlatform = log.RegisterPlatform
|
|
|
+ itemBill.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ itemBill.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
|
|
|
+ //48小时之内的取消也扣除一次参会记录
|
|
|
+ if time.Now().Add(+time.Hour * 48).After(resultTime) {
|
|
|
+ itemBill.BillDetailed = 0 //48小时之内取消的活动扣点不返回
|
|
|
+ }
|
|
|
+ itemBill.Total = fmt.Sprint(companyPointsNum+itemBill.BillDetailed, "次")
|
|
|
+ itemBill.Content = activityInfo.ResearchTheme + "--取消报名"
|
|
|
+ itemBill.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ items = append(items, itemBill)
|
|
|
+
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = companyPointsNum + itemBill.BillDetailed
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+
|
|
|
+ err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 11:合同审批通过的时候,专项调研点数更新
|
|
|
+func ActivitySpecialCompanyApprovalReduce(log models.YanXuanActivityPointsRedis) (err error) {
|
|
|
+ time.Sleep(5 * time.Second) // 延迟5秒处理
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("研选审批通过的时候研选扣点更新,处理Redis队列消息失败:"+err.Error()+fmt.Sprint(log), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ companyId := log.ComapnyId
|
|
|
+ companyContractId := log.CompanyContractId
|
|
|
+ comapnyDetail, e := models.GetCompanyById(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyById" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
|
|
|
+ total, e := models.GetCygxActivitySpecialPermissionPointsCountByCompanyId(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsCountByCompanyId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyPointsNum float64
|
|
|
+ if total == 0 {
|
|
|
+ companyPointsNum = 0
|
|
|
+ itemPointsCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemPointsCompany.CompanyId = companyId
|
|
|
+ itemPointsCompany.CompanyName = comapnyDetail.CompanyName
|
|
|
+ itemPointsCompany.CreateTime = time.Now()
|
|
|
+ itemPointsCompany.ModifyTime = time.Now()
|
|
|
+ e = models.AddCygxActivitySpecialPermissionPoints(itemPointsCompany)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 获取用户所在公司剩余的点
|
|
|
+ companyPointsNum, e = models.GetCygxActivitySpecialPermissionPoints(companyId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ companyPoints, e := company.GetCompanyContractPermissionPointsCount(companyContractId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyContractPermissionPointsCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //获取需要添加的流水信息
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ if companyPoints > 0 {
|
|
|
+ companyPointsNum += companyPoints
|
|
|
+ itemBill := new(models.CygxActivitySpecialTripBill)
|
|
|
+ itemBill.CreateTime = time.Now()
|
|
|
+ itemBill.CompanyId = comapnyDetail.CompanyId
|
|
|
+ itemBill.CompanyName = comapnyDetail.CompanyName
|
|
|
+ itemBill.Source = 2
|
|
|
+ itemBill.DoType = 2
|
|
|
+ itemBill.Way = 3
|
|
|
+ itemBill.RegisterPlatform = log.RegisterPlatform
|
|
|
+ itemBill.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ itemBill.BillDetailed = companyPoints
|
|
|
+ itemBill.Total = fmt.Sprint(companyPointsNum, "次")
|
|
|
+ itemBill.Content = "路演/专项点数转正"
|
|
|
+ items = append(items, itemBill)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取合同信息-套餐信息
|
|
|
+ companyContract, e := company.GetCompanyContractById(companyContractId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyContractById, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ itemBill := new(models.CygxActivitySpecialTripBill)
|
|
|
+ itemBill.CreateTime = time.Now()
|
|
|
+ itemBill.CompanyId = comapnyDetail.CompanyId
|
|
|
+ itemBill.CompanyName = comapnyDetail.CompanyName
|
|
|
+ itemBill.Source = 2
|
|
|
+ itemBill.DoType = 2
|
|
|
+ itemBill.Way = 3
|
|
|
+ itemBill.RegisterPlatform = log.RegisterPlatform
|
|
|
+ itemBill.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+
|
|
|
+ packageType := companyContract.RaiPackageType
|
|
|
+ if packageType > 0 {
|
|
|
+ packageTypeMap := map[int]float64{1: 16, 2: 12}
|
|
|
+ totalTrip := packageTypeMap[packageType]
|
|
|
+ itemBill.BillDetailed = totalTrip
|
|
|
+ companyPointsNum += totalTrip
|
|
|
+ itemBill.Total = fmt.Sprint(itemBill.BillDetailed) + "次"
|
|
|
+ if packageType == 2 {
|
|
|
+ itemBill.Content = "45w大套餐转正"
|
|
|
+ } else {
|
|
|
+ itemBill.Content = "70w大套餐转正"
|
|
|
+ }
|
|
|
+ itemBill.Total = fmt.Sprint(companyPointsNum, "次")
|
|
|
+ items = append(items, itemBill)
|
|
|
+ } else {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = " AND company_contract_id = ? AND is_upgrade = 1 "
|
|
|
+ pars = append(pars, companyContractId)
|
|
|
+ list, e := company.GetCompanyContractPermissionList(condition, pars) // 获取带有升级的权限
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyContractPermissionList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(list) > 0 {
|
|
|
+ //获取权益主观权限
|
|
|
+ listRaiSubjectivity, e := models.GetChartPermissionListRaiSubjectivity()
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetChartPermissionListRaiSubjectivity, Err: " + e.Error())
|
|
|
+ }
|
|
|
+ mapRaiSubjectivity := make(map[int]bool)
|
|
|
+ mapPermissionName := make(map[int]string)
|
|
|
+ for _, v := range listRaiSubjectivity {
|
|
|
+ mapRaiSubjectivity[v.ChartPermissionId] = true
|
|
|
+ mapPermissionName[v.ChartPermissionId] = v.ChartPermissionName
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ //如果是升级则加点
|
|
|
+ if v.IsUpgrade == 1 && mapRaiSubjectivity[v.ChartPermissionId] {
|
|
|
+ itemBill.BillDetailed += 4
|
|
|
+ companyPointsNum += 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemBill.Total = fmt.Sprint(companyPointsNum, "次")
|
|
|
+ itemBill.Content = "行业升级套餐转正"
|
|
|
+ items = append(items, itemBill)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = comapnyDetail.CompanyId
|
|
|
+ itemCompany.Points = companyPointsNum
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// ActivitySpecialPointsBillSubmitMeetingReduce(93)
|
|
|
+//}
|
|
|
+
|
|
|
+// 12: 专项调活动提交到会扣点处理
|
|
|
+func ActivitySpecialPointsBillSubmitMeetingReduce(log models.YanXuanActivityPointsRedis) (err error) {
|
|
|
+ //func ActivitySpecialPointsBillSubmitMeetingReduce(activityId int) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("专项调活动提交到会扣点处理,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("ActivityId", log.ActivityId, "adminId", log.AdminId), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ time.Sleep(5 * time.Second) //添加五秒的延迟
|
|
|
+
|
|
|
+ activityId := log.ActivityId
|
|
|
+ activityInfo, e := models.GetCygxActivitySpecialDetail(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivitySpecialDetail" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ mapCompanyPoints := make(map[int]float64) //一组公司的剩余点数
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND activity_id = ? `
|
|
|
+ pars = append(pars, activityId)
|
|
|
+
|
|
|
+ //获取提交到会的人员信息
|
|
|
+ signUpDetailList, e := models.GetCygxActivitySpecialmeetingDetailList(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetSignupDetailList" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(signUpDetailList) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range signUpDetailList {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+
|
|
|
+ companyId := v.CompanyId
|
|
|
+ //判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
|
|
|
+ total, e := models.GetCygxActivitySpecialPermissionPointsCountByCompanyId(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsCountByCompanyId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if total == 0 {
|
|
|
+ itemPointsCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemPointsCompany.CompanyId = companyId
|
|
|
+ itemPointsCompany.CompanyName = v.CompanyName
|
|
|
+ itemPointsCompany.CreateTime = time.Now()
|
|
|
+ itemPointsCompany.ModifyTime = time.Now()
|
|
|
+
|
|
|
+ e = models.AddCygxActivitySpecialPermissionPoints(itemPointsCompany)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND activity_id = ? AND table_source = 'activityspecial' AND mobile != '' ORDER BY id DESC `
|
|
|
+ pars = append(pars, activityId)
|
|
|
+ //获取扣点的流水记录
|
|
|
+ activityPointsBillList, e := models.GetCygxActivitySpecialTripBill(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialTripBill" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapActivityPointsBill := make(map[string]*models.CygxActivitySpecialTripBill)
|
|
|
+ var itemsOld []*models.CygxActivitySpecialTripBill // 之前扣过点的流水记录
|
|
|
+ for _, v := range activityPointsBillList { //获取这场活动,某个手机号最后一次的扣点记录
|
|
|
+ if mapActivityPointsBill[v.Mobile] == nil {
|
|
|
+ mapActivityPointsBill[v.Mobile] = v
|
|
|
+ if v.BillDetailed < 0 {
|
|
|
+ itemsOld = append(itemsOld, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+
|
|
|
+ //return
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
|
|
|
+ pars = append(pars, companyIds)
|
|
|
+ //获取这些公司剩余的点数
|
|
|
+ conpanyList, e := models.GetCygxActivitySpecialPermissionPointsList(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPointsList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //return
|
|
|
+ for _, v := range conpanyList {
|
|
|
+ if v.CompanyId != 0 {
|
|
|
+ mapCompanyPoints[v.CompanyId] = v.Points
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //return
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ mapMeetUserId := make(map[int]bool)
|
|
|
+ for _, user := range signUpDetailList {
|
|
|
+ mapMeetUserId[user.UserId] = true
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.RegisterPlatform = log.RegisterPlatform
|
|
|
+ item.AdminId = log.AdminId
|
|
|
+ item.Source = log.Source
|
|
|
+ item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
+ if user.IsMeeting == 1 {
|
|
|
+ //如果没有扣点记录就对他们进行扣点处理
|
|
|
+ if mapActivityPointsBill[user.Mobile] == nil || mapActivityPointsBill[user.Mobile].BillDetailed > 0 {
|
|
|
+ points := mapCompanyPoints[user.CompanyId] - 1
|
|
|
+ item.BillDetailed = -1
|
|
|
+ item.DoType = 1
|
|
|
+ item.Content = activityInfo.ResearchTheme + "--活动到会"
|
|
|
+ item.Total = fmt.Sprint(points, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ //item.Points = mapCompanyPoints[user.CompanyId] - activityPointsSetDetail.UserPointsNum
|
|
|
+ items = append(items, item)
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = points
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ mapCompanyPoints[user.CompanyId] = points
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //else {
|
|
|
+ // ////第二次提交改成未到会的,对其进行返点处理
|
|
|
+ // if mapActivityPointsBill[user.Mobile] != nil && mapActivityPointsBill[user.Mobile].BillDetailed < 0 {
|
|
|
+ // fmt.Println("取消到会了")
|
|
|
+ // points := mapCompanyPoints[user.CompanyId] + 1
|
|
|
+ // item.BillDetailed = 1
|
|
|
+ // item.DoType = 2
|
|
|
+ // item.Content = activityInfo.ResearchTheme + "--活动取消到会"
|
|
|
+ // //item.Points =points
|
|
|
+ // item.Total = fmt.Sprint(points, "次")
|
|
|
+ // item.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ // items = append(items, item)
|
|
|
+ //
|
|
|
+ // //更新对应机构的剩余点数
|
|
|
+ // itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ // itemCompany.CompanyId = user.CompanyId
|
|
|
+ // itemCompany.Points = points
|
|
|
+ // itemCompany.ModifyTime = time.Now()
|
|
|
+ // itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ // mapCompanyPoints[user.CompanyId] = points
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(itemsOld) > 0 {
|
|
|
+ for _, user := range itemsOld {
|
|
|
+ if mapMeetUserId[user.UserId] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ item := new(models.CygxActivitySpecialTripBill)
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.RegisterPlatform = log.RegisterPlatform
|
|
|
+ item.AdminId = log.AdminId
|
|
|
+ item.Source = log.Source
|
|
|
+ item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
+ item.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
+
|
|
|
+ points := mapCompanyPoints[user.CompanyId] + 1
|
|
|
+ item.BillDetailed = 1
|
|
|
+ item.DoType = 2
|
|
|
+ item.Content = activityInfo.ResearchTheme + "--活动取消到会"
|
|
|
+ //item.Points =points
|
|
|
+ item.Total = fmt.Sprint(points, "次")
|
|
|
+ item.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ items = append(items, item)
|
|
|
+
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = user.CompanyId
|
|
|
+ itemCompany.Points = points
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+ mapCompanyPoints[user.CompanyId] = points
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ e = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("AddCygxActivitySpecialTripBillMulti, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// initCygx14_5_01()
|
|
|
+//}
|
|
|
+
|
|
|
+func initCygx14_5_01() {
|
|
|
+ // 获取流水信息
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND points != 0 `
|
|
|
+ list, err := models.GetCygxActivityPointsCompanyList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ fmt.Println("v.CompanyId", v.CompanyId)
|
|
|
+ companyId := v.CompanyId
|
|
|
+ total, e := models.GetCygxActivitySpecialPermissionPointsCountByCompanyId(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivityPointsCompanyCountByCompanyId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyPointsNum float64
|
|
|
+ if total == 0 {
|
|
|
+ companyPointsNum = 0
|
|
|
+ itemPointsCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemPointsCompany.CompanyId = companyId
|
|
|
+ itemPointsCompany.CompanyName = v.CompanyName
|
|
|
+ itemPointsCompany.CreateTime = time.Now()
|
|
|
+ itemPointsCompany.ModifyTime = time.Now()
|
|
|
+ e = models.AddCygxActivitySpecialPermissionPoints(itemPointsCompany)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 获取用户所在公司剩余的点
|
|
|
+ companyPointsNum, e = models.GetCygxActivitySpecialPermissionPoints(v.CompanyId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxActivitySpecialPermissionPoints, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取需要添加的流水信息
|
|
|
+ var items []*models.CygxActivitySpecialTripBill
|
|
|
+ itemBill := new(models.CygxActivitySpecialTripBill)
|
|
|
+
|
|
|
+ itemBill.CreateTime = time.Now()
|
|
|
+
|
|
|
+ itemBill.CompanyId = v.CompanyId
|
|
|
+ itemBill.CompanyName = v.CompanyName
|
|
|
+ itemBill.Source = 3
|
|
|
+ itemBill.DoType = 0
|
|
|
+ itemBill.BillDetailed = v.Points / 2 // 流水减一
|
|
|
+ //itemBill.RegisterPlatform = utils.REGISTER_PLATFORM
|
|
|
+
|
|
|
+ itemBill.Content = "研选点数清零,1/2比例折算进专项/路演点数"
|
|
|
+ itemBill.Total = fmt.Sprint(companyPointsNum+itemBill.BillDetailed, "次")
|
|
|
+ itemBill.TableSource = utils.CYGX_OBJ_ACTIVITYSPECIAL
|
|
|
+ items = append(items, itemBill)
|
|
|
+ //更新对应机构的剩余点数
|
|
|
+ var itemCompanys []*models.CygxActivitySpecialPermissionPoints
|
|
|
+ itemCompany := new(models.CygxActivitySpecialPermissionPoints)
|
|
|
+ itemCompany.CompanyId = v.CompanyId
|
|
|
+ itemCompany.Points = companyPointsNum + itemBill.BillDetailed
|
|
|
+ itemCompany.ModifyTime = time.Now()
|
|
|
+ itemCompanys = append(itemCompanys, itemCompany)
|
|
|
+
|
|
|
+ err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
|
+ }
|
|
|
+ fmt.Println("enddd145")
|
|
|
+}
|