Browse Source

no message

xingzai 7 tháng trước cách đây
mục cha
commit
dcf957bcac
2 tập tin đã thay đổi với 37 bổ sung26 xóa
  1. 10 1
      models/db.go
  2. 27 25
      services/rai_serve_count.go

+ 10 - 1
models/db.go

@@ -3,6 +3,7 @@ package models
 import (
 	_ "github.com/go-sql-driver/mysql"
 	"hongze/hongze_cygx/models/order"
+	"hongze/hongze_cygx/models/rai_serve"
 	"hongze/hongze_cygx/utils"
 	"time"
 
@@ -192,7 +193,8 @@ func init() {
 		new(CygxActivitySpecialPermissionPoints),
 	)
 
-	initOrder() // 订单模块
+	initOrder()    // 订单模块
+	initRaiServe() // 权益服务记录模块
 
 	// 记录ORM查询日志
 	orm.Debug = true
@@ -211,3 +213,10 @@ func initOrder() {
 		new(order.CygxOrderVirtualAsset), //用户虚拟资产表(所购买的单篇报告,活动等)
 	)
 }
+
+// 权益服务记录模块
+func initRaiServe() {
+	orm.RegisterModel(
+		new(rai_serve.CygxRaiServeBill), //服务明细表
+	)
+}

+ 27 - 25
services/rai_serve_count.go

@@ -2,7 +2,9 @@ package services
 
 import (
 	"encoding/json"
+	"errors"
 	"fmt"
+	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/models/company"
 	"hongze/hongze_cygx/models/rai_serve"
 	"hongze/hongze_cygx/utils"
@@ -41,9 +43,9 @@ func CygxRaiServeBillRedisAdd(content, source string, userId, comapnyId, sourceI
 	return
 }
 
-func init() {
-	CygxRaiServeBillRedisAddReduce()
-}
+//func init() {
+//	CygxRaiServeBillRedisAddReduce()
+//}
 
 // CygxRaiServeBillRedisAddReduce 处理权益服务统计
 func CygxRaiServeBillRedisAddReduce() (err error) {
@@ -94,35 +96,35 @@ func RaiServeBillRedisAddReduceByYanxuanspecial(log rai_serve.RaiServeBillRedis)
 	sourceId := log.SourceId
 	defer func() {
 		if err != nil {
-			fmt.Println(err)
 			go utils.SendAlarmMsg("用户报名活动扣点,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("source:", source, "userId:", userId, "sourceId", sourceId), 2)
 		}
 	}()
-
+	wxUser, e := models.GetWxUserItemByUserId(userId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return
+	}
 	item := new(rai_serve.CygxRaiServeBill)
-
 	item.Content = log.Content
 	item.ServeTypeId = 5
 	item.ServeTypeName = "阅读uv"
+	item.UserId = wxUser.UserId
+	item.Mobile = wxUser.Mobile
+	item.Email = wxUser.Email
+	item.CompanyId = wxUser.CompanyId
+	item.CompanyName = wxUser.CompanyName
+	item.RealName = wxUser.RealName
+	item.RegisterPlatform = log.RegisterPlatform
+	item.ServeCount = 0.5
 
-	//	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:"浏览时间"`
-	//}
-
+	if wxUser.IsMaker == 1 {
+		item.IsKp = wxUser.IsMaker
+		item.ServeCount = item.ServeCount * 3
+	}
+	item.SourceId = log.SourceId
+	item.Source = log.Source
+	item.CreateTime = time.Now()
+	item.ViewTime = log.ViewTime
+	err = rai_serve.AddCygxRaiServeBill(item)
 	return
 }