作者 陈志颖

fix:修改活动截止日期格式

@@ -14,7 +14,6 @@ func main() { @@ -14,7 +14,6 @@ func main() {
14 for { 14 for {
15 now := time.Now() 15 now := time.Now()
16 next := now.Add(time.Hour * 24) 16 next := now.Add(time.Hour * 24)
17 - //next := now.Add(time.Minute * 5)  
18 nextZero := time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location()) 17 nextZero := time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location())
19 dispatchTicker := time.NewTimer(nextZero.Sub(now)) 18 dispatchTicker := time.NewTimer(nextZero.Sub(now))
20 <-dispatchTicker.C 19 <-dispatchTicker.C
@@ -489,9 +489,25 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -489,9 +489,25 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
489 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 489 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
490 } 490 }
491 491
  492 + var activitiesWithTs []interface{}
  493 + for _, activity := range activities {
  494 + activityWithTs := map[string]interface{} {
  495 + "activityId": activity.ActivityId,
  496 + "exchangeActivityName": activity.ExchangeActivityName,
  497 + "companyId": activity.CompanyId,
  498 + "exchangedCash": activity.ExchangedCash,
  499 + "exchangedSuMoney": activity.ExchangedSuMoney,
  500 + "deadline": activity.Deadline.Unix(),
  501 + "countDown": activity.CountDown,
  502 + "rate": activity.Rate,
  503 + "createTime": "2020-11-13T09:32:45.259856Z",
  504 + }
  505 + activitiesWithTs = append(activitiesWithTs, activityWithTs)
  506 + }
  507 +
492 return map[string]interface{}{ 508 return map[string]interface{}{
493 "count": count, 509 "count": count,
494 - "activities": activities, 510 + "activities": activitiesWithTs,
495 }, nil 511 }, nil
496 } 512 }
497 } 513 }
@@ -1652,6 +1668,10 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang @@ -1652,6 +1668,10 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang
1652 exchangeCashPersonListRepository = value 1668 exchangeCashPersonListRepository = value
1653 } 1669 }
1654 1670
  1671 + if len(exportExchangeCashListCommand.IDs) == 0 {
  1672 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
  1673 + }
  1674 +
1655 if _, people, err := exchangeCashPersonListRepository.FindById(tool_funs.SimpleStructToMap(exportExchangeCashListCommand)); err != nil { 1675 if _, people, err := exchangeCashPersonListRepository.FindById(tool_funs.SimpleStructToMap(exportExchangeCashListCommand)); err != nil {
1656 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1676 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1657 } else { 1677 } else {
@@ -238,6 +238,10 @@ func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuM @@ -238,6 +238,10 @@ func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuM
238 transactionContext.RollbackTransaction() 238 transactionContext.RollbackTransaction()
239 }() 239 }()
240 240
  241 + if len(exportSuMoneyTransactionRecordCommand.IDs) == 0 {
  242 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
  243 + }
  244 +
241 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository 245 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
242 if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{ 246 if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
243 "transactionContext": transactionContext, 247 "transactionContext": transactionContext,
@@ -77,7 +77,7 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map @@ -77,7 +77,7 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map
77 }, nil 77 }, nil
78 } 78 }
79 79
80 -// 返回兑换清单榜单 80 +// 返回兑换活动清单榜单
81 func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) { 81 func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
82 var retPeople []struct { 82 var retPeople []struct {
83 Uid int 83 Uid int
@@ -349,14 +349,14 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -349,14 +349,14 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
349 } 349 }
350 tx := dao.transactionContext.PgTx 350 tx := dao.transactionContext.PgTx
351 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 351 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
352 -  
353 // 财富值榜单 352 // 财富值榜单
354 queryWealth := tx.Model(suMoneyTransactionRecordModel) 353 queryWealth := tx.Model(suMoneyTransactionRecordModel)
355 queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint") 354 queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
356 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 355 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
357 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 356 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
358 queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money") 357 queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
359 - queryWealth = queryWealth.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC, su_money_transaction_record.create_time) AS ranking") 358 + //queryWealth = queryWealth.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC, su_money_transaction_record.create_time) AS ranking")
  359 + queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
