|
@@ -105,16 +105,6 @@ func (service *IntegralService) IntegralAddService(data entity.FlowJSON) (int64,
|
|
|
func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (int64, string) {
|
|
|
var af = int64(0)
|
|
|
orm := entity.Engine
|
|
|
- flow := entity.Flow{}
|
|
|
- flow.UserId = data.UserId
|
|
|
- flow.PointType = data.PointType
|
|
|
- flow.BusinessTypeId = data.BusinessTypeId
|
|
|
- flow.BusinessType = data.BusinessType
|
|
|
- flow.Point = data.Point
|
|
|
- flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
|
- flow.EndDate = data.EndDate
|
|
|
- flow.AppId = data.AppId
|
|
|
- flow.Sort = entity.ReduceCode
|
|
|
balance := entity.Balance{}
|
|
|
//查询积分余额是否充足
|
|
|
b, err := orm.Table("integral_balance").Select("countPoints,id").
|
|
@@ -131,7 +121,7 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
//结存消耗
|
|
|
soldelist := []entity.Solde{}
|
|
|
err = entity.Engine.Table("integral_solde").
|
|
|
- Where("appId=? and userId=? and(endDate =‘’ or endDate>= ?) and( ( perManEntPoints != 0 AND timePoints = 0 ) OR ( perManEntPoints = 0 AND timePoints != 0 ))", data.AppId, data.UserId, time.Now().Format("2006-01-02")).
|
|
|
+ Where("appId=? and userId=? and (endDate ='' or endDate is NULL or 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 {
|
|
@@ -198,6 +188,23 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
|
|
|
log.Print("余额扣除失败:",err)
|
|
|
return entity.ErrorCode, "余额扣除失败"
|
|
|
}
|
|
|
+
|
|
|
+ //消耗积分流水记录
|
|
|
+ flow := entity.Flow{}
|
|
|
+ flow.UserId = data.UserId
|
|
|
+ flow.PointType = data.PointType
|
|
|
+ flow.BusinessTypeId = data.BusinessTypeId
|
|
|
+ flow.BusinessType = data.BusinessType
|
|
|
+ flow.Point = data.Point
|
|
|
+ flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
|
+ flow.EndDate = data.EndDate
|
|
|
+ flow.AppId = data.AppId
|
|
|
+ flow.Sort = entity.ReduceCode
|
|
|
+ af, err = orm.Table("integral_flow").Insert(&flow)
|
|
|
+ if err != nil && af == 0 {
|
|
|
+ log.Print("积分记录失败")
|
|
|
+ return entity.ErrorCode, "积分记录失败"
|
|
|
+ }
|
|
|
return entity.SuccessCode, "积分消耗成功"
|
|
|
}
|
|
|
|
|
@@ -391,13 +398,14 @@ func (service *IntegralService) IntegralGuardService(endDate string) bool {
|
|
|
//积分过期流水记录
|
|
|
flow := entity.Flow{}
|
|
|
flow.UserId = solde.UserId
|
|
|
- flow.PointType = 9
|
|
|
+ flow.PointType = 2004
|
|
|
flow.BusinessTypeId = 0
|
|
|
flow.BusinessType = "0"
|
|
|
flow.Point = solde.TimePoints
|
|
|
flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
|
flow.EndDate = solde.EndDate
|
|
|
flow.AppId = solde.AppId
|
|
|
+ flow.Sort = entity.ReduceCode
|
|
|
af, err := orm.Table("integral_flow").Insert(&flow)
|
|
|
if err != nil && af == 0 {
|
|
|
log.Print("积分记录失败")
|