huangjiajun 2 mesi fa
parent
commit
8ce9aa57eb
3 ha cambiato i file con 81 aggiunte e 1 eliminazioni
  1. +1
    -1
      go.mod
  2. +2
    -0
      go.sum
  3. +78
    -0
      rule/service_award_dividend/return.go

+ 1
- 1
go.mod Vedi File

@@ -7,7 +7,7 @@ go 1.15

require (
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240812063422-6380c884a38b
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240815013805-e7235e2d4d7e
github.com/gin-gonic/gin v1.9.1
github.com/go-redis/redis v6.15.9+incompatible
github.com/gomodule/redigo v1.8.9


+ 2
- 0
go.sum Vedi File

@@ -4,6 +4,8 @@ code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 h1:dqvWJqlJi0WXCwTxbWPLv
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5/go.mod h1:TTcCnFn/LhBGapnutpezlW+GXkLRNPMWkziOoCsXQqY=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240812063422-6380c884a38b h1:RIDin5L2JusKXSZrWu9ThMtf5QSAHdlws/ukGPY83MI=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240812063422-6380c884a38b/go.mod h1:nT2x13YFgrS3tS1fDyUR6q/GNIK+hPw7bdzZXz99SM0=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240815013805-e7235e2d4d7e h1:XkIx6T9yJi3pnaZ1MNeVei/VqUZxrL9tZP7PjkqBt/Q=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240815013805-e7235e2d4d7e/go.mod h1:nT2x13YFgrS3tS1fDyUR6q/GNIK+hPw7bdzZXz99SM0=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=


+ 78
- 0
rule/service_award_dividend/return.go Vedi File

@@ -0,0 +1,78 @@
package service_award_dividend

import (
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/implement"
"sort"
"strings"
"time"
"xorm.io/xorm"
)

func GetCycle(eg *xorm.Engine) map[string]string {
NewServiceAwardReturnBaseDb := implement.NewServiceAwardReturnBaseDb(eg)
base, _ := NewServiceAwardReturnBaseDb.GetServiceAwardReturnBase()
now := time.Now()
res := map[string]string{
"coin_id": zhios_order_relate_utils.IntToStr(base.CoinId),
}
if base != nil {
ex := strings.Split(base.Day, ",")
if len(ex) > 0 {
day := now.Day()
hasDay := 0
sort.Strings(ex)
postion := 0
//31
// 16 20 30
for k, v := range ex { //判断最近的一天 now 读的是当前周期 就是比当前时间大的一个日期 last 读的是上个周期 就是比当前时间小的一个日期
if day > zhios_order_relate_utils.StrToInt(v) { //当前时间大于设置时间
if k+1 == len(ex) {
postion = k + 1
}
continue
}
if hasDay == 1 {
continue
}
postion = k
hasDay = 1
}
last := postion - 1
next := postion
if postion-1 < 0 { //找出上一周期的时间
last = len(ex) - 1
} else if last == len(ex)-1 { //最后一个了
next = 0
}

lastDate := GetDate(now, zhios_order_relate_utils.IntToStr(last), "last")
res["last"] = time.Unix(lastDate, 0).Format("20060102")
nowDate := GetDate(now, zhios_order_relate_utils.IntToStr(next), "now")
res["now"] = time.Unix(nowDate, 0).Format("20060102")
}
}
return res
}
func GetDate(now time.Time, day, types string) int64 {
year := now.Year()
month := now.Month()
var date int64 = 0
if types == "last" {
month--
if month < 0 {
month = 12
year--
}
}
if types == "next" {
month++
if month > 12 {
month = 1
year++
}
}

date = time.Date(year, month, zhios_order_relate_utils.StrToInt(day), 0, 0, 0, 0, now.Location()).Unix()
return date
}

Caricamento…
Annulla
Salva