360 queryWealth = queryWealth.Where(`e.status = ?`, 1) 360 queryWealth = queryWealth.Where(`e.status = ?`, 1)
361 queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})) 361 queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
362 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 362 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
@@ -368,8 +368,12 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -368,8 +368,12 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
368 if endTime, ok := queryOptions["endTime"]; ok { 368 if endTime, ok := queryOptions["endTime"]; ok {
369 queryWealth = queryWealth.Where(`su_money_transaction_record.create_time < ?`, endTime) 369 queryWealth = queryWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
370 } 370 }
371 - queryWealth = queryWealth.Group("su_money_transaction_record.employee")  
372 - queryWealth = queryWealth.Group("su_money_transaction_record.create_time") 371 + //queryWealth = queryWealth.Group("su_money_transaction_record.employee")
  372 + //queryWealth = queryWealth.Group("su_money_transaction_record.employee #>> '{uid}'")
  373 +
  374 + queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
  375 + //queryWealth = queryWealth.Group("su_money_transaction_record.create_time")
  376 + //queryWealth = queryWealth.Group(`su_money_transaction_record->'employee'->>'employeeName'`)
373 if offset, ok := queryOptions["offset"]; ok { 377 if offset, ok := queryOptions["offset"]; ok {
374 offset := offset.(int) 378 offset := offset.(int)
375 if offset > -1 { 379 if offset > -1 {
@@ -396,7 +400,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -396,7 +400,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
396 queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 400 queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
397 queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 401 queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
398 queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money") 402 queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
399 - queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC, su_money_transaction_record.create_time) AS ranking") 403 + queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
400 queryEmployeeWealth = queryEmployeeWealth.Where(`e.status = ?`, 1) 404 queryEmployeeWealth = queryEmployeeWealth.Where(`e.status = ?`, 1)
401 queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})) 405 queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
402 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 406 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
@@ -408,8 +412,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -408,8 +412,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
408 if endTime, ok := queryOptions["endTime"]; ok { 412 if endTime, ok := queryOptions["endTime"]; ok {
409 queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.create_time < ?`, endTime) 413 queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
410 } 414 }
411 - queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.employee")  
412 - queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.create_time") 415 + //queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.employee")
  416 + //queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.employee #>> '{uid}' ")
  417 + //queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.create_time")
  418 + queryEmployeeWealth = queryEmployeeWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
413 if uid, ok := queryOptions["uid"]; ok { 419 if uid, ok := queryOptions["uid"]; ok {
414 queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid) 420 queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid)
415 } 421 }
@@ -423,13 +429,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -423,13 +429,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
423 retCurrentEmployeeWealth = retEmployeeWealth[0] 429 retCurrentEmployeeWealth = retEmployeeWealth[0]
424 } 430 }
425 431
426 - // 贡献值榜单 432 + // 贡献值榜单-减少的贡献致富
427 queryContributionsDecrease := tx.Model(suMoneyTransactionRecordModel) 433 queryContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
428 queryContributionsDecrease = queryContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint") 434 queryContributionsDecrease = queryContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
429 queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 435 queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
430 queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 436 queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
431 queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions_decrease") 437 queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions_decrease")
432 - queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC, su_money_transaction_record.create_time) AS ranking") 438 + queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
433 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 439 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
434 queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId) 440 queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId)
435 } 441 }
@@ -441,8 +447,11 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -441,8 +447,11 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
441 if endTime, ok := queryOptions["endTime"]; ok { 447 if endTime, ok := queryOptions["endTime"]; ok {
442 queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime) 448 queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
443 } 449 }
444 - contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee").Group("su_money_transaction_record.create_time") 450 + //contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee").Group("su_money_transaction_record.create_time")
  451 + //contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee #>> '{uid}'").Group("su_money_transaction_record.create_time")
  452 + contributionsDecrease := queryContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
445 453
  454 + // 贡献值排行榜
446 queryContributions := tx.Model() 455 queryContributions := tx.Model()
447 queryContributions = queryContributions.With("t", contributionsDecrease) 456 queryContributions = queryContributions.With("t", contributionsDecrease)
448 queryContributions = queryContributions.Table("t") 457 queryContributions = queryContributions.Table("t")
@@ -451,7 +460,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -451,7 +460,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
451 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid") 460 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid")
452 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name") 461 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
453 queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`) 462 queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
454 - queryContributions = queryContributions.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC,su_money_transaction_records.create_time) AS ranking") 463 + queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
455 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 464 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
456 queryContributions = queryContributions.Where("e.company_id = ?", companyId) 465 queryContributions = queryContributions.Where("e.company_id = ?", companyId)
457 } 466 }
@@ -463,9 +472,11 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -463,9 +472,11 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
463 if endTime, ok := queryOptions["endTime"]; ok { 472 if endTime, ok := queryOptions["endTime"]; ok {
464 queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime) 473 queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
465 } 474 }
466 - queryContributions = queryContributions.Group("su_money_transaction_records.employee")  
467 - queryContributions = queryContributions.Group("t.employee_contributions_decrease")  
468 - queryContributions = queryContributions.Group("su_money_transaction_records.create_time") 475 + //queryContributions = queryContributions.Group("su_money_transaction_records.employee")
  476 + //queryContributions = queryContributions.Group("su_money_transaction_records.employee #>> '{uid}'")
  477 + //queryContributions = queryContributions.Group("t.employee_contributions_decrease")
  478 + //queryContributions = queryContributions.Group("su_money_transaction_records.create_time")
  479 + queryContributions = queryContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
