|
@@ -110,11 +110,12 @@ func (service *BalanceService) PurchaseUserBalance(balanceData *resourcesCenter.
|
|
|
}
|
|
|
|
|
|
//根据账户标识使用资源
|
|
|
-func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceData *resourcesCenter.Balance, detailedData *resourcesCenter.Detailed, infoId, url string) (int64, string) {
|
|
|
+func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceData *resourcesCenter.Balance, detailedData *resourcesCenter.Detailed, infoId, url string) (int64, string,int64) {
|
|
|
orm := entity.Engine.NewSession()
|
|
|
err := orm.Begin()
|
|
|
//去重
|
|
|
deductionNumb := detailedData.Number
|
|
|
+ deductionNumbs:= detailedData.Number
|
|
|
if duplicateRemoval == 1 {
|
|
|
dataDesc:=0
|
|
|
if detailedData.ResourceType == "标准字段包" {
|
|
@@ -125,7 +126,7 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
url = url + "/data/dedupAndSave?dataDesc="+fmt.Sprint(dataDesc)+"&personId=" + detailedData.UserId + "&infoId=" + infoId + "&accountId=" + detailedData.AccountId
|
|
|
res, urlerr := http.PostForm(url, nil)
|
|
|
if urlerr != nil {
|
|
|
- return entity.ErrorCode, "去重失败"
|
|
|
+ return entity.ErrorCode, "去重失败",0
|
|
|
}
|
|
|
defer res.Body.Close()
|
|
|
body, _ := ioutil.ReadAll(res.Body)
|
|
@@ -133,6 +134,7 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
_ = json.Unmarshal([]byte(body), &dat)
|
|
|
if dat.Code == 0 {
|
|
|
deductionNumb = dat.Data.NewCount
|
|
|
+ deductionNumbs= dat.Data.NewCount
|
|
|
}
|
|
|
}
|
|
|
//查询结存是否够用
|
|
@@ -147,11 +149,11 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
if err != nil {
|
|
|
fmt.Println("结存查询失败:", err)
|
|
|
orm.Rollback()
|
|
|
- return entity.ErrorCode, "结存查询失败"
|
|
|
+ return entity.ErrorCode, "结存查询失败",0
|
|
|
}
|
|
|
surplusNumb, err := strconv.ParseInt(sumStruct, 10, 64)
|
|
|
if surplusNumb < deductionNumb {
|
|
|
- return entity.ErrorCode, "结存不足,请立即充值"
|
|
|
+ return entity.ErrorCode, "结存不足,请立即充值",0
|
|
|
}
|
|
|
//新增流水记录
|
|
|
detailed := entity.Detailed{
|
|
@@ -172,11 +174,11 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
if err != nil || insertNumb <= 0 {
|
|
|
fmt.Println("新增流水失败:", err)
|
|
|
orm.Rollback()
|
|
|
- return entity.ErrorCode, "新增流水失败"
|
|
|
+ return entity.ErrorCode, "新增流水失败",0
|
|
|
}
|
|
|
if deductionNumb == 0 {
|
|
|
orm.Commit()
|
|
|
- return entity.SuccessCode, "修改结存成功"
|
|
|
+ return entity.SuccessCode, "修改结存成功",deductionNumb
|
|
|
}
|
|
|
//修改结存
|
|
|
balanceList := []entity.Balance{}
|
|
@@ -188,7 +190,7 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
if err != nil {
|
|
|
fmt.Println("结存查询失败:", err)
|
|
|
orm.Rollback()
|
|
|
- return entity.ErrorCode, "企业下的组织查询失败"
|
|
|
+ return entity.ErrorCode, "企业下的组织查询失败",0
|
|
|
}
|
|
|
for _, value := range balanceList {
|
|
|
if value.Number > deductionNumb {
|
|
@@ -204,14 +206,14 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
if err != nil || updateNumb <= 0 {
|
|
|
fmt.Println("结存修改失败:", err)
|
|
|
orm.Rollback()
|
|
|
- return entity.ErrorCode, "结存修改失败"
|
|
|
+ return entity.ErrorCode, "结存修改失败",0
|
|
|
}
|
|
|
if deductionNumb == 0 {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
orm.Commit()
|
|
|
- return entity.SuccessCode, "使用结存成功"
|
|
|
+ return entity.SuccessCode, "使用结存成功",deductionNumbs
|
|
|
}
|
|
|
|
|
|
//去重查询
|