|
@@ -20,14 +20,17 @@ func (service *IntegralService) IntegralAddService(data entity.FlowJSON) (int64,
|
|
|
flow.SourceId = data.SourceId
|
|
|
//flow.SourceType = data.SourceType
|
|
|
flow.PointType = data.PointType
|
|
|
- flow.SourceType=fmt.Sprint(data.PointType)
|
|
|
+ flow.SourceType = fmt.Sprint(data.PointType)
|
|
|
flow.Point = data.Point
|
|
|
- flow.EndDate=data.EndDate
|
|
|
+ flow.EndDate = data.EndDate
|
|
|
flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
|
flow.AppId = data.AppId
|
|
|
flow.Sort = entity.AddCode
|
|
|
- flow.Abstract=data.Abstract
|
|
|
+ flow.Abstract = data.Abstract
|
|
|
var numb = int64(0)
|
|
|
+ if data.OperationType {
|
|
|
+ flow.OperationType = 1
|
|
|
+ }
|
|
|
numb, err = orm.Table("integral_flow").Insert(flow)
|
|
|
if err != nil && numb == 0 {
|
|
|
log.Print("新增流水失败:", err)
|
|
@@ -41,6 +44,7 @@ func (service *IntegralService) IntegralAddService(data entity.FlowJSON) (int64,
|
|
|
if data.OperationType {
|
|
|
//永久积分
|
|
|
//先查看是否有EndDate的积分
|
|
|
+
|
|
|
soldelist := []entity.Solde{}
|
|
|
err = orm.Table("integral_solde").Where("appId=? and userId=? and endDate='' and perManEntPoints != 0 AND timePoints = 0 ", data.AppId, data.UserId).Find(&soldelist)
|
|
|
if len(soldelist) > 0 {
|
|
@@ -62,6 +66,7 @@ func (service *IntegralService) IntegralAddService(data entity.FlowJSON) (int64,
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
+ flow.OperationType = 0
|
|
|
solde.EndDate = data.EndDate
|
|
|
//先查看是否有EndDate的积分
|
|
|
soldelist := []entity.Solde{}
|
|
@@ -128,11 +133,11 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
b, err := orm.Table("integral_balance").Select("countPoints,id").
|
|
|
Where("userId = ? AND appId = ?", data.UserId, data.AppId).
|
|
|
Get(&balance)
|
|
|
- if err != nil {
|
|
|
+ if err != nil {
|
|
|
log.Printf("积分余额查询出错,userId:[%s],err:[%v]", data.UserId, err)
|
|
|
return entity.ErrorCode, "积分余额查询出错"
|
|
|
}
|
|
|
- if !b{
|
|
|
+ if !b {
|
|
|
log.Printf("没有查询到[%s]的积分记录,err:[%v]", data.UserId, err)
|
|
|
return entity.ErrorCode, "没有查询到积分记录"
|
|
|
}
|
|
@@ -161,7 +166,7 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
//够消耗
|
|
|
solde.PerManEntPoints = solde.PerManEntPoints - point
|
|
|
point = 0
|
|
|
- af, err = orm.Table("integral_solde").
|
|
|
+ af, err = orm.Table("integral_solde").
|
|
|
ID(solde.Id).
|
|
|
Cols("perManEntPoints").
|
|
|
Update(solde)
|
|
@@ -218,10 +223,10 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
//消耗积分流水记录
|
|
|
flow := entity.Flow{}
|
|
|
flow.UserId = data.UserId
|
|
|
- flow.SourceType=fmt.Sprint(data.PointType)
|
|
|
+ flow.SourceType = fmt.Sprint(data.PointType)
|
|
|
flow.PointType = data.PointType
|
|
|
flow.SourceId = data.SourceId
|
|
|
- flow.Abstract=data.Abstract
|
|
|
+ flow.Abstract = data.Abstract
|
|
|
//flow.SourceType = data.SourceType
|
|
|
flow.Point = data.Point
|
|
|
flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
@@ -229,7 +234,7 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
flow.AppId = data.AppId
|
|
|
flow.Sort = entity.ReduceCode
|
|
|
af, err = orm.Table("integral_flow").Insert(&flow)
|
|
|
- if err != nil || af == 0{
|
|
|
+ if err != nil || af == 0 {
|
|
|
log.Print("积分记录失败")
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "积分记录失败"
|
|
@@ -470,7 +475,7 @@ func (service *IntegralService) IntegralGuardService(endDate string) bool {
|
|
|
}
|
|
|
|
|
|
//积分余额查询
|
|
|
-func (service *IntegralService) IntegralBalanceCheckService(userId,appId string ) (bool, int64,int64) {
|
|
|
+func (service *IntegralService) IntegralBalanceCheckService(userId, appId string) (bool, int64, int64) {
|
|
|
orm := entity.Engine
|
|
|
//积分总余额
|
|
|
balance := entity.Balance{}
|
|
@@ -479,7 +484,7 @@ func (service *IntegralService) IntegralBalanceCheckService(userId,appId string
|
|
|
Get(&balance)
|
|
|
if err != nil {
|
|
|
log.Println("积分查询出错")
|
|
|
- return false, 0,0
|
|
|
+ return false, 0, 0
|
|
|
}
|
|
|
//积分30天内到期余额
|
|
|
var solde entity.Solde
|
|
@@ -489,9 +494,9 @@ func (service *IntegralService) IntegralBalanceCheckService(userId,appId string
|
|
|
Get(&solde)
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
- return false, 0,0
|
|
|
+ return false, 0, 0
|
|
|
}
|
|
|
- return true, balance.CountPoints,solde.TimePoints
|
|
|
+ return true, balance.CountPoints, solde.TimePoints
|
|
|
}
|
|
|
|
|
|
//按月查询积分使用情况
|
|
@@ -499,11 +504,11 @@ func (service *IntegralService) IntegralDetailedCheck(data entity.FlowJSON) ([]*
|
|
|
orm := entity.Engine.NewSession()
|
|
|
//查询时间范围内的
|
|
|
//查询新增消耗的积分和消耗积分 searchType 0全部 1新增 -1消耗
|
|
|
- searchCode :="1=1"
|
|
|
- if data.SearchType==1{
|
|
|
- searchCode=" flow.Sort=1"
|
|
|
- }else if data.SearchType==-1{
|
|
|
- searchCode=" flow.Sort=-1"
|
|
|
+ searchCode := "1=1"
|
|
|
+ if data.SearchType == 1 {
|
|
|
+ searchCode = " flow.Sort=1"
|
|
|
+ } else if data.SearchType == -1 {
|
|
|
+ searchCode = " flow.Sort=-1"
|
|
|
}
|
|
|
var flowList []*entity.FlowReq
|
|
|
numb, err := orm.Table("integral_flow").Alias("flow").
|
|
@@ -512,7 +517,7 @@ func (service *IntegralService) IntegralDetailedCheck(data entity.FlowJSON) ([]*
|
|
|
Where("flow.userId = ? AND flow.appId = ?", data.UserId, data.AppId).
|
|
|
And(searchCode).
|
|
|
Desc("flow.createTime").
|
|
|
- Limit(int(data.PageSize), (int(data.Page-1))*int(data.PageSize)).
|
|
|
+ Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).
|
|
|
FindAndCount(&flowList)
|
|
|
var flowReq []*integral.Point
|
|
|
for _, value := range flowList {
|
|
@@ -526,7 +531,7 @@ func (service *IntegralService) IntegralDetailedCheck(data entity.FlowJSON) ([]*
|
|
|
point.SourceId = value.SourceId
|
|
|
point.SourceType = value.SourceType
|
|
|
point.Name = value.Name
|
|
|
- point.Abstract=value.Abstract
|
|
|
+ point.Abstract = value.Abstract
|
|
|
flowReq = append(flowReq, &point)
|
|
|
}
|
|
|
fmt.Println(flowList)
|