|
@@ -142,7 +142,7 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
endTime := now.AddDate(0, int(-now.Month()+2), -now.Day()).Format("2006-01-02")
|
|
|
_, err = orm.Table(AccountResources).
|
|
|
Select("sum(number) as number").
|
|
|
- Where("accountId=? and companyId=? and departmentId=? and ResourceType=? and endTime=? and vipTime>?", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, endTime, time.Now().Format("2006-01-02")).
|
|
|
+ Where("accountId=? and companyId=? and departmentId=? and ResourceType=? and endTime=? and vipTime>?", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, endTime, time.Now().Unix()).
|
|
|
Get(&sumStruct)
|
|
|
} else {
|
|
|
_, err = orm.Table(AccountResources).
|
|
@@ -191,7 +191,7 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
endTime := now.AddDate(0, int(-now.Month()+2), -now.Day()).Format("2006-01-02")
|
|
|
err = orm.Table(AccountResources).
|
|
|
Select("*").
|
|
|
- Where("accountId=? and companyId=? and departmentId=? and number>0 and ResourceType=? and endTime=? and vipTime>=? ", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, endTime, time.Now().Format("2006-01-02")).
|
|
|
+ Where("accountId=? and companyId=? and departmentId=? and number>0 and ResourceType=? and endTime=? and vipTime>? ", balanceData.AccountId, balanceData.CompanyId, balanceData.DepartmentId, balanceData.ResourceType, endTime, time.Now().Unix()).
|
|
|
OrderBy("endTime").
|
|
|
Find(&balanceList)
|
|
|
} else {
|
|
@@ -425,3 +425,26 @@ func (service *BalanceService) UserMerge(mergeUser, mergedUser, appId string) (i
|
|
|
return entity.SuccessCode, "合并成功"
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+//根据账户标识使用资源
|
|
|
+func (service *BalanceService) UpdateVipTime(data *resourcesCenter.VipReq) (int64, string) {
|
|
|
+ orm := entity.Engine.NewSession()
|
|
|
+ err := orm.Begin()
|
|
|
+ defer orm.Close()
|
|
|
+ updateNumb := int64(0)
|
|
|
+ now := time.Now()
|
|
|
+ endTime := now.AddDate(0, int(-now.Month()+2), -now.Day()).Format("2006-01-02")
|
|
|
+ dataMap := map[string]interface{}{
|
|
|
+ "vipTime": data.VipTime,
|
|
|
+ }
|
|
|
+ updateNumb, err = orm.Table(AccountResources).
|
|
|
+ Cols("vipTime").Where("endTime = ? and accountId=? and resourceType=?",endTime,data.AccountId,"附件下载包").
|
|
|
+ Update(&dataMap)
|
|
|
+ if err != nil || updateNumb <= 0 {
|
|
|
+ fmt.Println("结存修改失败:", err)
|
|
|
+ orm.Rollback()
|
|
|
+ return entity.ErrorCode, "超级订阅时间修改失败"
|
|
|
+ }
|
|
|
+ orm.Commit()
|
|
|
+ return entity.SuccessCode, "超级订阅时间修改成功"
|
|
|
+}
|