469 if offset, ok := queryOptions["offset"]; ok { 480 if offset, ok := queryOptions["offset"]; ok {
470 offset := offset.(int) 481 offset := offset.(int)
471 if offset > -1 { 482 if offset > -1 {
@@ -486,13 +497,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -486,13 +497,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
486 return nil, err 497 return nil, err
487 } 498 }
488 499
489 - // 当前员工贡献值排名 500 + // 当前员工贡献值-减少的贡献值排名
490 queryEmployeeContributionsDecrease := tx.Model(suMoneyTransactionRecordModel) 501 queryEmployeeContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
491 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint") 502 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
492 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 503 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
493 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 504 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
494 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions_decrease") 505 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions_decrease")
495 - queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking") 506 + queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
496 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 507 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
497 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where("e.company_id = ?", companyId) 508 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where("e.company_id = ?", companyId)
498 } 509 }
@@ -504,8 +515,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -504,8 +515,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
504 if endTime, ok := queryOptions["endTime"]; ok { 515 if endTime, ok := queryOptions["endTime"]; ok {
505 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime) 516 queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
506 } 517 }
507 - employeeContributionsDecrease := queryEmployeeContributionsDecrease.Group("su_money_transaction_record.employee") 518 + //employeeContributionsDecrease := queryEmployeeContributionsDecrease.Group("su_money_transaction_record.employee")
  519 + employeeContributionsDecrease := queryEmployeeContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
508 520
  521 + // 当前员工贡献值排名
