Jianghan 6 months ago
parent
commit
fb8960cd7d
3 changed files with 66 additions and 68 deletions
  1. 5 6
      rpc/resourcesCenter.proto
  2. 18 28
      rpc/resourcesCenter/resourcesCenter.pb.go
  3. 43 34
      service/exportChargeService.go

+ 5 - 6
rpc/resourcesCenter.proto

@@ -199,20 +199,19 @@ message EntOperateReq {
 
 
 message ChargeAccountReq {
 message ChargeAccountReq {
   int64 entId = 1;
   int64 entId = 1;
-  int64 UserId = 2;
+  string UserId = 2;
   int64 entUserId = 3;
   int64 entUserId = 3;
 }
 }
 
 
 message ChargeReq {
 message ChargeReq {
   int64 entId = 1;
   int64 entId = 1;
-  int64 userId = 2;
+  string userId = 2;
   int64 entUserId = 3;
   int64 entUserId = 3;
   int64 exportNum = 4;
   int64 exportNum = 4;
   int64 deductNum = 5;
   int64 deductNum = 5;
-  string positionId = 6;
-  string accountId = 7;
-  int32 chargeType = 8;  //扣费方式,0: 企业,1: 个人
-  string remark = 9; // 备注
+  string accountId = 6;
+  int32 chargeType = 7;  //扣费方式,0: 企业,1: 个人
+  string remark = 8; // 备注
 }
 }
 
 
 message ChargeResp {
 message ChargeResp {

+ 18 - 28
rpc/resourcesCenter/resourcesCenter.pb.go

@@ -1912,9 +1912,9 @@ type ChargeAccountReq struct {
 	sizeCache     protoimpl.SizeCache
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 	unknownFields protoimpl.UnknownFields
 
 
-	EntId     int64 `protobuf:"varint,1,opt,name=entId,proto3" json:"entId,omitempty"`
-	UserId    int64 `protobuf:"varint,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
-	EntUserId int64 `protobuf:"varint,3,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
+	EntId     int64  `protobuf:"varint,1,opt,name=entId,proto3" json:"entId,omitempty"`
+	UserId    string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
+	EntUserId int64  `protobuf:"varint,3,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
 }
 }
 
 
 func (x *ChargeAccountReq) Reset() {
 func (x *ChargeAccountReq) Reset() {
@@ -1956,11 +1956,11 @@ func (x *ChargeAccountReq) GetEntId() int64 {
 	return 0
 	return 0
 }
 }
 
 
-func (x *ChargeAccountReq) GetUserId() int64 {
+func (x *ChargeAccountReq) GetUserId() string {
 	if x != nil {
 	if x != nil {
 		return x.UserId
 		return x.UserId
 	}
 	}
-	return 0
+	return ""
 }
 }
 
 
 func (x *ChargeAccountReq) GetEntUserId() int64 {
 func (x *ChargeAccountReq) GetEntUserId() int64 {
@@ -1976,14 +1976,13 @@ type ChargeReq struct {
 	unknownFields protoimpl.UnknownFields
 	unknownFields protoimpl.UnknownFields
 
 
 	EntId      int64  `protobuf:"varint,1,opt,name=entId,proto3" json:"entId,omitempty"`
 	EntId      int64  `protobuf:"varint,1,opt,name=entId,proto3" json:"entId,omitempty"`
-	UserId     int64  `protobuf:"varint,2,opt,name=userId,proto3" json:"userId,omitempty"`
+	UserId     string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"`
 	EntUserId  int64  `protobuf:"varint,3,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
 	EntUserId  int64  `protobuf:"varint,3,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
 	ExportNum  int64  `protobuf:"varint,4,opt,name=exportNum,proto3" json:"exportNum,omitempty"`
 	ExportNum  int64  `protobuf:"varint,4,opt,name=exportNum,proto3" json:"exportNum,omitempty"`
 	DeductNum  int64  `protobuf:"varint,5,opt,name=deductNum,proto3" json:"deductNum,omitempty"`
 	DeductNum  int64  `protobuf:"varint,5,opt,name=deductNum,proto3" json:"deductNum,omitempty"`
-	PositionId string `protobuf:"bytes,6,opt,name=positionId,proto3" json:"positionId,omitempty"`
-	AccountId  string `protobuf:"bytes,7,opt,name=accountId,proto3" json:"accountId,omitempty"`
-	ChargeType int32  `protobuf:"varint,8,opt,name=chargeType,proto3" json:"chargeType,omitempty"` //扣费方式,0: 企业,1: 个人
-	Remark     string `protobuf:"bytes,9,opt,name=remark,proto3" json:"remark,omitempty"`          // 备注
+	AccountId  string `protobuf:"bytes,6,opt,name=accountId,proto3" json:"accountId,omitempty"`
+	ChargeType int32  `protobuf:"varint,7,opt,name=chargeType,proto3" json:"chargeType,omitempty"` //扣费方式,0: 企业,1: 个人
+	Remark     string `protobuf:"bytes,8,opt,name=remark,proto3" json:"remark,omitempty"`          // 备注
 }
 }
 
 
 func (x *ChargeReq) Reset() {
 func (x *ChargeReq) Reset() {
@@ -2025,11 +2024,11 @@ func (x *ChargeReq) GetEntId() int64 {
 	return 0
 	return 0
 }
 }
 
 
-func (x *ChargeReq) GetUserId() int64 {
+func (x *ChargeReq) GetUserId() string {
 	if x != nil {
 	if x != nil {
 		return x.UserId
 		return x.UserId
 	}
 	}
-	return 0
+	return ""
 }
 }
 
 
 func (x *ChargeReq) GetEntUserId() int64 {
 func (x *ChargeReq) GetEntUserId() int64 {
@@ -2053,13 +2052,6 @@ func (x *ChargeReq) GetDeductNum() int64 {
 	return 0
 	return 0
 }
 }
 
 
-func (x *ChargeReq) GetPositionId() string {
-	if x != nil {
-		return x.PositionId
-	}
-	return ""
-}
-
 func (x *ChargeReq) GetAccountId() string {
 func (x *ChargeReq) GetAccountId() string {
 	if x != nil {
 	if x != nil {
 		return x.AccountId
 		return x.AccountId
@@ -2518,25 +2510,23 @@ var file_resourcesCenter_proto_rawDesc = []byte{
 	0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71,
 	0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71,
 	0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
 	0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
 	0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
 	0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
-	0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c,
 	0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
 	0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
-	0x03, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x89, 0x02, 0x0a,
+	0x03, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0xe9, 0x01, 0x0a,
 	0x09, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e,
 	0x09, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e,
 	0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64,
 	0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64,
-	0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
+	0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55,
 	0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55,
 	0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x74,
 	0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x74,
 	0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74,
 	0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 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,
 	0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x78, 0x70, 0x6f, 0x72,
 	0x74, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x75,
 	0x74, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x75,
 	0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x64, 0x65, 0x64, 0x75, 0x63, 0x74, 0x4e,
 	0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x64, 0x65, 0x64, 0x75, 0x63, 0x74, 0x4e,
-	0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64,
-	0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
-	0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x18,
-	0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64,
-	0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x08,
+	0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x18,
+	0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64,
+	0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x07,
 	0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65,
 	0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65,
-	0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09,
+	0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x69, 0x0a, 0x0a, 0x43, 0x68, 0x61, 0x72,
 	0x52, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x69, 0x0a, 0x0a, 0x43, 0x68, 0x61, 0x72,
 	0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01,
 	0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 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,
 	0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65,

+ 43 - 34
service/exportChargeService.go

@@ -4,7 +4,6 @@ import (
 	"app.yhyue.com/moapp/jyResourcesCenter/entity"
 	"app.yhyue.com/moapp/jyResourcesCenter/entity"
 	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
 	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/common"
-	"log"
 	"strings"
 	"strings"
 	"time"
 	"time"
 )
 )
@@ -17,9 +16,9 @@ func ChargeAccount(data *resourcesCenter.ChargeAccountReq) (resp *resourcesCente
 	jyOrm := entity.JyEngine.NewSession()
 	jyOrm := entity.JyEngine.NewSession()
 	centerOrm := entity.Engine.NewSession()
 	centerOrm := entity.Engine.NewSession()
 	var exportPower int
 	var exportPower int
-	has, _ := jyOrm.Table("entniche_user").Cols("export_power").Where("id = ?", data.UserId).Get(&exportPower)
-	if has && exportPower == 0 {
-		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "人员没有数据定制导出权限"}
+	_, err := jyOrm.Table("entniche_user").Cols("export_power").Where("id = ?", data.UserId).Get(&exportPower)
+	if err != nil {
+		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "人员数据定制权限查询失败"}
 	}
 	}
 	entInfo, b := entity.Mgo.FindOne("user", map[string]interface{}{"entid": data.EntId})
 	entInfo, b := entity.Mgo.FindOne("user", map[string]interface{}{"entid": data.EntId})
 	var entNums int64
 	var entNums int64
@@ -31,7 +30,7 @@ func ChargeAccount(data *resourcesCenter.ChargeAccountReq) (resp *resourcesCente
 	}
 	}
 	var personNums int64
 	var personNums int64
 	_ = centerOrm.Table("account_resources").Cols("SUM(number) AS totalNum").
 	_ = centerOrm.Table("account_resources").Cols("SUM(number) AS totalNum").
-		Where("accountId = ? and endTime >= ? and resourceType = ?", data.EntId, now, "高级字段包").Find(&personNums)
+		Where("accountId = ? and endTime >= ? and resourceType = ?", data.UserId, now, "高级字段包").Find(&personNums)
 	if exportPower == 1 && (entNums > 0 || personNums == 0) {
 	if exportPower == 1 && (entNums > 0 || personNums == 0) {
 		// 企业流量包扣除
 		// 企业流量包扣除
 		var personLimit []*entity.PersonLimit
 		var personLimit []*entity.PersonLimit
@@ -82,14 +81,17 @@ func ChargeFunc(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRe
 func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeResp) {
 func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeResp) {
 	souceOrm := entity.Engine.NewSession()
 	souceOrm := entity.Engine.NewSession()
 	jyOrm := entity.JyEngine.NewSession()
 	jyOrm := entity.JyEngine.NewSession()
-	var personLimit *entity.PersonLimit
-	_ = jyOrm.Table("entniche_export_limit").Select("*").
+	var personLimit []*entity.PersonLimit
+	err := jyOrm.Table("entniche_export_limit").Select("*").
 		Where("ent_id = ? and user_id = ?", data.EntId, data.EntUserId).Find(&personLimit)
 		Where("ent_id = ? and user_id = ?", data.EntId, data.EntUserId).Find(&personLimit)
+	if err != nil || personLimit == nil || len(personLimit) == 0 {
+		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "企业个人账号限额查询失败"}
+	}
 	var entNums int64
 	var entNums int64
 	entInfo, b := entity.Mgo.FindOne("user", map[string]interface{}{"entid": data.EntId})
 	entInfo, b := entity.Mgo.FindOne("user", map[string]interface{}{"entid": data.EntId})
-	log.Println(*entInfo)
 	if b && len(*entInfo) > 0 && (*entInfo)["plan"] != nil {
 	if b && len(*entInfo) > 0 && (*entInfo)["plan"] != nil {
-		entNums = common.Int64All((*entInfo)["current"])
+		plan := (*entInfo)["plan"].(map[string]interface{})
+		entNums = common.Int64All(plan["current"])
 	} else {
 	} else {
 		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "未查询到企业数据流量"}
 		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "未查询到企业数据流量"}
 	}
 	}
@@ -102,10 +104,10 @@ func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRes
 				ChargeResult: 0,
 				ChargeResult: 0,
 				FailMsg:      "企业数据流量包余额不足",
 				FailMsg:      "企业数据流量包余额不足",
 				Num1:         entNums,
 				Num1:         entNums,
-				Num2:         personLimit.DataLimit,
-				Num3:         common.Int64All(common.If(personLimit.DataLimit == 0 && personLimit.MaxNums == 0, 0, personLimit.DataLimit-personLimit.ExportNums)),
-				Num4:         personLimit.MaxNums,
-				Num5:         common.Int64All(common.If(personLimit.DataLimit == 0 && personLimit.MaxNums == 0, 0, personLimit.MaxNums-personLimit.AllExportNums)),
+				Num2:         personLimit[0].DataLimit,
+				Num3:         common.Int64All(common.If(personLimit[0].DataLimit == 0 && personLimit[0].MaxNums == 0, 0, personLimit[0].DataLimit-personLimit[0].ExportNums)),
+				Num4:         personLimit[0].MaxNums,
+				Num5:         common.Int64All(common.If(personLimit[0].DataLimit == 0 && personLimit[0].MaxNums == 0, 0, personLimit[0].MaxNums-personLimit[0].AllExportNums)),
 			},
 			},
 		}
 		}
 	}
 	}
