作者 陈志颖

test:测试服务时间差

... ... @@ -104,7 +104,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
UnExchangeSuMoney: systemUnExchangeSuMoney,
LastRate: 0,
Rate: 0,
CreateTime: time.Now(),
CreateTime: time.Now().Local(),
}
if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -137,7 +137,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
UnExchangeSuMoney: systemUnExchangeSuMoney,
Rate: newRate,
LastRate: cashPools[0].LastRate,
CreateTime: time.Now(),
CreateTime: time.Now().Local(),
}
// 保存现金池更新
if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
... ... @@ -267,7 +267,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
"unExchangeSuMoney": systemUnExchangeSuMoney,
"rate": 0, // 平均兑换汇率
"lastRate": 0, // 上期活动兑换汇率
"createTime": time.Now(),
"createTime": time.Now().Local(),
}, nil
} else {
cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
... ... @@ -323,7 +323,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
//var deadline = createExchangeCashActivityCommand.Deadline
todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local)
deadline := todayZero.Add(dd)
var t1 = time.Now()
var t1 = time.Now().Local()
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local)
// 获取该公司所有兑换现金活动
... ... @@ -333,7 +333,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, activity := range activities {
if t2.Format("2006-01-02") == activity.Deadline.UTC().Format("2006-01-02") {
//if t2.Format("2006-01-02") == activity.Deadline.UTC().Format("2006-01-02") {
if t2.Format("2006-01-02") == activity.Deadline.Format("2006-01-02") {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
}
}
... ... @@ -348,7 +349,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
Deadline: t2,
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
Rate: createExchangeCashActivityCommand.ExchangeRate,
CreateTime: time.Now(),
CreateTime: time.Now().Local(),
}
// 倒计时结束判断
... ... @@ -406,7 +407,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc
// 提取兑换现金活动截止时间
var deadlines []interface{}
for _, activity := range activities {
tmpTime := activity.Deadline.UTC().Format("2006-01-02")
//tmpTime := activity.Deadline.UTC().Format("2006-01-02")
tmpTime := activity.Deadline.Format("2006-01-02")
if !utils.IsContain(deadlines, tmpTime) {
deadlines = append(deadlines, tmpTime)
}
... ... @@ -451,7 +453,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, activity := range activities {
var t1 = time.Now()
var t1 = time.Now().Local()
var t2 = activity.Deadline
// 更新兑换活动倒计时命令
... ... @@ -547,7 +549,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, activity := range activities {
var t1 = time.Now()
var t1 = time.Now().Local()
var t2 = activity.Deadline
// 更新兑换现金活动倒计时命令
... ... @@ -583,7 +585,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
// 兑换现金活动返回截止时间处理
var activitiesWithTs []interface{}
currentTime := time.Now()
currentTime := time.Now().Local()
//endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())
for _, activity := range activities {
if activity.Deadline.UnixNano() / 1e6 >= currentTime.UnixNano() / 1e6 {
... ... @@ -696,7 +698,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getExchangeCashActivityQuery.ExchangeCashActivityId)))
}
var t1 = time.Now()
var t1 = time.Now().Local()
var t2 = activityFound.Deadline
// 更新兑换现金活动倒计时命令
... ... @@ -901,7 +903,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
}
// 计算倒计时
var t1 = time.Now()
var t1 = time.Now().Local()
var t2 = activityFound.Deadline
updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
... ...
... ... @@ -97,7 +97,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
var expendSuMoneyOfYesterday float64
tx := dao.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
yesterday := time.Now().AddDate(0, 0, -1)
yesterday := time.Now().Local().AddDate(0, 0, -1)
// 昨日总收益
if err := tx.Model(suMoneyTransactionRecordModel).
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
... ...
... ... @@ -89,7 +89,7 @@ func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64,
SuMoney: suMoney,
Operator: operator.EmployeeInfo,
RecordDescription: recordDescription,
CreateTime: time.Now(),
CreateTime: time.Now().Local(),
}
if err := employeeDao.TransferSuMoney(employee.EmployeeInfo.Uid, transferSuMoney); err != nil {
return nil, err
... ...
... ... @@ -5,10 +5,13 @@ import (
"github.com/linmadan/egglib-go/web/beego/filters"
. "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/log"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/routers"
"time"
)
func init() {
beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequestBodyFilter())
beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequstLogFilter(Logger))
beego.InsertFilter("/*", beego.AfterExec, filters.CreateResponseLogFilter(Logger), false)
timeLocal, _ := time.LoadLocation("Asia/Chongqing")
time.Local = timeLocal
}
... ...