509 queryEmployeeContributions := tx.Model() 522 queryEmployeeContributions := tx.Model()
510 queryEmployeeContributions = queryEmployeeContributions.With("t", employeeContributionsDecrease) 523 queryEmployeeContributions = queryEmployeeContributions.With("t", employeeContributionsDecrease)
511 queryEmployeeContributions = queryEmployeeContributions.Table("t") 524 queryEmployeeContributions = queryEmployeeContributions.Table("t")
@@ -514,7 +527,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -514,7 +527,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
514 queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid") 527 queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid")
515 queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name") 528 queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
516 queryEmployeeContributions = queryEmployeeContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`) 529 queryEmployeeContributions = queryEmployeeContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
517 - queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking") 530 + queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
518 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 531 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
519 queryEmployeeContributions = queryContributions.Where("e.company_id = ?", companyId) 532 queryEmployeeContributions = queryContributions.Where("e.company_id = ?", companyId)
520 } 533 }
@@ -529,8 +542,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -529,8 +542,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
529 if uid, ok := queryOptions["uid"]; ok { 542 if uid, ok := queryOptions["uid"]; ok {
530 queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.employee @> '{"uid":?}'`, uid) 543 queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.employee @> '{"uid":?}'`, uid)
531 } 544 }
532 - queryEmployeeContributions = queryEmployeeContributions.Group("su_money_transaction_records.employee")  
533 - queryEmployeeContributions = queryEmployeeContributions.Group("t.employee_contributions_decrease") 545 + //queryEmployeeContributions = queryEmployeeContributions.Group("su_money_transaction_records.employee")
  546 + queryEmployeeContributions = queryEmployeeContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
  547 + //queryEmployeeContributions = queryEmployeeContributions.Group("t.employee_contributions_decrease")
534 if err := queryEmployeeContributions.Order("employees_contributions DESC").Select(&retEmployeeContributions); err != nil { 548 if err := queryEmployeeContributions.Order("employees_contributions DESC").Select(&retEmployeeContributions); err != nil {
535 return nil, err 549 return nil, err
536 } 550 }
@@ -18,6 +18,7 @@ type SuMoneyController struct { @@ -18,6 +18,7 @@ type SuMoneyController struct {
18 beego.Controller 18 beego.Controller
19 } 19 }
20 20
  21 +// 操作素币
21 func (controller *SuMoneyController) OperationSuMoney() { 22 func (controller *SuMoneyController) OperationSuMoney() {
22 suMoneyService := service.NewSuMoneyService(nil) 23 suMoneyService := service.NewSuMoneyService(nil)
23 operationSuMoneyCommand := &command.OperationSuMoneyCommand{} 24 operationSuMoneyCommand := &command.OperationSuMoneyCommand{}
@@ -33,6 +34,7 @@ func (controller *SuMoneyController) OperationSuMoney() { @@ -33,6 +34,7 @@ func (controller *SuMoneyController) OperationSuMoney() {
33 controller.ServeJSON() 34 controller.ServeJSON()
34 } 35 }
35 36
  37 +// 获取素币事务记录
36 func (controller *SuMoneyController) GetSuMoneyTransactionRecord() { 38 func (controller *SuMoneyController) GetSuMoneyTransactionRecord() {
37 suMoneyService := service.NewSuMoneyService(nil) 39 suMoneyService := service.NewSuMoneyService(nil)
38 getSuMoneyTransactionRecordQuery := &query.GetSuMoneyTransactionRecordQuery{} 40 getSuMoneyTransactionRecordQuery := &query.GetSuMoneyTransactionRecordQuery{}
@@ -49,6 +51,7 @@ func (controller *SuMoneyController) GetSuMoneyTransactionRecord() { @@ -49,6 +51,7 @@ func (controller *SuMoneyController) GetSuMoneyTransactionRecord() {
49 controller.ServeJSON() 51 controller.ServeJSON()
50 } 52 }
51 53
  54 +// 兑换素币
52 func (controller *SuMoneyController) ExchangeSuMoney() { 55 func (controller *SuMoneyController) ExchangeSuMoney() {
53 suMoneyService := service.NewSuMoneyService(nil) 56 suMoneyService := service.NewSuMoneyService(nil)
54 exchangeSuMoneyCommand := &command.ExchangeSuMoneyCommand{} 57 exchangeSuMoneyCommand := &command.ExchangeSuMoneyCommand{}
@@ -64,6 +67,7 @@ func (controller *SuMoneyController) ExchangeSuMoney() { @@ -64,6 +67,7 @@ func (controller *SuMoneyController) ExchangeSuMoney() {
64 controller.ServeJSON() 67 controller.ServeJSON()
65 } 68 }
66 69
  70 +// 搜索素币事务
67 func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() { 71 func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() {
68 suMoneyService := service.NewSuMoneyService(nil) 72 suMoneyService := service.NewSuMoneyService(nil)
69 searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{} 73 searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{}
@@ -150,12 +154,12 @@ func (controller *SuMoneyController) GetCashPool() { @@ -150,12 +154,12 @@ func (controller *SuMoneyController) GetCashPool() {
150 controller.ServeJSON() 154 controller.ServeJSON()
151 } 155 }
152 156
153 -// 搜索返回兑换活动列表  
154 -func (controller *SuMoneyController) SearchExchangeActivities () { 157 +// 新增兑换活动
  158 +func (controller *SuMoneyController) CreateExchangeActivities () {
155 cashPoolService := service.NewCashPoolService(nil) 159 cashPoolService := service.NewCashPoolService(nil)
156 - searchExchangeCashActivityCommand := &command.SearchExchangeCashActivityCommand{}  
157 - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchExchangeCashActivityCommand)  
158 - data, err := cashPoolService.SearchExchangeCashActivity(searchExchangeCashActivityCommand) 160 + createExchangeCashActivityCommand := &command.CreateExchangeCashActivityCommand{}
  161 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashActivityCommand)
  162 + data, err := cashPoolService.CreateExchangeCashActivity(createExchangeCashActivityCommand)
159 var response utils.JsonResponse 163 var response utils.JsonResponse
160 if err != nil { 164 if err != nil {
161 response = utils.ResponseError(controller.Ctx, err) 165 response = utils.ResponseError(controller.Ctx, err)
@@ -189,14 +193,12 @@ func (controller *SuMoneyController) ListExchangeActivities () { @@ -189,14 +193,12 @@ func (controller *SuMoneyController) ListExchangeActivities () {
189 controller.ServeJSON() 193 controller.ServeJSON()
190 } 194 }
191 195
192 -// 更新兑换活动信息  
193 -func (controller *SuMoneyController) UpdateExchangeActivities () { 196 +// 搜索返回兑换活动列表
  197 +func (controller *SuMoneyController) SearchExchangeActivities () {
194 cashPoolService := service.NewCashPoolService(nil) 198 cashPoolService := service.NewCashPoolService(nil)
195 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{}  
196 - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashActivityCommand)  
197 - activityId, _ := controller.GetInt64(":activityId")  
198 - updateExchangeCashActivityCommand.ExchangeCashActivityId = activityId  
199 - data, err := cashPoolService.UpdateExchangeCashActivity(updateExchangeCashActivityCommand) 199 + searchExchangeCashActivityCommand := &command.SearchExchangeCashActivityCommand{}
  200 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchExchangeCashActivityCommand)
  201 + data, err := cashPoolService.SearchExchangeCashActivity(searchExchangeCashActivityCommand)
200 var response utils.JsonResponse 202 var response utils.JsonResponse
201 if err != nil { 203 if err != nil {
202 response = utils.ResponseError(controller.Ctx, err) 204 response = utils.ResponseError(controller.Ctx, err)
@@ -207,12 +209,13 @@ func (controller *SuMoneyController) UpdateExchangeActivities () { @@ -207,12 +209,13 @@ func (controller *SuMoneyController) UpdateExchangeActivities () {
207 controller.ServeJSON() 209 controller.ServeJSON()
208 } 210 }
209 211
210 -// 新增兑换活动  
211 -func (controller *SuMoneyController) CreateExchangeActivities () { 212 +// 返回兑换现金活动
  213 +func (controller *SuMoneyController) GetExchangeCashActivity () {
212 cashPoolService := service.NewCashPoolService(nil) 214 cashPoolService := service.NewCashPoolService(nil)
213 - createExchangeCashActivityCommand := &command.CreateExchangeCashActivityCommand{}  
214 - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashActivityCommand)  
215 - data, err := cashPoolService.CreateExchangeCashActivity(createExchangeCashActivityCommand) 215 + getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{}
  216 + activityId, _ := controller.GetInt64(":activityId")
  217 + getExchangeCashActivityQuery.ExchangeCashActivityId = activityId
  218 + data, err := cashPoolService.GetExchangeCashActivity(getExchangeCashActivityQuery)
216 var response utils.JsonResponse 219 var response utils.JsonResponse
217 if err != nil { 220 if err != nil {
218 response = utils.ResponseError(controller.Ctx, err) 221 response = utils.ResponseError(controller.Ctx, err)
@@ -223,14 +226,14 @@ func (controller *SuMoneyController) CreateExchangeActivities () { @@ -223,14 +226,14 @@ func (controller *SuMoneyController) CreateExchangeActivities () {
223 controller.ServeJSON() 226 controller.ServeJSON()
224 } 227 }
225 228
226 -// 移除兑换活动  
227 -func (controller *SuMoneyController) RemoveExchangeActivities () { 229 +// 更新兑换活动信息
  230 +func (controller *SuMoneyController) UpdateExchangeActivities () {
228 cashPoolService := service.NewCashPoolService(nil) 231 cashPoolService := service.NewCashPoolService(nil)
229 - removeExchangeCashActivityCommand := &command.RemoveExchangeCashActivityCommand{} 232 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{}
  233 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashActivityCommand)
230 activityId, _ := controller.GetInt64(":activityId") 234 activityId, _ := controller.GetInt64(":activityId")
231 - beego.Info(activityId)  
232 - removeExchangeCashActivityCommand.ActivityId = activityId  
233 - data, err := cashPoolService.RemoveExchangeCashActivity(removeExchangeCashActivityCommand) 235 + updateExchangeCashActivityCommand.ExchangeCashActivityId = activityId
  236 + data, err := cashPoolService.UpdateExchangeCashActivity(updateExchangeCashActivityCommand)
234 var response utils.JsonResponse 237 var response utils.JsonResponse
235 if err != nil { 238 if err != nil {
236 response = utils.ResponseError(controller.Ctx, err) 239 response = utils.ResponseError(controller.Ctx, err)
@@ -241,13 +244,14 @@ func (controller *SuMoneyController) RemoveExchangeActivities () { @@ -241,13 +244,14 @@ func (controller *SuMoneyController) RemoveExchangeActivities () {
241 controller.ServeJSON() 244 controller.ServeJSON()
242 } 245 }
243 246
244 -// 返回兑换现金活动  
245 -func (controller *SuMoneyController) GetExchangeCashActivity () { 247 +// 移除兑换活动
  248 +func (controller *SuMoneyController) RemoveExchangeActivities () {
246 cashPoolService := service.NewCashPoolService(nil) 249 cashPoolService := service.NewCashPoolService(nil)
247 - getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{} 250 + removeExchangeCashActivityCommand := &command.RemoveExchangeCashActivityCommand{}
248 activityId, _ := controller.GetInt64(":activityId") 251 activityId, _ := controller.GetInt64(":activityId")
249 - getExchangeCashActivityQuery.ExchangeCashActivityId = activityId  
250 - data, err := cashPoolService.GetExchangeCashActivity(getExchangeCashActivityQuery) 252 + beego.Info(activityId)
  253 + removeExchangeCashActivityCommand.ActivityId = activityId
  254 + data, err := cashPoolService.RemoveExchangeCashActivity(removeExchangeCashActivityCommand)
251 var response utils.JsonResponse 255 var response utils.JsonResponse
252 if err != nil { 256 if err != nil {
253 response = utils.ResponseError(controller.Ctx, err) 257 response = utils.ResponseError(controller.Ctx, err)
@@ -353,6 +357,39 @@ func (controller *SuMoneyController) GetExchangeCashPerson () { @@ -353,6 +357,39 @@ func (controller *SuMoneyController) GetExchangeCashPerson () {
353 controller.ServeJSON() 357 controller.ServeJSON()
354 } 358 }
355 359
  360 +// 返回兑换活动截止时间列表
  361 +func (controller *SuMoneyController) ListDeadline() {
  362 + cashPoolService := service.NewCashPoolService(nil)
  363 + listExchangeCashActivityDeadlineQuery := &query.ListExchangeCashActivityDeadlineQuery{}
  364 + companyId, _ := controller.GetInt64("companyId")
  365 + listExchangeCashActivityDeadlineQuery.CompanyId = companyId
  366 + data, err := cashPoolService.ListExchangeCashActivityDeadline(listExchangeCashActivityDeadlineQuery)
  367 + var response utils.JsonResponse
  368 + if err != nil {
  369 + response = utils.ResponseError(controller.Ctx, err)
  370 + } else {
  371 + response = utils.ResponseData(controller.Ctx, data)
  372 + }
  373 + controller.Data["json"] = response
  374 + controller.ServeJSON()
  375 +}
  376 +
  377 +// 返回兑换素币清单排行榜
  378 +func (controller *SuMoneyController) ExchangeCashListRanking() {
  379 + cashPoolService := service.NewCashPoolService(nil)
  380 + exchangeListRankingQuery := &query.ExchangeListRankingQuery{}
  381 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exchangeListRankingQuery)
  382 + data, err := cashPoolService.ExchangeListRanking(exchangeListRankingQuery)
  383 + var response utils.JsonResponse
  384 + if err != nil {
  385 + response = utils.ResponseError(controller.Ctx, err)
  386 + } else {
  387 + response = utils.ResponseData(controller.Ctx, data)
  388 + }
  389 + controller.Data["json"] = response
  390 + controller.ServeJSON()
  391 +}
  392 +
356 // 导入兑换素币清单 393 // 导入兑换素币清单
357 func (controller *SuMoneyController) ImportExchangeList () { 394 func (controller *SuMoneyController) ImportExchangeList () {
358 cashPoolService := service.NewCashPoolService(nil) 395 cashPoolService := service.NewCashPoolService(nil)
@@ -412,40 +449,6 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -412,40 +449,6 @@ func (controller *SuMoneyController) ImportExchangeList () {
412 controller.ServeJSON() 449 controller.ServeJSON()
413 } 450 }
414 451
415 -// 返回兑换活动截止时间列表  
416 -func (controller *SuMoneyController) ListDeadline() {  
417 - cashPoolService := service.NewCashPoolService(nil)  
418 - listExchangeCashActivityDeadlineQuery := &query.ListExchangeCashActivityDeadlineQuery{}  
419 - companyId, _ := controller.GetInt64("companyId")  
420 - listExchangeCashActivityDeadlineQuery.CompanyId = companyId  
421 - data, err := cashPoolService.ListExchangeCashActivityDeadline(listExchangeCashActivityDeadlineQuery)  
422 - var response utils.JsonResponse  
423 - if err != nil {  
424 - response = utils.ResponseError(controller.Ctx, err)  
425 - } else {  
426 - response = utils.ResponseData(controller.Ctx, data)  
427 - }  
428 - controller.Data["json"] = response  
429 - controller.ServeJSON()  
430 -}  
431 -  
432 -// 返回兑换素币清单排行榜  
433 -func (controller *SuMoneyController) ExchangeCashListRanking() {  
434 - cashPoolService := service.NewCashPoolService(nil)  
435 - exchangeListRankingQuery := &query.ExchangeListRankingQuery{}  
436 - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exchangeListRankingQuery)  
437 - data, err := cashPoolService.ExchangeListRanking(exchangeListRankingQuery)  
438 - var response utils.JsonResponse  
439 - if err != nil {  
440 - response = utils.ResponseError(controller.Ctx, err)  
441 - } else {  
442 - response = utils.ResponseData(controller.Ctx, data)  
443 - }  
444 - controller.Data["json"] = response  
445 - controller.ServeJSON()  
446 -}  
447 -  
448 -  
449 // 导出素币兑换清单,选择导出(ids),增加导出失败信息 452 // 导出素币兑换清单,选择导出(ids),增加导出失败信息
450 func (controller *SuMoneyController) ExportExchangeList() { 453 func (controller *SuMoneyController) ExportExchangeList() {
451 cashPoolService := service.NewCashPoolService(nil) 454 cashPoolService := service.NewCashPoolService(nil)