作者 陈志颖

test:导入参数测试

... ... @@ -433,28 +433,29 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if len(listIntervals) == 0 { // 未配置年榜
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
timeNow := time.Now().Local()
contributionsWealthRankingQuery.StartTime = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
} else if len(listIntervals) == 1 { // 只配置了一个年榜
currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
if currentTime.Before(listIntervals[0].IntervalStartTime) && currentTime.After(listIntervals[0].IntervalEndTime) || currentTime.Equal(listIntervals[0].IntervalStartTime) || currentTime.Equal(listIntervals[0].IntervalEndTime) { // 当前时间在榜单内
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
currentTime := time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 0, 0, 0, 0, time.Local)
if currentTime.Before(listIntervals[0].IntervalStartTime.Local()) && currentTime.After(listIntervals[0].IntervalEndTime.Local()) || currentTime.Equal(listIntervals[0].IntervalStartTime.Local()) || currentTime.Equal(listIntervals[0].IntervalEndTime.Local()) { // 当前时间在榜单内
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime.Local()
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime.Local()
} else { // 当前时间处于空档期
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 0, 0, 0, 0, time.Local)
}
} else { // 配置了多个年榜
// 判断当前时间是否在榜单里
currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
currentTime := time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 0, 0, 0, 0, time.Local)
for _, listInterval := range listIntervals {
if currentTime.Before(listInterval.IntervalStartTime) && currentTime.After(listInterval.IntervalEndTime) || currentTime.Equal(listInterval.IntervalStartTime) || currentTime.Equal(listInterval.IntervalEndTime) { // 当前时间在榜单内
contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime
contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime
if currentTime.Before(listInterval.IntervalStartTime.Local()) && currentTime.After(listInterval.IntervalEndTime.Local()) || currentTime.Equal(listInterval.IntervalStartTime.Local()) || currentTime.Equal(listInterval.IntervalEndTime.Local()) { // 当前时间在榜单内
contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime.Local()
contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime.Local()
break
} else { // 当前时间处于空档期
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 0, 0, 0, 0, time.Local)
break
}
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ImportExchangeCashListCommand struct {
Where map[string]interface{} `json:"where"`
}
func (importExchangeCashListCommand *ImportExchangeCashListCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(importExchangeCashListCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
... ... @@ -407,7 +407,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
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("e.uid = t.uid::bigint")
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
}
... ...
... ... @@ -6,7 +6,6 @@ import (
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/astaxie/beego"
"github.com/linmadan/egglib-go/web/beego/utils"
utils_tool "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
... ... @@ -395,9 +394,9 @@ func (controller *SuMoneyController) ExchangeCashListRanking() {
// 导入兑换素币清单
func (controller *SuMoneyController) ImportExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
whereStr := controller.GetString("where")
where, err := utils_tool.JsonToMap(whereStr)
importExchangeCashListCommand := &command.ImportExchangeCashListCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), importExchangeCashListCommand)
//fmt.Printf("命令:%+v\n", importExchangeCashListCommand)
file, h, _ := controller.GetFile("file")
// 错误信息返回
... ... @@ -478,8 +477,9 @@ func (controller *SuMoneyController) ImportExchangeList () {
//fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row))
if i > 2 && len(row) > 1 {
// 创建兑换清单命令
createExchangeCashPersonCommand.ExchangeCashActivityId ,err = strconv.ParseInt(where["activityId"], 10, 64)
createExchangeCashPersonCommand.Operator, err = strconv.ParseInt(where["uid"], 10, 64)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
createExchangeCashPersonCommand.ExchangeCashActivityId ,err = strconv.ParseInt(importExchangeCashListCommand.Where["activityId"].(string), 10, 64)
createExchangeCashPersonCommand.Operator = importExchangeCashListCommand.Where["uid"].(int64)
createExchangeCashPersonCommand.PersonName = row[0]
createExchangeCashPersonCommand.PersonAccount = row[1]
r2, _ := strconv.ParseFloat(row[2], 64)
... ...