|
@@ -103,6 +103,7 @@ func (service *IntegralService) IntegralAddService(data entity.FlowJSON) (int, s
|
|
|
|
|
|
//消耗积分流水
|
|
|
func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (int, string) {
|
|
|
+ var af = int64(0)
|
|
|
orm := entity.Engine
|
|
|
flow := entity.Flow{}
|
|
|
flow.UserId = data.UserId
|
|
@@ -114,7 +115,6 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
flow.EndDate = data.EndDate
|
|
|
flow.AppId = data.AppId
|
|
|
flow.Sort = entity.ReduceCode
|
|
|
- //判断是否为消耗积分:false
|
|
|
balance := entity.Balance{}
|
|
|
//查询积分余额是否充足
|
|
|
b, err := orm.Table("integral_balance").Select("countPoints,id").
|
|
@@ -127,15 +127,13 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
if balance.CountPoints < data.Point {
|
|
|
return entity.ErrorCode, "积分余额不足"
|
|
|
}
|
|
|
- af, err := orm.Table("integral_flow").Insert(&flow)
|
|
|
- if err != nil && af==0{
|
|
|
- log.Print("积分记录失败")
|
|
|
- return entity.ErrorCode, "积分记录失败"
|
|
|
- }
|
|
|
|
|
|
//结存消耗
|
|
|
soldelist := []entity.Solde{}
|
|
|
- err = entity.Engine.Table("integral_solde").Where("appId=? and userId=? and endDate> ? and( ( perManEntPoints != 0 AND timePoints = 0 ) OR ( perManEntPoints = 0 AND timePoints != 0 ))", data.AppId, data.UserId, time.Now().Format("2006-01-02")).Desc("endDate").Desc("timePoints").Find(&soldelist)
|
|
|
+ err = entity.Engine.Table("integral_solde").
|
|
|
+ Where("appId=? and userId=? and endDate> ? and( ( perManEntPoints != 0 AND timePoints = 0 ) OR ( perManEntPoints = 0 AND timePoints != 0 ))", data.AppId, data.UserId, time.Now().Format("2006-01-02")).
|
|
|
+ Desc("endDate").
|
|
|
+ Desc("timePoints").Find(&soldelist)
|
|
|
if len(soldelist) == 0 {
|
|
|
return entity.ErrorCode, "没有结存可以消耗"
|
|
|
}
|