|
@@ -226,6 +226,10 @@ func YanXuanActivityPointsBillReduce() (err error) {
|
|
go SpecialActivityPointsBillSignupCancelReduce(log)
|
|
go SpecialActivityPointsBillSignupCancelReduce(log)
|
|
fmt.Println(" 10:取消报名专项调研活动")
|
|
fmt.Println(" 10:取消报名专项调研活动")
|
|
break
|
|
break
|
|
|
|
+ case 11:
|
|
|
|
+ go ActivitySpecialCompanyApprovalReduce(log)
|
|
|
|
+ fmt.Println("11:合同审批通过的时候,专项调研点数更新。")
|
|
|
|
+ break
|
|
default:
|
|
default:
|
|
fmt.Println(string(b))
|
|
fmt.Println(string(b))
|
|
go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+string(b), 2)
|
|
go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+string(b), 2)
|
|
@@ -1455,3 +1459,152 @@ func SpecialActivityPointsBillSignupCancelReduce(log models.YanXuanActivityPoint
|
|
err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
err = models.AddCygxActivitySpecialTripBillMulti(items, itemCompanys)
|
|
return
|
|
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 {
|
|
|
|
+ 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 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //获取权益主观权限
|
|
|
|
+ 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
|
|
|
|
+}
|