作者 陈志颖

fix:兑换活动截止时间

... ... @@ -2,7 +2,6 @@ package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
... ...
... ... @@ -10,7 +10,7 @@ import (
type CreateExchangeCashActivityCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
Deadline time.Time `json:"deadline"` // 活动截止时间
Deadline string `json:"deadline"` // 活动截止时间
ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
CreateTime time.Time `json:"createTime"` // 创建时间
}
... ...
... ... @@ -313,11 +313,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
}
// 时间格式化
//dd, _ := time.ParseDuration("24h")
dd, _ := time.ParseDuration("24h")
//var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
var deadline = createExchangeCashActivityCommand.Deadline
//var deadline = createExchangeCashActivityCommand.Deadline
todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local)
deadline := todayZero.Add(dd)
var t1 = time.Now()
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local)
// 获取该公司所有兑换现金活动
if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
... ...
... ... @@ -317,8 +317,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤
queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6}))
queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryWealth = queryWealth.Where("e.company_id = ?", companyId)
}
... ... @@ -385,7 +385,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId)
}
//queryContributionsDecrease = queryContributionsDecrease.Where(`e.status = ?`, 1)
queryContributionsDecrease = queryContributionsDecrease.Where(`e.status = ?`, 1)
queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.record_type = ?`, 4)
if startTime, ok := queryOptions["startTime"]; ok {
queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time > ?`, startTime)
... ... @@ -405,9 +405,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))
queryContributions = queryContributions.Where(`e.status = ?`, 1)
queryContributions = queryContributions.Where("e.uid = t.uid::bigint")
queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
}
... ...
package utils
import (
"fmt"
"time"
)
func StringSliceEqualBCE(a, b []int) bool {
if len(a) != len(b) {
... ... @@ -27,4 +31,20 @@ func IsContain(items []interface{}, item string) bool {
}
}
return false
}
type LocalTime time.Time
// MarshalJSON satify the json marshal interface
func (l LocalTime) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02 15:04:05"))
return []byte(stamp), nil
}
type LocalDate time.Time
// MarshalJSON satify the json marshal interface
func (l LocalDate) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02"))
return []byte(stamp), nil
}
\ No newline at end of file
... ...