From 09567e78532dce4087c4f416a592a560f697d8a2 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 16 Aug 2024 09:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 2 ++ rule/service_award_dividend/return.go | 49 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 74b45e3..3cd3f4b 100644 --- a/go.mod +++ b/go.mod @@ -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.20240815013805-e7235e2d4d7e + code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240816012431-432a50e554e4 github.com/gin-gonic/gin v1.9.1 github.com/go-redis/redis v6.15.9+incompatible github.com/gomodule/redigo v1.8.9 diff --git a/go.sum b/go.sum index 0668c9e..fc62840 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240812063422-6380c88 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= +code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240816012431-432a50e554e4 h1:DOPRTEFY8bKmAk+soM5t/hdnEaMI+UCNATX5y64sy7Q= +code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240816012431-432a50e554e4/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= diff --git a/rule/service_award_dividend/return.go b/rule/service_award_dividend/return.go index 7ad07a4..ad77da9 100644 --- a/rule/service_award_dividend/return.go +++ b/rule/service_award_dividend/return.go @@ -3,6 +3,7 @@ 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" + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" "sort" "strings" "time" @@ -76,3 +77,51 @@ func GetDate(now time.Time, day, types string) int64 { date = time.Date(year, month, zhios_order_relate_utils.StrToInt(day), 0, 0, 0, 0, now.Location()).Unix() return date } + +func AddPeriod(eg *xorm.Engine, sess *xorm.Session, req map[string]string) int { + NewServiceAwardReturnBaseDb := implement.NewServiceAwardReturnBaseDb(eg) + base, _ := NewServiceAwardReturnBaseDb.GetServiceAwardReturnBase() + if base == nil { + return 2 + } + if base.CoinId != zhios_order_relate_utils.StrToInt(req["coin_id"]) { + return 2 + } + period := 0 + switch req["pvd"] { + case "0": + period = base.CpsPeriod + break + case "1": + period = base.MallPeriod + break + case "2": + period = base.MemberUplvPeriod + break + case "3": + period = base.NewMemberPeriod + break + } + if period == 0 { + return 2 + } + date := GetCycle(eg) + data := models.ServiceAwardReturnFlow{ + Uid: zhios_order_relate_utils.StrToInt(req["uid"]), + Time: time.Now(), + UpdateTime: time.Now(), + Sum: req["amount"], + HasReturnMoney: "0", + Period: period, + EveryMoney: zhios_order_relate_utils.Float64ToStr(float64(int(zhios_order_relate_utils.StrToFloat64(req["amount"])/float64(period)*100)) / 100), + Pvd: zhios_order_relate_utils.StrToInt(req["pvd"]), + CoinId: base.CoinId, + Date: zhios_order_relate_utils.StrToInt(date["now"]), + Oid: zhios_order_relate_utils.StrToInt64(req["oid"]), + } + insert, err := sess.Insert(&data) + if insert == 0 || err != nil { + return 3 + } + return 1 +}