|
@@ -3,6 +3,7 @@ package services
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "hongze/hongze_cygx/models/company"
|
|
|
"hongze/hongze_cygx/models/rai_serve"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"time"
|
|
@@ -40,9 +41,9 @@ func CygxRaiServeBillRedisAdd(content, source string, userId, comapnyId, sourceI
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//func init() {
|
|
|
-// CygxRaiServeBillRedisAddReduce()
|
|
|
-//}
|
|
|
+func init() {
|
|
|
+ CygxRaiServeBillRedisAddReduce()
|
|
|
+}
|
|
|
|
|
|
// CygxRaiServeBillRedisAddReduce 处理权益服务统计
|
|
|
func CygxRaiServeBillRedisAddReduce() (err error) {
|
|
@@ -52,7 +53,25 @@ func CygxRaiServeBillRedisAddReduce() (err error) {
|
|
|
var log rai_serve.RaiServeBillRedis
|
|
|
if err := json.Unmarshal(b, &log); err != nil {
|
|
|
fmt.Println("json unmarshal wrong!")
|
|
|
- go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+err.Error()+string(b), 2)
|
|
|
+ go utils.SendAlarmMsg("处理权益服务统计Redis队列消息失败:"+err.Error()+string(b), 2)
|
|
|
+ }
|
|
|
+ //如果不是共享给 权益服务组的,则不处理
|
|
|
+ taotalRaiServe, err := company.GetCompanyProductAaiServeCount(log.ComapnyId, utils.RAI_SERVE_GROUP_ID)
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg("处理权益服务统计Redis队列消息失败:GetCompanyProductAaiServeCount"+err.Error()+string(b), 2)
|
|
|
+ }
|
|
|
+ fmt.Println("taotaRaiServe", taotalRaiServe)
|
|
|
+ if taotalRaiServe == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果已经有记录了就不处理
|
|
|
+ taotalSource, err := rai_serve.GetCygxRaiServeBillCountByUserAndSource(log.UserId, log.SourceId, log.Source)
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg("处理权益服务统计Redis队列消息失败:GetCygxRaiServeBillCountByUserAndSource"+err.Error()+string(b), 2)
|
|
|
+ }
|
|
|
+ if taotalSource > 0 {
|
|
|
+ return
|
|
|
}
|
|
|
switch log.Source {
|
|
|
case utils.CYGX_OBJ_YANXUANSPECIAL: //研选专栏阅读记录处理
|
|
@@ -80,98 +99,30 @@ func RaiServeBillRedisAddReduceByYanxuanspecial(log rai_serve.RaiServeBillRedis)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- //activityId := log.ActivityId
|
|
|
- //userId := log.UserId
|
|
|
- //
|
|
|
- //activtyPayTotal := GetCygxOrderVirtualAssetdCountTotal(userId, activityId) // 单场付费活动不处理扣点明细
|
|
|
- //if activtyPayTotal > 0 {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- ////获取活动是否扣点以及扣点规则明细
|
|
|
- //activityPointsSetDetail, e := models.GetCygxActivityPointsSetDetail(activityId)
|
|
|
- //if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- // err = errors.New("GetCygxActivityPointsSetDetail" + e.Error())
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if activityPointsSetDetail == nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if activityPointsSetDetail.UserPointsNum == 0 || activityPointsSetDetail.PointsType != 1 {
|
|
|
- // return // 如果不是报名即扣点的这种形式,那么就不做任何处理
|
|
|
- //}
|
|
|
- //
|
|
|
- //activityInfo, e := models.GetAddActivityInfoById(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
|
|
|
- //}
|
|
|
- //companyId := user.CompanyId
|
|
|
- ////判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
|
|
|
- //total, e := models.GetCygxActivityPointsCompanyCountByCompanyId(companyId)
|
|
|
- //if e != nil {
|
|
|
- // err = errors.New("GetCygxActivityPointsCompanyCountByCompanyId, Err: " + e.Error())
|
|
|
- // return
|
|
|
- //}
|
|
|
- //var companyPointsNum float64
|
|
|
- //if total == 0 {
|
|
|
- // companyPointsNum = 0
|
|
|
- // itemPointsCompany := new(models.CygxActivityPointsCompany)
|
|
|
- //
|
|
|
- // itemPointsCompany.CompanyId = companyId
|
|
|
- // itemPointsCompany.CompanyName = user.CompanyName
|
|
|
- // itemPointsCompany.CreateTime = time.Now()
|
|
|
- // itemPointsCompany.ModifyTime = time.Now()
|
|
|
- //
|
|
|
- // e = models.AddCygxActivityPointsCompany(itemPointsCompany)
|
|
|
- // if e != nil {
|
|
|
- // err = errors.New("AddCygxActivityPointsCompany, Err: " + e.Error())
|
|
|
- // return
|
|
|
- // }
|
|
|
- //} else {
|
|
|
- // // 获取用户所在公司剩余的点
|
|
|
- // companyPointsNum, e = models.GetCompanyPoints(user.CompanyId)
|
|
|
- // if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- // err = errors.New("GetCompanyPoints, Err: " + e.Error())
|
|
|
- // return
|
|
|
- // }
|
|
|
- //
|
|
|
+ item := new(rai_serve.CygxRaiServeBill)
|
|
|
+
|
|
|
+ item.Content = log.Content
|
|
|
+ item.ServeTypeId = 5
|
|
|
+ item.ServeTypeName = "阅读uv"
|
|
|
+
|
|
|
+ // BillId int `comment:"服务明细主键ID"`
|
|
|
+ // Content string `comment:"服务内容说明"`
|
|
|
+ // ServeTypeId int `comment:"服务类型ID"`
|
|
|
+ // ServeTypeName string `comment:"服务类型"`
|
|
|
+ // UserId int `comment:"用户ID"`
|
|
|
+ // Mobile string `comment:"手机号"`
|
|
|
+ // Email string `comment:"邮箱"`
|
|
|
+ // CompanyId int `comment:"公司ID"`
|
|
|
+ // CompanyName string `comment:"公司名称"`
|
|
|
+ // RealName string `comment:"用户实际名称"`
|
|
|
+ // RegisterPlatform int `comment:"来源 1小程序,2:网页"`
|
|
|
+ // ServeCount float64 `comment:"服务量小计"`
|
|
|
+ // IsKp int `comment:"是否是KP,1:是、0:否"`
|
|
|
+ // SourceId int `comment:"来源ID"`
|
|
|
+ // Source string `comment:"来源 "`
|
|
|
+ // CreateTime time.Time `comment:"创建时间"`
|
|
|
+ // ViewTime time.Time `comment:"浏览时间"`
|
|
|
//}
|
|
|
- //
|
|
|
- ////获取需要添加的流水信息
|
|
|
- //var items []*models.CygxActivityPointsBill
|
|
|
- //item := new(models.CygxActivityPointsBill)
|
|
|
- //item.UserId = user.UserId
|
|
|
- //item.ActivityId = activityId
|
|
|
- //item.CreateTime = time.Now()
|
|
|
- //item.Mobile = user.Mobile
|
|
|
- //item.Email = user.Email
|
|
|
- //item.CompanyId = user.CompanyId
|
|
|
- //item.CompanyName = user.CompanyName
|
|
|
- //item.RealName = user.RealName
|
|
|
- //item.BillDetailed = -activityPointsSetDetail.UserPointsNum
|
|
|
- //item.RegisterPlatform = log.RegisterPlatform
|
|
|
- //item.AdminId = log.AdminId
|
|
|
- //item.Source = log.Source
|
|
|
- //item.ChartPermissionId = activityInfo.ChartPermissionId
|
|
|
- //item.DoType = 1
|
|
|
- //item.Content = activityInfo.ActivityName + "--报名"
|
|
|
- //item.Points = companyPointsNum - activityPointsSetDetail.UserPointsNum
|
|
|
- //items = append(items, item)
|
|
|
- //
|
|
|
- ////更新对应机构的剩余点数
|
|
|
- //var itemCompanys []*models.CygxActivityPointsCompany
|
|
|
- //itemCompany := new(models.CygxActivityPointsCompany)
|
|
|
- //itemCompany.CompanyId = user.CompanyId
|
|
|
- //itemCompany.Points = item.Points
|
|
|
- //itemCompany.ModifyTime = time.Now()
|
|
|
- //itemCompanys = append(itemCompanys, itemCompany)
|
|
|
- //
|
|
|
- //err = models.AddCygxActivityPointsBillMulti(items, itemCompanys)
|
|
|
+
|
|
|
return
|
|
|
}
|