|
@@ -100,13 +100,13 @@ func (service *BalanceService) PurchaseUserBalance(balanceData *resourcesCenter.
|
|
|
updateNumb, err := orm.Table(AccountResources).
|
|
|
Where("accountId=? and companyId=? and departmentId=? and resourceType=? and endTime=?", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, balanceData.EndTime).
|
|
|
Update(&balance)
|
|
|
- if err != nil || updateNumb > 0 {
|
|
|
+ if err != nil || updateNumb <= 0 {
|
|
|
orm.Rollback()
|
|
|
fmt.Println("结存修改失败:", err)
|
|
|
return entity.ErrorCode, "结存修改失败"
|
|
|
}
|
|
|
- orm.Rollback()
|
|
|
- return entity.ErrorCode, "结存修改失败"
|
|
|
+ orm.Commit()
|
|
|
+ return entity.SuccessCode, "结存修改成功"
|
|
|
}
|
|
|
|
|
|
//根据账户标识使用资源
|
|
@@ -116,7 +116,13 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
//去重
|
|
|
deductionNumb := detailedData.Number
|
|
|
if duplicateRemoval == 1 {
|
|
|
- url = url + "/data/dedupAndSave?personId=" + detailedData.UserId + "&infoId=" + infoId + "&accountId=" + detailedData.AccountId
|
|
|
+ dataDesc:=0
|
|
|
+ if detailedData.ResourceType == "标准字段包" {
|
|
|
+ dataDesc = 2
|
|
|
+ } else if detailedData.ResourceType == "高级字段包" {
|
|
|
+ dataDesc = 1
|
|
|
+ }
|
|
|
+ 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, "去重失败"
|
|
@@ -208,18 +214,24 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
return entity.SuccessCode, "使用结存成功"
|
|
|
}
|
|
|
|
|
|
-//根据账户标识使用资源
|
|
|
+//去重查询
|
|
|
func (service *BalanceService) FindPreview(in *resourcesCenter.PreviewReq, url string) (int64, string, int64, int64) {
|
|
|
orm := entity.Engine
|
|
|
balance := []entity.AccountBalance{}
|
|
|
//先查询余额
|
|
|
+ dataDesc:=0
|
|
|
+ if in.ResourceType == "标准字段包" {
|
|
|
+ dataDesc = 2
|
|
|
+ } else if in.ResourceType == "高级字段包" {
|
|
|
+ dataDesc = 1
|
|
|
+ }
|
|
|
err := orm.Table("account_resources").Select("number").
|
|
|
Where("accountId = ? and resourceType = ?", in.AccountId, in.ResourceType).Find(&balance)
|
|
|
if err != nil {
|
|
|
return entity.ErrorCode, "查询余额失败", 0, 0
|
|
|
}
|
|
|
var appheader = "application/x-www-form-urlencoded"
|
|
|
- param := "personId=" + in.AccountId + "&infoId=" + in.InfoId + "&accountId=" + in.AccountId
|
|
|
+ param := "dataDesc="+fmt.Sprint(dataDesc)+"&personId=" + in.AccountId + "&infoId=" + in.InfoId + "&accountId=" + in.AccountId
|
|
|
resp, status, _ := HttpPost_M(url+"/data/dedupByAcount", appheader, param, 20)
|
|
|
log.Println(resp, status)
|
|
|
if status != 200 && (resp == nil || len(resp) <= 0) {
|
|
@@ -298,7 +310,7 @@ func (service *BalanceService) UserMerge(mergeUser, mergedUser, appId string) (i
|
|
|
pType := 0
|
|
|
if value.ResourceType == "标准字段包" {
|
|
|
pType = 1
|
|
|
- } else if value.ResourceType == "标准字段包" {
|
|
|
+ } else if value.ResourceType == "高级字段包" {
|
|
|
pType = 2
|
|
|
}
|
|
|
times, _ := time.Parse("2006-01-02 15:04:05", value.EndTime+" 23:59:59")
|
|
@@ -381,7 +393,6 @@ func (service *BalanceService) UserMerge(mergeUser, mergedUser, appId string) (i
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "结存修改失败"
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
orm.Commit()
|
|
|
return entity.SuccessCode, "合并成功"
|