소스 검색

Merge branch 'master' of https://app.yhyue.com/moapp/jyPoints

李哲 4 년 전
부모
커밋
f647d46a22
4개의 변경된 파일45개의 추가작업 그리고 35개의 파일을 삭제
  1. 10 10
      rpc/integral/integral.pb.go
  2. 1 0
      rpc/internal/logic/integraldetailedchecklogic.go
  3. 6 13
      rpc/internal/logic/integralharvestlogic.go
  4. 28 12
      service/integralService.go

+ 10 - 10
rpc/integral/integral.pb.go

@@ -7,15 +7,15 @@
 package integral
 
 import (
-	context "context"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
+	"context"
+	"github.com/golang/protobuf/proto"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"google.golang.org/protobuf/reflect/protoreflect"
+	"google.golang.org/protobuf/runtime/protoimpl"
+	"reflect"
+	"sync"
 )
 
 const (
@@ -221,6 +221,7 @@ type RespList struct {
 	Count   int64    `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`    //总数
 	Data    []*Point `protobuf:"bytes,4,rep,name=data,proto3" json:"data,omitempty"`       //列表
 }
+
 func (x *RespList) Reset() {
 	*x = RespList{}
 	if protoimpl.UnsafeEnabled {
@@ -285,7 +286,6 @@ type Point struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
-
 	Id             int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
 	UserId         string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"`
 	PointType      int64  `protobuf:"varint,3,opt,name=pointType,proto3" json:"pointType,omitempty"`

+ 1 - 0
rpc/internal/logic/integraldetailedchecklogic.go

@@ -34,6 +34,7 @@ func (l *IntegralDetailedCheckLogic) IntegralDetailedCheck(in *integral.Req) (*i
 	dat.AppId = in.AppId
 	dat.Page = in.Page
 	dat.PageSize = in.PageSize
+	dat.UserId=in.UserId
 	data, count := integralService.IntegralDetailedCheck(dat)
 	fmt.Println(count, data)
 	result.Code = entity.SuccessCode

+ 6 - 13
rpc/internal/logic/integralharvestlogic.go

@@ -34,18 +34,11 @@ func (l *IntegralHarvestLogic) IntegralHarvest(in *integral.Req) (*integral.Resp
 	dat.EndDate = in.EndDate
 	dat.AppId = in.AppId
 	dat.OperationType = in.OperationType
-	dat.UserId=in.UserId
-	dat.Point=in.Point
+	dat.UserId = in.UserId
+	dat.Point = in.Point
 	code, msg := integralService.IntegralAddService(dat)
-	fmt.Println(code,msg)
-	if code == 1 {
-		result.Code = entity.SuccessCode
-		result.Message = "获取积分成功"
-		return result, nil
-	} else {
-		result.Code = entity.ErrorCode
-		result.Message = "获取积分失败"
-		return result, nil
-	}
-
+	fmt.Println(code, msg)
+	result.Code = code
+	result.Message = msg
+	return result, nil
 }

+ 28 - 12
service/integralService.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"fmt"
 	"log"
 	"points_service/entity"
 	"points_service/rpc/integral"
@@ -209,19 +210,19 @@ func (service *IntegralService) IntegralConsumeService(data entity.FlowJSON) (in
 }
 
 //到期积分查询
-func (service *IntegralService) IntegralExpireCheckService(data entity.ExpireJSON) (int64,int64) {
+func (service *IntegralService) IntegralExpireCheckService(data entity.ExpireJSON) (int64, int64) {
 	orm := entity.Engine
 	var solde entity.Solde
 	var err error
-	af,err := orm.Table("integral_solde").
+	af, err := orm.Table("integral_solde").
 		Select("SUM( timePoints ) AS timePoints").
 		Where("userId = ? AND appId = ? AND endDate < ? ", data.UserId, data.AppId, data.EndDate).
 		Get(&solde)
 	if !af || err != nil {
 		log.Println(err)
-		return entity.ErrorCode,0
+		return entity.ErrorCode, 0
 	}
-	return entity.SuccessCode,solde.TimePoints
+	return entity.SuccessCode, solde.TimePoints
 }
 
 /*//结存新增
@@ -428,7 +429,7 @@ func (service *IntegralService) IntegralGuardService(endDate string) bool {
 }
 
 //积分余额查询
-func (service *IntegralService) IntegralBalanceCheckService(userId string,appId int64) (bool, int64) {
+func (service *IntegralService) IntegralBalanceCheckService(userId string, appId int64) (bool, int64) {
 	orm := entity.Engine
 	balance := entity.Balance{}
 	b, err := orm.Table("integral_balance").
@@ -442,19 +443,34 @@ func (service *IntegralService) IntegralBalanceCheckService(userId string,appId
 }
 
 //按月查询积分使用情况
-func (service *IntegralService) IntegralDetailedCheck(data entity.FlowJSON) ([]*integral.Point,int64) {
+func (service *IntegralService) IntegralDetailedCheck(data entity.FlowJSON) ([]*integral.Point, int64) {
 	orm := entity.Engine
-	flowReq := []*integral.Point{}
-	numb,err := orm.Table("integral_flow").Alias("flow").
+
+	var  flowList []*entity.FlowReq
+	numb, err := orm.Table("integral_flow").Alias("flow").
 		Select("flow.*,pt.name").
 		Join("left", "point_type pt", "flow.pointType=pt.code").
 		Where("flow.userId = ? AND flow.appId = ? AND DATE_FORMAT(flow.createTime,'%Y-%m')=? ", data.UserId, data.AppId, data.EndDate).
 		Desc("flow.createTime").
-		Limit(int(data.PageSize), (int(data.Page-1))*int(data.PageSize)).
-		FindAndCount(&flowReq)
+		Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).
+		FindAndCount(&flowList)
+	var flowReq []*integral.Point
+	for _, value := range flowList {
+		point:=integral.Point{}
+		point.EndDate=value.EndDate
+		point.Sort=value.Sort
+		point.Point= value.Point
+		point.CreateTime=value.CreateTime
+		point.PointType=value.PointType
+		point.BusinessTypeId=value.BusinessTypeId
+		point.BusinessType=value.BusinessType
+		point.Name=value.Name
+		flowReq=append(flowReq,&point )
+	}
+	fmt.Println(flowList)
 	if err != nil {
 		log.Println(err)
-		return nil,int64(0)
+		return nil, int64(0)
 	}
-	return flowReq,numb
+	return flowReq, numb
 }