作者 陈志颖

fix:兑换活动截止时间

@@ -2,7 +2,6 @@ package command @@ -2,7 +2,6 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 -  
6 "github.com/astaxie/beego/validation" 5 "github.com/astaxie/beego/validation"
7 ) 6 )
8 7
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 type CreateExchangeCashActivityCommand struct { 10 type CreateExchangeCashActivityCommand struct {
11 CompanyId int64 `json:"companyId" valid:"Required"` // 公司id 11 CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
12 ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 12 ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
13 - Deadline time.Time `json:"deadline"` // 活动截止时间 13 + Deadline string `json:"deadline"` // 活动截止时间
14 ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率 14 ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
15 CreateTime time.Time `json:"createTime"` // 创建时间 15 CreateTime time.Time `json:"createTime"` // 创建时间
16 } 16 }
@@ -313,11 +313,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -313,11 +313,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
313 } 313 }
314 314
315 // 时间格式化 315 // 时间格式化
316 - //dd, _ := time.ParseDuration("24h") 316 + dd, _ := time.ParseDuration("24h")
317 //var deadline = createExchangeCashActivityCommand.Deadline.Add(dd) 317 //var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
318 - var deadline = createExchangeCashActivityCommand.Deadline 318 + //var deadline = createExchangeCashActivityCommand.Deadline
  319 + todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local)
  320 + deadline := todayZero.Add(dd)
319 var t1 = time.Now() 321 var t1 = time.Now()
320 - var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local) 322 + var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local)
321 323
322 // 获取该公司所有兑换现金活动 324 // 获取该公司所有兑换现金活动
323 if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{ 325 if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
@@ -317,8 +317,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -317,8 +317,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
317 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 317 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
318 queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money") 318 queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
319 queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking") 319 queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
320 - queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤  
321 queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6})) 320 queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6}))
  321 + queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤
322 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 322 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
323 queryWealth = queryWealth.Where("e.company_id = ?", companyId) 323 queryWealth = queryWealth.Where("e.company_id = ?", companyId)
324 } 324 }
@@ -385,7 +385,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -385,7 +385,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
385 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 385 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
386 queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId) 386 queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId)
387 } 387 }
388 - //queryContributionsDecrease = queryContributionsDecrease.Where(`e.status = ?`, 1) 388 + queryContributionsDecrease = queryContributionsDecrease.Where(`e.status = ?`, 1)
389 queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.record_type = ?`, 4) 389 queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.record_type = ?`, 4)
390 if startTime, ok := queryOptions["startTime"]; ok { 390 if startTime, ok := queryOptions["startTime"]; ok {
391 queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time > ?`, startTime) 391 queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time > ?`, startTime)
@@ -405,9 +405,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -405,9 +405,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
405 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name") 405 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
406 queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`) 406 queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
407 queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking") 407 queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
  408 + queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))
408 queryContributions = queryContributions.Where(`e.status = ?`, 1) 409 queryContributions = queryContributions.Where(`e.status = ?`, 1)
409 queryContributions = queryContributions.Where("e.uid = t.uid::bigint") 410 queryContributions = queryContributions.Where("e.uid = t.uid::bigint")
410 - queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))  
411 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 411 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
412 queryContributions = queryContributions.Where("e.company_id = ?", companyId) 412 queryContributions = queryContributions.Where("e.company_id = ?", companyId)
413 } 413 }
1 package utils 1 package utils
2 2
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +)
3 7
4 func StringSliceEqualBCE(a, b []int) bool { 8 func StringSliceEqualBCE(a, b []int) bool {
5 if len(a) != len(b) { 9 if len(a) != len(b) {
@@ -28,3 +32,19 @@ func IsContain(items []interface{}, item string) bool { @@ -28,3 +32,19 @@ func IsContain(items []interface{}, item string) bool {
28 } 32 }
29 return false 33 return false
30 } 34 }
  35 +
  36 +type LocalTime time.Time
  37 +
  38 +// MarshalJSON satify the json marshal interface
  39 +func (l LocalTime) MarshalJSON() ([]byte, error) {
  40 + stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02 15:04:05"))
  41 + return []byte(stamp), nil
  42 +}
  43 +
  44 +type LocalDate time.Time
  45 +
  46 +// MarshalJSON satify the json marshal interface
  47 +func (l LocalDate) MarshalJSON() ([]byte, error) {
  48 + stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02"))
  49 + return []byte(stamp), nil
  50 +}