|
@@ -36,7 +36,7 @@ func (service *BalanceService) UpdateUserBalance(in *resourcesCenter.Balance) (i
|
|
|
CompanyId: in.CompanyId,
|
|
|
DepartmentId: in.DepartmentId,
|
|
|
Name: in.Name,
|
|
|
- ResourceType: in.ResourceType,
|
|
|
+ ResourceType: in.ResourceType,
|
|
|
Number: in.Number,
|
|
|
Spec: in.Spec,
|
|
|
AppId: in.AppId,
|
|
@@ -52,13 +52,13 @@ func (service *BalanceService) UpdateUserBalance(in *resourcesCenter.Balance) (i
|
|
|
|
|
|
}
|
|
|
if in.Model == 0 {
|
|
|
- if (balance.Number > in.Number) {
|
|
|
+ if (balance.Number < in.Number) {
|
|
|
return entity.ErrorCode, "该用户结存不够不可使用"
|
|
|
}
|
|
|
balance.Number = balance.Number - in.Number
|
|
|
updateNumb, err := orm.Table(AccountResources).
|
|
|
Cols("number").
|
|
|
- Where("accountId=? and companyId=? and departmentId=? and code=?", in.AccountId, in.CompanyId, in.DepartmentId, in.ResourceType).
|
|
|
+ Where("accountId=? and companyId=? and departmentId=? and resourceType=?", in.AccountId, in.CompanyId, in.DepartmentId, in.ResourceType).
|
|
|
Update(&balance)
|
|
|
if err != nil {
|
|
|
log.Panicln("结存修改失败:", err)
|
|
@@ -71,7 +71,7 @@ func (service *BalanceService) UpdateUserBalance(in *resourcesCenter.Balance) (i
|
|
|
}
|
|
|
balance.Number = balance.Number + in.Number
|
|
|
updateNumb, err := orm.Table(AccountResources).
|
|
|
- Where("accountId=? and companyId=? and departmentId=? and code=?", in.AccountId, in.CompanyId, in.DepartmentId, in.ResourceType).
|
|
|
+ Where("accountId=? and companyId=? and departmentId=? and resourceType=?", in.AccountId, in.CompanyId, in.DepartmentId, in.ResourceType).
|
|
|
Update(&balance)
|
|
|
if err != nil {
|
|
|
log.Panicln("结存修改失败:", err)
|
|
@@ -96,6 +96,7 @@ func (service *BalanceService) UpdateUserDetailed(in *resourcesCenter.Detailed)
|
|
|
RuleId: in.RuleId,
|
|
|
ExportTime: time.Now().Local(),
|
|
|
UserType: in.UserType,
|
|
|
+ UserId: in.UserId,
|
|
|
}
|
|
|
insertNumb, err := orm.Table(ConsumeRecord).Insert(&detailed)
|
|
|
if err != nil {
|