WH01243 4 vuotta sitten
vanhempi
commit
46f50d09a8
4 muutettua tiedostoa jossa 16 lisäystä ja 12 poistoa
  1. 3 3
      api/integral.api
  2. 3 3
      api/internal/types/types.go
  3. 2 1
      entity/integral.go
  4. 8 5
      service/integralService.go

+ 3 - 3
api/integral.api

@@ -53,10 +53,10 @@ type (
 		UserId        string `form:"userId"`
 		AppId         string `form:"appId"`
 		PointType     int64  `form:"pointType"`
-		SourceId      string `form:"sourceId"`
-		SourceType    string `form:"sourceType"`
+		SourceId      string `form:"sourceId,optional"`
+		SourceType    string `form:"sourceType,optional"`
 		Point         int64  `form:"point"`
-		EndDate       string `form:"endDate"`
+		EndDate       string `form:"endDate,optional"`
 		OperationType bool   `form:"operationType"`
 	}
 

+ 3 - 3
api/internal/types/types.go

@@ -50,10 +50,10 @@ type AddReq struct {
 	UserId        string `form:"userId"`
 	AppId         string `form:"appId"`
 	PointType     int64  `form:"pointType"`
-	SourceId      string `form:"sourceId"`
-	SourceType    string `form:"sourceType"`
+	SourceId      string `form:"sourceId,optional"`
+	SourceType    string `form:"sourceType,optional"`
 	Point         int64  `form:"point"`
-	EndDate       string `form:"endDate"`
+	EndDate       string `form:"endDate,optional"`
 	OperationType bool   `form:"operationType"`
 }
 

+ 2 - 1
entity/integral.go

@@ -2,6 +2,7 @@ package entity
 
 import (
 	"github.com/go-xorm/xorm"
+	"time"
 )
 
 //定义orm引擎
@@ -57,7 +58,7 @@ type FlowReq struct {
 	SourceId   string `xorm:"sourceId" form:"sourceId" json:"sourceId"`               //来源标识
 	SourceType string `xorm:"sourceType" form:"sourceType" json:"sourceType"` 		  //来源类型
 	Point          int64  `xorm:"point" form:"point" json:"point"`                            //积分
-	CreateTime     string `xorm:"createTime" form:"createTime" json:"createTime"`             //创建时间
+	CreateTime     time.Time `xorm:"createTime" form:"createTime" json:"createTime"`             //创建时间
 	EndDate        string `xorm:"endDate" form:"endDate" json:"endDate"`                      //截止时间
 	AppId          string `xorm:"appId" form:"appId" json:"appId"`                            //剑鱼标识
 	Sort           int64  `xorm:"sort" form:"sort" json:"sort"`                               //操作类型1加-1减

+ 8 - 5
service/integralService.go

@@ -18,8 +18,9 @@ func (service *IntegralService) IntegralAddService(data entity.FlowJSON) (int64,
 	flow := entity.Flow{}
 	flow.UserId = data.UserId
 	flow.SourceId = data.SourceId
-	flow.SourceType = data.SourceType
+	//flow.SourceType = data.SourceType
 	flow.PointType = data.PointType
+	flow.SourceType=fmt.Sprint(data.PointType)
 	flow.Point = data.Point
 	flow.EndDate=data.EndDate
 	flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
@@ -216,9 +217,10 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
 	//消耗积分流水记录
 	flow := entity.Flow{}
 	flow.UserId = data.UserId
+	flow.SourceType=fmt.Sprint(data.PointType)
 	flow.PointType = data.PointType
 	flow.SourceId = data.SourceId
-	flow.SourceType = data.SourceType
+	//flow.SourceType = data.SourceType
 	flow.Point = data.Point
 	flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
 	flow.EndDate = data.EndDate
@@ -432,7 +434,7 @@ func (service *IntegralService) IntegralGuardService(endDate string) bool {
 		flow.UserId = solde.UserId
 		flow.PointType = 2004
 		flow.SourceId = ""
-		flow.SourceType = ""
+		flow.SourceType = "2004"
 		flow.Point = solde.TimePoints
 		flow.CreateTime = time.Now().Format("2006-01-02 15:04:05")
 		flow.EndDate = solde.EndDate
@@ -475,7 +477,7 @@ func (service *IntegralService) IntegralBalanceCheckService(userId,appId string
 		Get(&balance)
 	if !b || err != nil {
 		log.Println("暂无积分余额")
-		return false, 0,0
+		return false, 1,0
 	}
 	//积分30天内到期余额
 	var solde entity.Solde
@@ -516,7 +518,8 @@ func (service *IntegralService) IntegralDetailedCheck(data entity.FlowJSON) ([]*
 		point.EndDate = value.EndDate
 		point.Sort = value.Sort
 		point.Point = value.Point
-		point.CreateTime = value.CreateTime
+		createTimeStr := value.CreateTime.Format("2006-01-02")
+		point.CreateTime = createTimeStr
 		point.PointType = value.PointType
 		point.SourceId = value.SourceId
 		point.SourceType = value.SourceType