|
@@ -117,22 +117,34 @@ func (service *BalanceService) PurchaseUserBalance(balanceData *resourcesCenter.
|
|
}
|
|
}
|
|
|
|
|
|
//根据账户标识使用资源
|
|
//根据账户标识使用资源
|
|
-func (service *BalanceService) UseUserDetailed(balanceData *resourcesCenter.Balance, detailedData *resourcesCenter.Detailed) (int64, string) {
|
|
|
|
|
|
+func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceData *resourcesCenter.Balance, detailedData *resourcesCenter.Detailed, infoId, url string) (int64, string) {
|
|
orm := entity.Engine.NewSession()
|
|
orm := entity.Engine.NewSession()
|
|
err := orm.Begin()
|
|
err := orm.Begin()
|
|
//去重
|
|
//去重
|
|
- deductionNumb := int64(0)
|
|
|
|
- deductionNumb = detailedData.ExportNum
|
|
|
|
|
|
+ deductionNumb := detailedData.ExportNum
|
|
|
|
+ if duplicateRemoval == 1 {
|
|
|
|
+ url=url+"/data/dedupAndSave?personId="+detailedData.UserId+"&infoId="+infoId+"&accountId="+detailedData.AccountId
|
|
|
|
+ res, urlerr := http.PostForm( url, nil)
|
|
|
|
+ fmt.Println(url, urlerr)
|
|
|
|
+ defer res.Body.Close()
|
|
|
|
+ body, _ := ioutil.ReadAll(res.Body)
|
|
|
|
+ dat := entity.Dedup{}
|
|
|
|
+ _ = json.Unmarshal([]byte(body), &dat)
|
|
|
|
+ fmt.Println(dat)
|
|
|
|
+ if dat.Code == 0 {
|
|
|
|
+ deductionNumb = dat.Data.NewCount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//查询结存是否够用
|
|
//查询结存是否够用
|
|
type SumStruct struct {
|
|
type SumStruct struct {
|
|
Age int `xorm:"age"`
|
|
Age int `xorm:"age"`
|
|
}
|
|
}
|
|
sumStruct := "0"
|
|
sumStruct := "0"
|
|
- fool, err := orm.Table(AccountResources).
|
|
|
|
|
|
+ _, err = orm.Table(AccountResources).
|
|
Select("sum(number) as number").
|
|
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")).
|
|
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)
|
|
Get(&sumStruct)
|
|
- fmt.Println(fool, sumStruct)
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Panicln("结存查询失败:", err)
|
|
log.Panicln("结存查询失败:", err)
|
|
orm.Rollback()
|
|
orm.Rollback()
|
|
@@ -169,6 +181,9 @@ func (service *BalanceService) UseUserDetailed(balanceData *resourcesCenter.Bala
|
|
orm.Rollback()
|
|
orm.Rollback()
|
|
return entity.ErrorCode, "新增流水失败"
|
|
return entity.ErrorCode, "新增流水失败"
|
|
}
|
|
}
|
|
|
|
+ if deductionNumb==0{
|
|
|
|
+ return entity.SuccessCode, "修改结存成功"
|
|
|
|
+ }
|
|
//修改结存
|
|
//修改结存
|
|
balanceList := []entity.Balance{}
|
|
balanceList := []entity.Balance{}
|
|
err = orm.Table(AccountResources).
|
|
err = orm.Table(AccountResources).
|