@@ -123,30 +125,30 @@ func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRes
 	}
 	}
 	b = entity.Mgo.Update("user", query, update, false, false)
 	b = entity.Mgo.Update("user", query, update, false, false)
 	if !b {
 	if !b {
-		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
+		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "企业余额操作失败"}
 	}
 	}
-	err := jyOrm.Begin()
+	err = jyOrm.Begin()
 	//更新限额
 	//更新限额
 	if err != nil {
 	if err != nil {
 		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
 		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
 	}
 	}
 	var updateNum = int64(0)
 	var updateNum = int64(0)
-	if personLimit.DataLimit == 0 && personLimit.MaxNums == 0 {
+	if personLimit[0].DataLimit == 0 && personLimit[0].MaxNums == 0 {
 		// 当前账号没有限额
 		// 当前账号没有限额
-		updateNum, err = jyOrm.Table("entniche_export_limit").Where("id = ?", personLimit.Id).
+		updateNum, err = jyOrm.Table("entniche_export_limit").Where("id = ?", personLimit[0].Id).
 			Incr("export_nums", data.ExportNum).
 			Incr("export_nums", data.ExportNum).
-			Incr("all_export_nums", data.ExportNum).Update(nil)
+			Incr("all_export_nums", data.ExportNum).Update(&entity.PersonLimit{})
 		if err != nil || updateNum <= 0 {
 		if err != nil || updateNum <= 0 {
 			_ = jyOrm.Rollback()
 			_ = jyOrm.Rollback()
 			return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
 			return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
 		}
 		}
 	} else {
 	} else {
-		updateNum, err = jyOrm.Table("entniche_export_limit").Where("id = ? and data_limit >=", 0, personLimit.Id, data.DeductNum).
+		updateNum, err = jyOrm.Table("entniche_export_limit").Where("id = ? and data_limit >= ?", personLimit[0].Id, data.DeductNum).
 			Decr("data_limit", data.DeductNum).
 			Decr("data_limit", data.DeductNum).
 			Decr("max_nums", data.DeductNum).
 			Decr("max_nums", data.DeductNum).
 			Incr("export_nums", data.ExportNum).
 			Incr("export_nums", data.ExportNum).
 			Incr("all_export_nums", data.ExportNum).
 			Incr("all_export_nums", data.ExportNum).
-			Update(nil)
+			Update(&entity.PersonLimit{})
 		if err != nil {
 		if err != nil {
 			_ = jyOrm.Rollback()
 			_ = jyOrm.Rollback()
 			return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
 			return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "操作失败"}
@@ -156,10 +158,10 @@ func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRes
 			_ = jyOrm.Table("entniche_export_limit").Select("*").
 			_ = jyOrm.Table("entniche_export_limit").Select("*").
 				Where("ent_id = ? and user_id = ?", data.EntId, data.EntUserId).Find(&personLimit)
 				Where("ent_id = ? and user_id = ?", data.EntId, data.EntUserId).Find(&personLimit)
 			var msg []string
 			var msg []string
-			if personLimit.DataLimit < data.DeductNum {
+			if personLimit[0].DataLimit < data.DeductNum {
 				msg = append(msg, "超出您的每日导出限额")
 				msg = append(msg, "超出您的每日导出限额")
 			}
 			}
-			if personLimit.MaxNums < data.DeductNum {
+			if personLimit[0].MaxNums < data.DeductNum {
 				msg = append(msg, "超出您的数据导出总量限额")
 				msg = append(msg, "超出您的数据导出总量限额")
 			}
 			}
 			return &resourcesCenter.ChargeResp{
 			return &resourcesCenter.ChargeResp{
@@ -170,10 +172,10 @@ func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRes
 					ChargeResult: 0,
 					ChargeResult: 0,
 					FailMsg:      common.ObjToString(common.If(len(msg) > 0, strings.Join(msg, "、"), "")),
 					FailMsg:      common.ObjToString(common.If(len(msg) > 0, strings.Join(msg, "、"), "")),
 					Num1:         entNums,
 					Num1:         entNums,
-					Num2:         personLimit.DataLimit,
-					Num3:         personLimit.DataLimit - personLimit.ExportNums,
-					Num4:         personLimit.MaxNums,
-					Num5:         personLimit.MaxNums - personLimit.AllExportNums,
+					Num2:         personLimit[0].DataLimit,
+					Num3:         personLimit[0].DataLimit - personLimit[0].ExportNums,
+					Num4:         personLimit[0].MaxNums,
+					Num5:         personLimit[0].MaxNums - personLimit[0].AllExportNums,
 				},
 				},
 			}
 			}
 		}
 		}
