作者 陈志颖

fix:导入参数调整

... ... @@ -318,13 +318,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
}
// 时间格式化
dd, _ := time.ParseDuration("24h")
//dd, _ := time.ParseDuration("24h")
//var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
//var deadline = createExchangeCashActivityCommand.Deadline
todayZero, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local)
deadline := todayZero.Add(dd)
deadline, _ := time.ParseInLocation("2006-01-02", createExchangeCashActivityCommand.Deadline, time.Local)
//deadline := todayZero.Add(dd)
var t1 = time.Now().Local()
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 0, 0, 0, 0 - 1, time.Local)
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
fmt.Print(t2, "\n")
// 获取该公司所有兑换现金活动
if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
... ... @@ -334,7 +336,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
} 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.Format("2006-01-02") {
if t2.Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
}
}
... ... @@ -550,13 +552,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
} else {
for _, activity := range activities {
var t1 = time.Now().Local()
var t2 = activity.Deadline
var t2 = activity.Deadline.Local()
// 更新兑换现金活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
ExchangeCashActivityId: activity.ActivityId,
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 重新计算活动倒计时
Deadline: activity.Deadline,
Deadline: activity.Deadline.Local(),
ExchangedSuMoney: activity.ExchangedSuMoney,
ExchangedCash: activity.ExchangedCash,
ExchangeRate: activity.Rate,
... ...
package utils
import (
"encoding/json"
"fmt"
"time"
)
... ... @@ -48,3 +49,18 @@ func (l LocalDate) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02"))
return []byte(stamp), nil
}
func JsonToMap(jsonStr string) (map[string]string, error) {
m := make(map[string]string)
err := json.Unmarshal([]byte(jsonStr), &m)
if err != nil {
fmt.Printf("Unmarshal with error: %+v\n", err)
return nil, err
}
for k, v := range m {
fmt.Printf("%v: %v\n", k, v)
}
return m, nil
}
... ...
... ... @@ -6,6 +6,7 @@ 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,8 +396,19 @@ func (controller *SuMoneyController) ExchangeCashListRanking() {
func (controller *SuMoneyController) ImportExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
activityId, _ := controller.GetInt64("activityId")
operator, _ := controller.GetInt64("operator")
//activityId, _ := controller.GetInt64("activityId")
//operator, _ := controller.GetInt64("operator")
whereStr := controller.GetString("where")
where, err := utils_tool.JsonToMap(whereStr)
//var jsonBlob = []byte(whereStr)
//type Where struct {
// ActivityId string
// Uid string
//}
//var where Where
//err := json.Unmarshal(jsonBlob, where)
//fmt.Print(where, "\n")
file, h, _ := controller.GetFile("file")
// 错误信息返回
... ... @@ -471,14 +483,14 @@ func (controller *SuMoneyController) ImportExchangeList () {
// 新增成功计数
var successDataCount int64
fmt.Print(len(rows), "\n")
//fmt.Print(len(rows), "\n")
for i, row := range rows {
fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row))
//fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row))
if i > 2 && len(row) > 1 {
// 创建兑换清单命令
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
createExchangeCashPersonCommand.Operator = operator
createExchangeCashPersonCommand.ExchangeCashActivityId ,err = strconv.ParseInt(where["activityId"], 10, 64)
createExchangeCashPersonCommand.Operator, err = strconv.ParseInt(where["uid"], 10, 64)
createExchangeCashPersonCommand.PersonName = row[0]
createExchangeCashPersonCommand.PersonAccount = row[1]
r2, _ := strconv.ParseFloat(row[2], 64)
... ...