WH01243 4 anos atrás
pai
commit
a633355f0e

+ 13 - 0
entity/accountResources.go

@@ -0,0 +1,13 @@
+package entity
+
+type Balance struct {
+	Id           int64  `xorm:"pk autoincr id" form:"id" json:"id"`
+	EmployeeId   int64  `xorm:"employeeId" form:"employeeId" json:"employeeId"`       //人员标识
+	CompanyId    int64  `xorm:"companyId" form:"companyId" json:"companyId"`          //企业标识
+	DepartmentId int64  `xorm:"departmentId" form:"departmentId" json:"departmentId"` //组织标识
+	Name         string `xorm:"name" form:"name" json:"name"`                         //资源名称
+	Code         string `xorm:"code" form:"code" json:"code"`                         //资源代码
+	Number       int64  `xorm:"number" form:"number" json:"number"`                   //数量
+	Spec         string `xorm:"spec" form:"spec" json:"spec"`                         //规格
+	AppId        string `xorm:"appId" form:"appId" json:"appId"`                      //标识
+}

+ 16 - 0
entity/detailed.go

@@ -0,0 +1,16 @@
+package entity
+
+import "time"
+
+type Detailed struct {
+	Id            int64     `xorm:"pk autoincr id" form:"id" json:"id"`
+	EmployeeId    int64     `xorm:"employeeId" form:"employeeId" json:"employeeId"`          //人员标识
+	CompanyId     int64     `xorm:"companyId" form:"companyId" json:"companyId"`             //企业标识
+	DepartmentId  int64     `xorm:"departmentId" form:"departmentId" json:"departmentId"`    //组织标识
+	ResourceType  string    `xorm:"resourceType" form:"resourceType" json:"resourceType"`    //资源类型
+	ExportNum     int64     `xorm:"exportNum" form:"exportNum" json:"exportNum"`             //导出数量
+	DeductionType int64    `xorm:"deductionType" form:"deductionType" json:"deductionType"` //扣类型(1高级字段包)
+	RuleId        int64     `xorm:"ruleId" form:"ruleId" json:"ruleId"`                      //使用规则标识
+	ExportTime    time.Time `xorm:"exportTime" form:"exportTime" json:"exportTime"`          //导出时间
+	UserType      int64     `xorm:"userType" form:"userType" json:"userType"`                //流水类型0使用1新增
+}

+ 1 - 1
rpc/etc/resourcescenter.yaml

@@ -13,7 +13,7 @@ Etcd:
   Hosts:
     - 127.0.0.1:2379
   Key: resourcescenter.rpc
-DataSource: root:123456@tcp(127.0.0.1:3306)/jy_user_center?charset=utf8mb4&parseTime=true&loc=Local
+DataSource: root:Topnet123@tcp(127.0.0.1:13306)/jy_user_center?charset=utf8mb4&parseTime=true&loc=Local
 FileSystemConf:
   Etcd:
     Hosts:

+ 36 - 0
rpc/internal/logic/updateuserbalancelogic.go