@@ -188,7 +190,7 @@ func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRes
 		CreateTime:   time.Now().Local(),
 		CreateTime:   time.Now().Local(),
 		Remarks:      data.Remark,
 		Remarks:      data.Remark,
 		UserType:     0,
 		UserType:     0,
-		UserId:       data.PositionId,
+		UserId:       data.UserId,
 		AccountType:  1,
 		AccountType:  1,
 		EntId:        data.EntId,
 		EntId:        data.EntId,
 	}
 	}
@@ -209,10 +211,10 @@ func entCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.ChargeRes
 			ChargeType:   0,
 			ChargeType:   0,
 			ChargeResult: 1,
 			ChargeResult: 1,
 			Num1:         entNums,
 			Num1:         entNums,
-			Num2:         personLimit.DataLimit,
-			Num3:         personLimit.DataLimit - personLimit.ExportNums,
-			Num4:         personLimit.MaxNums,
-			Num5:         personLimit.MaxNums - personLimit.AllExportNums,
+			Num2:         personLimit[0].DataLimit,
+			Num3:         personLimit[0].DataLimit - personLimit[0].ExportNums,
+			Num4:         personLimit[0].MaxNums,
+			Num5:         personLimit[0].MaxNums - personLimit[0].AllExportNums,
 		},
 		},
 	}
 	}
 }
 }
