作者 陈志颖

test:测试服务时间差

@@ -104,7 +104,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -104,7 +104,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
104 UnExchangeSuMoney: systemUnExchangeSuMoney, 104 UnExchangeSuMoney: systemUnExchangeSuMoney,
105 LastRate: 0, 105 LastRate: 0,
106 Rate: 0, 106 Rate: 0,
107 - CreateTime: time.Now(), 107 + CreateTime: time.Now().Local(),
108 } 108 }
109 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil { 109 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
110 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 110 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -137,7 +137,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -137,7 +137,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
137 UnExchangeSuMoney: systemUnExchangeSuMoney, 137 UnExchangeSuMoney: systemUnExchangeSuMoney,
138 Rate: newRate, 138 Rate: newRate,
139 LastRate: cashPools[0].LastRate, 139 LastRate: cashPools[0].LastRate,
140 - CreateTime: time.Now(), 140 + CreateTime: time.Now().Local(),
141 } 141 }
142 // 保存现金池更新 142 // 保存现金池更新
143 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil { 143 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
@@ -267,7 +267,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -267,7 +267,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
267 "unExchangeSuMoney": systemUnExchangeSuMoney, 267 "unExchangeSuMoney": systemUnExchangeSuMoney,
268 "rate": 0, // 平均兑换汇率 268 "rate": 0, // 平均兑换汇率
269 "lastRate": 0, // 上期活动兑换汇率 269 "lastRate": 0, // 上期活动兑换汇率
270 - "createTime": time.Now(), 270 + "createTime": time.Now().Local(),
271 }, nil 271 }, nil
272 } else { 272 } else {
273 cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64) 273 cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
@@ -323,7 +323,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -323,7 +323,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
323 //var deadline = createExchangeCashActivityCommand.Deadline 323 //var deadline = createExchangeCashActivityCommand.Deadline
324 todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local) 324 todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local)
325 deadline := todayZero.Add(dd) 325 deadline := todayZero.Add(dd)
326 - var t1 = time.Now() 326 + var t1 = time.Now().Local()
327 var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local) 327 var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local)
328 328
329 // 获取该公司所有兑换现金活动 329 // 获取该公司所有兑换现金活动
@@ -333,7 +333,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -333,7 +333,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
333 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 333 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
334 } else { 334 } else {
335 for _, activity := range activities { 335 for _, activity := range activities {
336 - if t2.Format("2006-01-02") == activity.Deadline.UTC().Format("2006-01-02") { 336 + //if t2.Format("2006-01-02") == activity.Deadline.UTC().Format("2006-01-02") {
  337 + if t2.Format("2006-01-02") == activity.Deadline.Format("2006-01-02") {
337 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合") 338 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
338 } 339 }
339 } 340 }
@@ -348,7 +349,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -348,7 +349,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
348 Deadline: t2, 349 Deadline: t2,
349 CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时 350 CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
350 Rate: createExchangeCashActivityCommand.ExchangeRate, 351 Rate: createExchangeCashActivityCommand.ExchangeRate,
351 - CreateTime: time.Now(), 352 + CreateTime: time.Now().Local(),
352 } 353 }
353 354
354 // 倒计时结束判断 355 // 倒计时结束判断
@@ -406,7 +407,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc @@ -406,7 +407,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc
406 // 提取兑换现金活动截止时间 407 // 提取兑换现金活动截止时间
407 var deadlines []interface{} 408 var deadlines []interface{}
408 for _, activity := range activities { 409 for _, activity := range activities {
409 - tmpTime := activity.Deadline.UTC().Format("2006-01-02") 410 + //tmpTime := activity.Deadline.UTC().Format("2006-01-02")
  411 + tmpTime := activity.Deadline.Format("2006-01-02")
410 if !utils.IsContain(deadlines, tmpTime) { 412 if !utils.IsContain(deadlines, tmpTime) {
411 deadlines = append(deadlines, tmpTime) 413 deadlines = append(deadlines, tmpTime)
412 } 414 }
@@ -451,7 +453,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -451,7 +453,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
451 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 453 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
452 } else { 454 } else {
453 for _, activity := range activities { 455 for _, activity := range activities {
454 - var t1 = time.Now() 456 + var t1 = time.Now().Local()
455 var t2 = activity.Deadline 457 var t2 = activity.Deadline
456 458
457 // 更新兑换活动倒计时命令 459 // 更新兑换活动倒计时命令
@@ -547,7 +549,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -547,7 +549,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
547 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 549 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
548 } else { 550 } else {
549 for _, activity := range activities { 551 for _, activity := range activities {
550 - var t1 = time.Now() 552 + var t1 = time.Now().Local()
551 var t2 = activity.Deadline 553 var t2 = activity.Deadline
552 554
553 // 更新兑换现金活动倒计时命令 555 // 更新兑换现金活动倒计时命令
@@ -583,7 +585,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -583,7 +585,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
583 585
584 // 兑换现金活动返回截止时间处理 586 // 兑换现金活动返回截止时间处理
585 var activitiesWithTs []interface{} 587 var activitiesWithTs []interface{}
586 - currentTime := time.Now() 588 + currentTime := time.Now().Local()
587 //endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location()) 589 //endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())
588 for _, activity := range activities { 590 for _, activity := range activities {
589 if activity.Deadline.UnixNano() / 1e6 >= currentTime.UnixNano() / 1e6 { 591 if activity.Deadline.UnixNano() / 1e6 >= currentTime.UnixNano() / 1e6 {
@@ -696,7 +698,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -696,7 +698,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
696 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getExchangeCashActivityQuery.ExchangeCashActivityId))) 698 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getExchangeCashActivityQuery.ExchangeCashActivityId)))
697 } 699 }
698 700
699 - var t1 = time.Now() 701 + var t1 = time.Now().Local()
700 var t2 = activityFound.Deadline 702 var t2 = activityFound.Deadline
701 703
702 // 更新兑换现金活动倒计时命令 704 // 更新兑换现金活动倒计时命令
@@ -901,7 +903,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -901,7 +903,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
901 } 903 }
902 904
903 // 计算倒计时 905 // 计算倒计时
904 - var t1 = time.Now() 906 + var t1 = time.Now().Local()
905 var t2 = activityFound.Deadline 907 var t2 = activityFound.Deadline
906 updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24)) 908 updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
907 909
@@ -97,7 +97,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ @@ -97,7 +97,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
97 var expendSuMoneyOfYesterday float64 97 var expendSuMoneyOfYesterday float64
98 tx := dao.transactionContext.PgTx 98 tx := dao.transactionContext.PgTx
99 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 99 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
100 - yesterday := time.Now().AddDate(0, 0, -1) 100 + yesterday := time.Now().Local().AddDate(0, 0, -1)
101 // 昨日总收益 101 // 昨日总收益
102 if err := tx.Model(suMoneyTransactionRecordModel). 102 if err := tx.Model(suMoneyTransactionRecordModel).
103 ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money"). 103 ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
@@ -89,7 +89,7 @@ func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64, @@ -89,7 +89,7 @@ func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64,
89 SuMoney: suMoney, 89 SuMoney: suMoney,
90 Operator: operator.EmployeeInfo, 90 Operator: operator.EmployeeInfo,
91 RecordDescription: recordDescription, 91 RecordDescription: recordDescription,
92 - CreateTime: time.Now(), 92 + CreateTime: time.Now().Local(),
93 } 93 }
94 if err := employeeDao.TransferSuMoney(employee.EmployeeInfo.Uid, transferSuMoney); err != nil { 94 if err := employeeDao.TransferSuMoney(employee.EmployeeInfo.Uid, transferSuMoney); err != nil {
95 return nil, err 95 return nil, err
@@ -5,10 +5,13 @@ import ( @@ -5,10 +5,13 @@ import (
5 "github.com/linmadan/egglib-go/web/beego/filters" 5 "github.com/linmadan/egglib-go/web/beego/filters"
6 . "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/log" 6 . "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/log"
7 _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/routers" 7 _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/routers"
  8 + "time"
8 ) 9 )
9 10
10 func init() { 11 func init() {
11 beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequestBodyFilter()) 12 beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequestBodyFilter())
12 beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequstLogFilter(Logger)) 13 beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequstLogFilter(Logger))
13 beego.InsertFilter("/*", beego.AfterExec, filters.CreateResponseLogFilter(Logger), false) 14 beego.InsertFilter("/*", beego.AfterExec, filters.CreateResponseLogFilter(Logger), false)
  15 + timeLocal, _ := time.LoadLocation("Asia/Chongqing")
  16 + time.Local = timeLocal
14 } 17 }