@@ -0,0 +1,36 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/internal/svc"
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
+	"app.yhyue.com/moapp/jyResourcesCenter/service"
+	"context"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type UpdateUserBalanceLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewUpdateUserBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserBalanceLogic {
+	return &UpdateUserBalanceLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+var balanceService service.BalanceService
+
+// 根据账户标识修改资源结存账
+func (l *UpdateUserBalanceLogic) UpdateUserBalance(in *resourcesCenter.Balance) (*resourcesCenter.Response, error) {
+	// todo: add your logic here and delete this line
+
+	code, msg := balanceService.UpdateUserBalance(in)
+	return &resourcesCenter.Response{
+		Code:    code,
+		Message: msg,
+	}, nil
+}

+ 34 - 0
rpc/internal/logic/updateuserdetailedlogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/internal/svc"
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type UpdateUserDetailedLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewUpdateUserDetailedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserDetailedLogic {
+	return &UpdateUserDetailedLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 根据账户标识记录资源使用流水账
+func (l *UpdateUserDetailedLogic) UpdateUserDetailed(in *resourcesCenter.Detailed) (*resourcesCenter.Response, error) {
+	// todo: add your logic here and delete this line
+	code, msg := balanceService.UpdateUserDetailed(in)
+	return &resourcesCenter.Response{
+		Code:    code,
+		Message: msg,
+	}, nil
+}

+ 12 - 0
rpc/internal/server/resourcescenterserver.go

@@ -26,3 +26,15 @@ func (s *ResourcesCenterServer) FindCompanyOrgan(ctx context.Context, in *resour
 	l := logic.NewFindCompanyOrganLogic(ctx, s.svcCtx)
 	return l.FindCompanyOrgan(in)
 }
+
+// 根据账户标识修改资源结存账
+func (s *ResourcesCenterServer) UpdateUserBalance(ctx context.Context, in *resourcesCenter.Balance) (*resourcesCenter.Response, error) {
+	l := logic.NewUpdateUserBalanceLogic(ctx, s.svcCtx)
+	return l.UpdateUserBalance(in)
+}
+
+// 根据账户标识记录资源使用流水账
+func (s *ResourcesCenterServer) UpdateUserDetailed(ctx context.Context, in *resourcesCenter.Detailed) (*resourcesCenter.Response, error) {
+	l := logic.NewUpdateUserDetailedLogic(ctx, s.svcCtx)
+	return l.UpdateUserDetailed(in)
+}

+ 32 - 1
rpc/resourcesCenter.proto

@@ -44,8 +44,39 @@ message CompanyOrgan {
    int64   id=11;
    repeated Organ data=12;   //列表
  }
-service ResourcesCenter {
 
+ message Response {
+    int64    code =1;            //响应代码
+    string   message=2;          //响应消息
+ }
+  message Balance {
+   int64    employeeId =1;           //人员标识
+   int64    companyId =2;            //企业标识
+   int64    departmentId =3;         //组织标识
+   string   name=4;                  //资源名称
+   string    code =5;                 //资源代码
+   int64    number =6;               //数量
+   string    spec =7;                 //规格
+   string   appId=8;                 //标识
+   int64    model =9;                //操作类型0使用1新增
+  }
+   message Detailed {
+      int64    employeeId =1;        //人员标识
+      int64    companyId =2;         //企业标识
+      string    resourceType =3;      //资源类型
+      int64   exportNum=4;          //导出数量
+      string    deductionType =5;     //扣类型(1高级字段包)
+      int64    ruleId =6;            //使用规则标识
+      int64    exportTime =7;        //导出时间
+      int64    userType =8;          //流水类型0使用1新增
+      int64    departmentId =9;      //组织标识
+
+   }
+service ResourcesCenter {
   //查询用户组织信息
   rpc findCompanyOrgan(OrganRequest) returns(CompanyOrganResponse);
+  //根据账户标识修改资源结存账
+  rpc updateUserBalance(Balance) returns(Response);
+  //根据账户标识记录资源使用流水账
+  rpc updateUserDetailed(Detailed) returns(Response);
 }

+ 458 - 15
rpc/resourcesCenter/resourcesCenter.pb.go

@@ -444,6 +444,283 @@ func (x *Organ) GetData() []*Organ {
 	return nil
 }
 
+type Response struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Code    int64  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`      //响应代码
+	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` //响应消息
+}
+
+func (x *Response) Reset() {
+	*x = Response{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_resourcesCenter_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Response) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Response) ProtoMessage() {}
+
+func (x *Response) ProtoReflect() protoreflect.Message {
+	mi := &file_resourcesCenter_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Response.ProtoReflect.Descriptor instead.
+func (*Response) Descriptor() ([]byte, []int) {
+	return file_resourcesCenter_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *Response) GetCode() int64 {
+	if x != nil {
+		return x.Code
+	}
+	return 0
+}
+
+func (x *Response) GetMessage() string {
+	if x != nil {
+		return x.Message
+	}
+	return ""
+}
+
+type Balance struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	EmployeeId   int64  `protobuf:"varint,1,opt,name=employeeId,proto3" json:"employeeId,omitempty"`     //人员标识
+	CompanyId    int64  `protobuf:"varint,2,opt,name=companyId,proto3" json:"companyId,omitempty"`       //企业标识
+	DepartmentId int64  `protobuf:"varint,3,opt,name=departmentId,proto3" json:"departmentId,omitempty"` //组织标识
+	Name         string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`                  //资源名称
+	Code         string `protobuf:"bytes,5,opt,name=code,proto3" json:"code,omitempty"`                  //资源代码
+	Number       int64  `protobuf:"varint,6,opt,name=number,proto3" json:"number,omitempty"`             //数量
+	Spec         string `protobuf:"bytes,7,opt,name=spec,proto3" json:"spec,omitempty"`                  //规格
+	AppId        string `protobuf:"bytes,8,opt,name=appId,proto3" json:"appId,omitempty"`                //标识
+	Model        int64  `protobuf:"varint,9,opt,name=model,proto3" json:"model,omitempty"`               //操作类型0使用1新增
+}
+
+func (x *Balance) Reset() {
+	*x = Balance{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_resourcesCenter_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Balance) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Balance) ProtoMessage() {}
+
+func (x *Balance) ProtoReflect() protoreflect.Message {
+	mi := &file_resourcesCenter_proto_msgTypes[5]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Balance.ProtoReflect.Descriptor instead.
+func (*Balance) Descriptor() ([]byte, []int) {
+	return file_resourcesCenter_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *Balance) GetEmployeeId() int64 {
+	if x != nil {
+		return x.EmployeeId
+	}
+	return 0
+}
+
+func (x *Balance) GetCompanyId() int64 {
+	if x != nil {
+		return x.CompanyId
+	}
+	return 0
+}
+
+func (x *Balance) GetDepartmentId() int64 {
+	if x != nil {
+		return x.DepartmentId
+	}
+	return 0
+}
+
+func (x *Balance) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
+}
+
+func (x *Balance) GetCode() string {
+	if x != nil {
+		return x.Code
+	}
+	return ""
+}
+
+func (x *Balance) GetNumber() int64 {
+	if x != nil {
+		return x.Number
+	}
+	return 0
+}
+
+func (x *Balance) GetSpec() string {
+	if x != nil {
+		return x.Spec
+	}
+	return ""
+}
+
+func (x *Balance) GetAppId() string {
+	if x != nil {
+		return x.AppId
+	}
+	return ""
+}
+
+func (x *Balance) GetModel() int64 {
+	if x != nil {
+		return x.Model
+	}
+	return 0
+}
+
+type Detailed struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	EmployeeId    int64  `protobuf:"varint,1,opt,name=employeeId,proto3" json:"employeeId,omitempty"`      //人员标识
+	CompanyId     int64  `protobuf:"varint,2,opt,name=companyId,proto3" json:"companyId,omitempty"`        //企业标识
+	ResourceType  string `protobuf:"bytes,3,opt,name=resourceType,proto3" json:"resourceType,omitempty"`   //资源类型
+	ExportNum     int64  `protobuf:"varint,4,opt,name=exportNum,proto3" json:"exportNum,omitempty"`        //导出数量
+	DeductionType string `protobuf:"bytes,5,opt,name=deductionType,proto3" json:"deductionType,omitempty"` //扣类型(1高级字段包)
+	RuleId        int64  `protobuf:"varint,6,opt,name=ruleId,proto3" json:"ruleId,omitempty"`              //使用规则标识
+	ExportTime    int64  `protobuf:"varint,7,opt,name=exportTime,proto3" json:"exportTime,omitempty"`      //导出时间
+	UserType      int64  `protobuf:"varint,8,opt,name=userType,proto3" json:"userType,omitempty"`          //流水类型0使用1新增
+	DepartmentId  int64  `protobuf:"varint,9,opt,name=departmentId,proto3" json:"departmentId,omitempty"`  //组织标识
+}
+
+func (x *Detailed) Reset() {
+	*x = Detailed{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_resourcesCenter_proto_msgTypes[6]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Detailed) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Detailed) ProtoMessage() {}
+
+func (x *Detailed) ProtoReflect() protoreflect.Message {
+	mi := &file_resourcesCenter_proto_msgTypes[6]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Detailed.ProtoReflect.Descriptor instead.
+func (*Detailed) Descriptor() ([]byte, []int) {
+	return file_resourcesCenter_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *Detailed) GetEmployeeId() int64 {
+	if x != nil {
+		return x.EmployeeId
+	}
+	return 0
+}
+
+func (x *Detailed) GetCompanyId() int64 {
+	if x != nil {
+		return x.CompanyId
+	}
+	return 0
+}
+
+func (x *Detailed) GetResourceType() string {
+	if x != nil {
+		return x.ResourceType
+	}
+	return ""
+}
+
+func (x *Detailed) GetExportNum() int64 {
+	if x != nil {
+		return x.ExportNum
+	}
+	return 0
+}
+
+func (x *Detailed) GetDeductionType() string {
+	if x != nil {
+		return x.DeductionType
+	}
+	return ""
+}
+
+func (x *Detailed) GetRuleId() int64 {
+	if x != nil {
+		return x.RuleId
+	}
+	return 0
+}
+
+func (x *Detailed) GetExportTime() int64 {
+	if x != nil {
+		return x.ExportTime
+	}
+	return 0
+}
+
+func (x *Detailed) GetUserType() int64 {
+	if x != nil {
+		return x.UserType
+	}
+	return 0
+}
+
+func (x *Detailed) GetDepartmentId() int64 {
+	if x != nil {
+		return x.DepartmentId
+	}
+	return 0
+}
+
 var File_resourcesCenter_proto protoreflect.FileDescriptor
 
 var file_resourcesCenter_proto_rawDesc = []byte{
@@ -512,16 +789,63 @@ var file_resourcesCenter_proto_rawDesc = []byte{
 	0x65, 0x41, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52,
 	0x02, 0x69, 0x64, 0x12, 0x2a, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0c, 0x20, 0x03, 0x28,
 	0x0b, 0x32, 0x16, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e,
-	0x74, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32,
-	0x6b, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74,
-	0x65, 0x72, 0x12, 0x58, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x64, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e,
-	0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x12, 0x1d, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
-	0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x52, 0x65,
-	0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
-	0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x4f,
-	0x72, 0x67, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x5a, 0x10,
-	0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2f,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x74, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,
+	0x38, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63,
+	0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12,
+	0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x01, 0x0a, 0x07, 0x42, 0x61,
+	0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65,
+	0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x65, 0x6d, 0x70, 0x6c, 0x6f,
+	0x79, 0x65, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
+	0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e,
+	0x79, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e,
+	0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x61, 0x72,
+	0x74, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
+	0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63,
+	0x6f, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12,
+	0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18,
+	0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x61,
+	0x70, 0x70, 0x49, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49,
+	0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03,
+	0x52, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x22, 0xa8, 0x02, 0x0a, 0x08, 0x44, 0x65, 0x74, 0x61,
+	0x69, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65,
+	0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79,
+	0x65, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x49,
+	0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
+	0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79,
+	0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
+	0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74,
+	0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x78, 0x70, 0x6f, 0x72,
+	0x74, 0x4e, 0x75, 0x6d, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x64, 0x75, 0x63, 0x74, 0x69, 0x6f,
+	0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x64,
+	0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x75,
+	0x6c, 0x65, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x72, 0x75, 0x6c, 0x65,
+	0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65,
+	0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x69,
+	0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x18, 0x08,
+	0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22,
+	0x0a, 0x0c, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x09,
+	0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74,
+	0x49, 0x64, 0x32, 0x81, 0x02, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73,
+	0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x64, 0x43, 0x6f,
+	0x6d, 0x70, 0x61, 0x6e, 0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x12, 0x1d, 0x2e, 0x72, 0x65, 0x73,
+	0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x67,
+	0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x72, 0x65, 0x73, 0x6f,
+	0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x70,
+	0x61, 0x6e, 0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
+	0x12, 0x48, 0x0a, 0x11, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x61,
+	0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
+	0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x1a,
+	0x19, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65,
+	0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x12, 0x75, 0x70,
+	0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x65, 0x64,
+	0x12, 0x19, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74,
+	0x65, 0x72, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x1a, 0x19, 0x2e, 0x72, 0x65,
+	0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x65,
+	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x5a, 0x10, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
+	0x63, 0x65, 0x73, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
+	0x6f, 0x33,
 }
 
 var (
@@ -536,20 +860,27 @@ func file_resourcesCenter_proto_rawDescGZIP() []byte {
 	return file_resourcesCenter_proto_rawDescData
 }
 
-var file_resourcesCenter_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_resourcesCenter_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
 var file_resourcesCenter_proto_goTypes = []interface{}{
 	(*OrganRequest)(nil),         // 0: resourcesCenter.OrganRequest
 	(*CompanyOrganResponse)(nil), // 1: resourcesCenter.CompanyOrganResponse
 	(*CompanyOrgan)(nil),         // 2: resourcesCenter.CompanyOrgan
 	(*Organ)(nil),                // 3: resourcesCenter.Organ
+	(*Response)(nil),             // 4: resourcesCenter.Response
+	(*Balance)(nil),              // 5: resourcesCenter.Balance
+	(*Detailed)(nil),             // 6: resourcesCenter.Detailed
 }
 var file_resourcesCenter_proto_depIdxs = []int32{
 	2, // 0: resourcesCenter.CompanyOrganResponse.data:type_name -> resourcesCenter.CompanyOrgan
 	3, // 1: resourcesCenter.Organ.data:type_name -> resourcesCenter.Organ
 	0, // 2: resourcesCenter.ResourcesCenter.findCompanyOrgan:input_type -> resourcesCenter.OrganRequest
-	1, // 3: resourcesCenter.ResourcesCenter.findCompanyOrgan:output_type -> resourcesCenter.CompanyOrganResponse
-	3, // [3:4] is the sub-list for method output_type
-	2, // [2:3] is the sub-list for method input_type
+	5, // 3: resourcesCenter.ResourcesCenter.updateUserBalance:input_type -> resourcesCenter.Balance
+	6, // 4: resourcesCenter.ResourcesCenter.updateUserDetailed:input_type -> resourcesCenter.Detailed
+	1, // 5: resourcesCenter.ResourcesCenter.findCompanyOrgan:output_type -> resourcesCenter.CompanyOrganResponse
+	4, // 6: resourcesCenter.ResourcesCenter.updateUserBalance:output_type -> resourcesCenter.Response
+	4, // 7: resourcesCenter.ResourcesCenter.updateUserDetailed:output_type -> resourcesCenter.Response
+	5, // [5:8] is the sub-list for method output_type
+	2, // [2:5] is the sub-list for method input_type
 	2, // [2:2] is the sub-list for extension type_name
 	2, // [2:2] is the sub-list for extension extendee
 	0, // [0:2] is the sub-list for field type_name
@@ -609,6 +940,42 @@ func file_resourcesCenter_proto_init() {
 				return nil
 			}
 		}
+		file_resourcesCenter_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Response); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_resourcesCenter_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Balance); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_resourcesCenter_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Detailed); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -616,7 +983,7 @@ func file_resourcesCenter_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_resourcesCenter_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   4,
+			NumMessages:   7,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
@@ -644,6 +1011,10 @@ const _ = grpc.SupportPackageIsVersion6
 type ResourcesCenterClient interface {
 	//查询用户组织信息
 	FindCompanyOrgan(ctx context.Context, in *OrganRequest, opts ...grpc.CallOption) (*CompanyOrganResponse, error)
+	//根据账户标识修改资源结存账
+	UpdateUserBalance(ctx context.Context, in *Balance, opts ...grpc.CallOption) (*Response, error)
+	//根据账户标识记录资源使用流水账
+	UpdateUserDetailed(ctx context.Context, in *Detailed, opts ...grpc.CallOption) (*Response, error)
 }
 
 type resourcesCenterClient struct {
@@ -663,10 +1034,32 @@ func (c *resourcesCenterClient) FindCompanyOrgan(ctx context.Context, in *OrganR
 	return out, nil
 }
 
+func (c *resourcesCenterClient) UpdateUserBalance(ctx context.Context, in *Balance, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/resourcesCenter.ResourcesCenter/updateUserBalance", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *resourcesCenterClient) UpdateUserDetailed(ctx context.Context, in *Detailed, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/resourcesCenter.ResourcesCenter/updateUserDetailed", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ResourcesCenterServer is the server API for ResourcesCenter service.
 type ResourcesCenterServer interface {
 	//查询用户组织信息
 	FindCompanyOrgan(context.Context, *OrganRequest) (*CompanyOrganResponse, error)
+	//根据账户标识修改资源结存账
+	UpdateUserBalance(context.Context, *Balance) (*Response, error)
+	//根据账户标识记录资源使用流水账
+	UpdateUserDetailed(context.Context, *Detailed) (*Response, error)
 }
 
 // UnimplementedResourcesCenterServer can be embedded to have forward compatible implementations.
@@ -676,6 +1069,12 @@ type UnimplementedResourcesCenterServer struct {
 func (*UnimplementedResourcesCenterServer) FindCompanyOrgan(context.Context, *OrganRequest) (*CompanyOrganResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method FindCompanyOrgan not implemented")
 }
+func (*UnimplementedResourcesCenterServer) UpdateUserBalance(context.Context, *Balance) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method UpdateUserBalance not implemented")
+}
+func (*UnimplementedResourcesCenterServer) UpdateUserDetailed(context.Context, *Detailed) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method UpdateUserDetailed not implemented")
+}
 
 func RegisterResourcesCenterServer(s *grpc.Server, srv ResourcesCenterServer) {
 	s.RegisterService(&_ResourcesCenter_serviceDesc, srv)
@@ -699,6 +1098,42 @@ func _ResourcesCenter_FindCompanyOrgan_Handler(srv interface{}, ctx context.Cont
 	return interceptor(ctx, in, info, handler)
 }
 
+func _ResourcesCenter_UpdateUserBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(Balance)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ResourcesCenterServer).UpdateUserBalance(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/resourcesCenter.ResourcesCenter/UpdateUserBalance",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ResourcesCenterServer).UpdateUserBalance(ctx, req.(*Balance))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _ResourcesCenter_UpdateUserDetailed_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(Detailed)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ResourcesCenterServer).UpdateUserDetailed(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/resourcesCenter.ResourcesCenter/UpdateUserDetailed",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ResourcesCenterServer).UpdateUserDetailed(ctx, req.(*Detailed))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _ResourcesCenter_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "resourcesCenter.ResourcesCenter",
 	HandlerType: (*ResourcesCenterServer)(nil),
@@ -707,6 +1142,14 @@ var _ResourcesCenter_serviceDesc = grpc.ServiceDesc{
 			MethodName: "findCompanyOrgan",
 			Handler:    _ResourcesCenter_FindCompanyOrgan_Handler,
 		},
+		{
+			MethodName: "updateUserBalance",
+			Handler:    _ResourcesCenter_UpdateUserBalance_Handler,
+		},
+		{
+			MethodName: "updateUserDetailed",
+			Handler:    _ResourcesCenter_UpdateUserDetailed_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "resourcesCenter.proto",

+ 21 - 2
rpc/resourcesCenterclient/resourcescenter.go

@@ -14,14 +14,21 @@ import (
 )
 
 type (
-	OrganRequest         = resourcesCenter.OrganRequest
-	CompanyOrganResponse = resourcesCenter.CompanyOrganResponse
 	CompanyOrgan         = resourcesCenter.CompanyOrgan
 	Organ                = resourcesCenter.Organ
+	Response             = resourcesCenter.Response
+	Balance              = resourcesCenter.Balance
+	Detailed             = resourcesCenter.Detailed
+	OrganRequest         = resourcesCenter.OrganRequest
+	CompanyOrganResponse = resourcesCenter.CompanyOrganResponse
 
 	ResourcesCenter interface {
 		// 查询用户组织信息
 		FindCompanyOrgan(ctx context.Context, in *OrganRequest) (*CompanyOrganResponse, error)
+		// 根据账户标识修改资源结存账
+		UpdateUserBalance(ctx context.Context, in *Balance) (*Response, error)
+		// 根据账户标识记录资源使用流水账
+		UpdateUserDetailed(ctx context.Context, in *Detailed) (*Response, error)
 	}
 
 	defaultResourcesCenter struct {
@@ -40,3 +47,15 @@ func (m *defaultResourcesCenter) FindCompanyOrgan(ctx context.Context, in *Organ
 	client := resourcesCenter.NewResourcesCenterClient(m.cli.Conn())
 	return client.FindCompanyOrgan(ctx, in)
 }
+
+// 根据账户标识修改资源结存账
+func (m *defaultResourcesCenter) UpdateUserBalance(ctx context.Context, in *Balance) (*Response, error) {
+	client := resourcesCenter.NewResourcesCenterClient(m.cli.Conn())
+	return client.UpdateUserBalance(ctx, in)
+}
+
+// 根据账户标识记录资源使用流水账
+func (m *defaultResourcesCenter) UpdateUserDetailed(ctx context.Context, in *Detailed) (*Response, error) {
+	client := resourcesCenter.NewResourcesCenterClient(m.cli.Conn())
+	return client.UpdateUserDetailed(ctx, in)
+}

+ 73 - 10
rpc/test/company_test.go

@@ -1,10 +1,11 @@
 package test
 
 import (
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/internal/config"
 	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
-	"app.yhyue.com/moapp/jyResourcesCenter/rpc/userCenter"
-	"app.yhyue.com/moapp/jyResourcesCenter/rpc/usercenterclient"
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
 	"context"
+	"flag"
 	"github.com/tal-tech/go-zero/core/conf"
 	"github.com/tal-tech/go-zero/zrpc"
 	"log"
@@ -12,20 +13,82 @@ import (
 	"time"
 )
 
+var configFile = flag.String("f", "usercenter.yaml", "the config file")
+var c config.Config
+
 func init() {
 	conf.MustLoad(*configFile, &c)
 }
 
-//企业下组织
-func Test_FindCompanyOrgan(t *testing.T) {
+/*EmployeeId
+int64  //人员标识
+CompanyId
+int64  //企业标识
+DepartmentId
+int64  //组织标识
+Name
+string //资源名称
+Code
+string //资源代码
+Number
+int64  //数量
+Spec
+string //标识
+AppId
+string //剑鱼标识
+Model
+int64  //操作类型0使用1新增*/
+//修改结存
+func Test_UpdateUserBalance(t *testing.T) {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := resourcesCenterclient.NewResourcesCenter(zrpc.MustNewClient(c.FileSystemConf))
+	req := &resourcesCenter.Balance{
+		EmployeeId:   1,
+		CompanyId:    2,
+		DepartmentId: 3,
+		Name:         "数据导出",
+		Code:         "001",
+		Number:       123,
+		Spec:         "021",
+		AppId:        "10000",
+		Model:        1,
+	}
+	res, err := FileSystem.UpdateUserBalance(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}
+/*EmployeeId
+int64  //人员标识
+CompanyId
+int64  //企业标识
+ResourceType
+string //资源类型
+ExportNum
+int64  //导出数量
+DeductionType
+string //扣类型(1高级字段包)
+int64
+ExportTime
+RuleId  //使用规则标识
+int64  //导出时间
+UserType
+int64  //流水类型0使用1新增
+DepartmentId
+int64  //组织标识*/
+func Test_UpdateUserDetailed(t *testing.T) {
 	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := resourcesCenter.NewResourcesCenterClient(zrpc.MustNewClient(c.FileSystemConf))
-	//解绑
-	req := &resourcesCenter.OrganRequest{
-		Id:        24,
-		CompanyId: 1,
+	FileSystem := resourcesCenterclient.NewResourcesCenter(zrpc.MustNewClient(c.FileSystemConf))
+	req := &resourcesCenter.Detailed{
+		EmployeeId:    1,
+		CompanyId:     2,
+		ResourceType:  "100",
+		ExportNum:     100,
+		DeductionType: "1",
+		RuleId:        12,
+		UserType:      1,
+		DepartmentId:  3,
 	}
-	res, err := FileSystem.FindCompanyOrgan(ctx, req)
+	res, err := FileSystem.UpdateUserDetailed(ctx, req)
 	log.Println("err ", err)
 	log.Println("req ", res)
 }

+ 109 - 0
service/balanceService.go

@@ -0,0 +1,109 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jyResourcesCenter/entity"
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
+	"log"
+	"time"
+)
+
+type BalanceService struct{}
+
+const (
+	ConsumeRecord    = "consume_record"    //流水表
+	AccountResources = "account_resources" //结存表
+)
+
+//根据账户标识修改资源结存账
+func (service *BalanceService) UpdateUserBalance(in *resourcesCenter.Balance) (int64, string) {
+	orm := entity.Engine
+	balance := entity.Balance{}
+	fool, err := orm.Table(AccountResources).
+		Select("*").
+		Where("employeeId=? and  companyId=? and  departmentId=? and  code=?", in.EmployeeId, in.CompanyId, in.DepartmentId, in.Code).
+		Get(&balance)
+	if err != nil && !fool {
+		log.Panicln("结存查询失败:", err)
+		return entity.ErrorCode, "企业下的组织查询失败"
+	}
+	if balance.Id == 0 {
+		if in.Model == 0 {
+			return entity.ErrorCode, "该用户没有结存不可使用"
+		}
+		//新增结存记录
+		balance = entity.Balance{
+			EmployeeId:   in.EmployeeId,
+			CompanyId:    in.CompanyId,
+			DepartmentId: in.DepartmentId,
+			Name:         in.Name,
+			Code:         in.Code,
+			Number:       in.Number,
+			Spec:         in.Spec,
+			AppId:        in.AppId,
+		}
+		insertNumb, err := orm.Table(AccountResources).Insert(&balance)
+		if err != nil {
+			log.Panicln("结存查询失败:", err)
+			return entity.ErrorCode, "企业下的组织查询失败"
+		}
+		if insertNumb > 0 {
+			return entity.SuccessCode, "结存新增成功"
+		}
+
+	}
+	if in.Model == 0 {
+		if (balance.Number > in.Number) {
+			return entity.ErrorCode, "该用户结存不够不可使用"
+		}
+		balance.Number = balance.Number - in.Number
+		updateNumb, err := orm.Table(AccountResources).
+			Cols("number").
+			Where("employeeId=? and  companyId=? and  departmentId=? and  code=?", in.EmployeeId, in.CompanyId, in.DepartmentId, in.Code).
+			Update(&balance)
+		if err != nil {
+			log.Panicln("结存修改失败:", err)
+			return entity.ErrorCode, "结存修改失败"
+		}
+		if updateNumb > 0 {
+			return entity.SuccessCode, "结存修改成功"
+		}
+		return entity.ErrorCode, "结存修改失败"
+	}
+	balance.Number = balance.Number + in.Number
+	updateNumb, err := orm.Table(AccountResources).
+		Where("employeeId=? and  companyId=? and  departmentId=? and  code=?", in.EmployeeId, in.CompanyId, in.DepartmentId, in.Code).
+		Update(&balance)
+	if err != nil {
+		log.Panicln("结存修改失败:", err)
+		return entity.ErrorCode, "结存修改失败"
+	}
+	if updateNumb > 0 {
+		return entity.SuccessCode, "结存修改成功"
+	}
+	return entity.ErrorCode, "结存修改失败"
+}
+
+//根据账户标识记录资源使用流水账
+func (service *BalanceService) UpdateUserDetailed(in *resourcesCenter.Detailed) (int64, string) {
+	orm := entity.Engine
+	//新增流水记录
+	detailed := entity.Detailed{
+		EmployeeId:   in.EmployeeId,
+		CompanyId:    in.CompanyId,
+		DepartmentId: in.DepartmentId,
+		ResourceType: in.ResourceType,
+		ExportNum:    in.ExportNum,
+		RuleId:       in.RuleId,
+		ExportTime:   time.Now().Local(),
+		UserType:     in.UserType,
+	}
+	insertNumb, err := orm.Table(ConsumeRecord).Insert(&detailed)
+	if err != nil {
+		log.Panicln("新增流水失败:", err)
+		return entity.ErrorCode, "新增流水失败"
+	}
+	if insertNumb > 0 {
+		return entity.SuccessCode, "新增流水成功"
+	}
+	return entity.ErrorCode, "新增流水失败"
+}