|
@@ -3,7 +3,9 @@ package service
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jyResourcesCenter/entity"
|
|
|
"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
|
|
|
+ "fmt"
|
|
|
"log"
|
|
|
+ "strconv"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -116,22 +118,23 @@ func (service *BalanceService) UseUserDetailed(balanceData *resourcesCenter.Bala
|
|
|
err := orm.Begin()
|
|
|
//去重
|
|
|
deductionNumb := int64(0)
|
|
|
-
|
|
|
+ deductionNumb = detailedData.ExportNum
|
|
|
//查询结存是否够用
|
|
|
type SumStruct struct {
|
|
|
- count int64
|
|
|
+ Age int `xorm:"age"`
|
|
|
}
|
|
|
- sumStruct := new(SumStruct)
|
|
|
- totals, err := orm.Table(AccountResources).
|
|
|
- Select("*").
|
|
|
- Where("accountId=? and companyId=? and departmentId=? and ResourceType=? and endTime=?", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, balanceData.EndTime).
|
|
|
- SumsInt(sumStruct, "number")
|
|
|
+ sumStruct := "0"
|
|
|
+ fool, err := orm.Table(AccountResources).
|
|
|
+ Select("sum(number) as number").
|
|
|
+ Where("accountId=? and companyId=? and departmentId=? and ResourceType=? and endTime>=?", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, time.Now().Format("2006-01-02")).
|
|
|
+ Get(&sumStruct)
|
|
|
+ fmt.Println(fool, sumStruct)
|
|
|
if err != nil {
|
|
|
log.Panicln("结存查询失败:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "结存查询失败"
|
|
|
}
|
|
|
- surplusNumb := totals[0]
|
|
|
+ surplusNumb, err := strconv.ParseInt(sumStruct, 10, 64)
|
|
|
if surplusNumb < deductionNumb {
|
|
|
return entity.ErrorCode, "结存不足,请立即充值"
|
|
|
}
|
|
@@ -183,7 +186,7 @@ func (service *BalanceService) UseUserDetailed(balanceData *resourcesCenter.Bala
|
|
|
value.Number = 0
|
|
|
}
|
|
|
updateNumb, err := orm.Table(AccountResources).
|
|
|
- Cols("number").ID(value).
|
|
|
+ Cols("number").ID(value.Id).
|
|
|
Update(&value)
|
|
|
if err != nil {
|
|
|
log.Panicln("结存修改失败:", err)
|