@@ -225,10 +227,17 @@ func personCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.Charge
 	err := centerOrm.Table("account_resources").Cols("SUM(number) AS totalNum").
 	err := centerOrm.Table("account_resources").Cols("SUM(number) AS totalNum").
 		Where("accountId = ? and endTime >= ? and resourceType = ?", data.EntId, now, "高级字段包").Find(&personNums)
 		Where("accountId = ? and endTime >= ? and resourceType = ?", data.EntId, now, "高级字段包").Find(&personNums)
 	if err != nil {
 	if err != nil {
-		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "查询失败"}
+		return &resourcesCenter.ChargeResp{Code: entity.ErrorCode, Message: "个人余额查询失败"}
 	}
 	}
 	if personNums == 0 || personNums < data.DeductNum {
 	if personNums == 0 || personNums < data.DeductNum {
-		return &resourcesCenter.ChargeResp{Code: entity.SuccessCode, Message: "个人数据流量包(高级字段包)余额不足"}
+		return &resourcesCenter.ChargeResp{
+			Code: entity.SuccessCode,
+			Data: &resourcesCenter.SomeInfo{
+				ChargeType:   1,
+				ChargeResult: 0,
+				Num1:         personNums,
+			},
+		}
 	}
 	}
 	var updateNum int64
 	var updateNum int64
 	err = centerOrm.Begin()
 	err = centerOrm.Begin()
@@ -275,7 +284,7 @@ func personCharge(data *resourcesCenter.ChargeReq) (resp *resourcesCenter.Charge
 		CreateTime:   time.Now().Local(),
 		CreateTime:   time.Now().Local(),
 		Remarks:      data.Remark,
 		Remarks:      data.Remark,
 		UserType:     0,
 		UserType:     0,
-		UserId:       data.PositionId,
+		UserId:       data.UserId,
 		AccountType:  1,
 		AccountType:  1,
 		EntId:        data.EntId,
 		EntId:        data.EntId,
 	}
 	}