|
@@ -138,8 +138,12 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
}
|
|
|
sumStruct := "0"
|
|
|
if balanceData.ResourceType == "附件下载包" {
|
|
|
- now := time.Now()
|
|
|
- endTime := now.AddDate(0, int(-now.Month()+2), -now.Day()).Format("2006-01-02")
|
|
|
+ now1 := time.Now()
|
|
|
+ currentYear, currentMonth, _ := now1.Date()
|
|
|
+ currentLocation := now1.Location()
|
|
|
+ firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
|
|
|
+ lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
|
|
|
+ endTime := lastOfMonth.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().Unix()).
|
|
@@ -187,8 +191,12 @@ func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceDa
|
|
|
//修改结存
|
|
|
balanceList := []entity.Balance{}
|
|
|
if balanceData.ResourceType == "附件下载包" {
|
|
|
- now := time.Now()
|
|
|
- endTime := now.AddDate(0, int(-now.Month()+2), -now.Day()).Format("2006-01-02")
|
|
|
+ now1 := time.Now()
|
|
|
+ currentYear, currentMonth, _ := now1.Date()
|
|
|
+ currentLocation := now1.Location()
|
|
|
+ firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
|
|
|
+ lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
|
|
|
+ endTime := lastOfMonth.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().Unix()).
|
|
@@ -432,15 +440,19 @@ func (service *BalanceService) UpdateVipTime(data *resourcesCenter.VipReq) (int6
|
|
|
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")
|
|
|
+ now1 := time.Now()
|
|
|
+ currentYear, currentMonth, _ := now1.Date()
|
|
|
+ currentLocation := now1.Location()
|
|
|
+ firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
|
|
|
+ lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
|
|
|
+ endTime := lastOfMonth.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 {
|
|
|
+ if err != nil || updateNumb < 0 {
|
|
|
fmt.Println("结存修改失败:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "超级订阅时间修改失败"
|