huangjiajun 2 months ago
parent
commit
30737cabaa
3 changed files with 29 additions and 91 deletions
  1. +1
    -1
      go.mod
  2. +2
    -0
      go.sum
  3. +26
    -90
      rule/service_award_dividend/return.go

+ 1
- 1
go.mod View 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.20241011013237-040263075a38
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241017011352-f7f92494c0f4
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 View File

@@ -16,6 +16,8 @@ code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241010102102-5676d4b
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241010102102-5676d4b8436f/go.mod h1:nT2x13YFgrS3tS1fDyUR6q/GNIK+hPw7bdzZXz99SM0=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241011013237-040263075a38 h1:UdYxMWbzUYbIX8YkrWHLFioWvkd7YsVNWHpAovlRkDE=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241011013237-040263075a38/go.mod h1:nT2x13YFgrS3tS1fDyUR6q/GNIK+hPw7bdzZXz99SM0=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241017011352-f7f92494c0f4 h1:bixWmzOO5D7XtR30/xl6rR1KiMbwrqc+snRJ6aQyWWI=
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241017011352-f7f92494c0f4/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=


+ 26
- 90
rule/service_award_dividend/return.go View File

@@ -93,66 +93,32 @@ func AddPeriod(eg *xorm.Engine, sess *xorm.Session, req map[string]string) int {
return 2
}
date := GetCycle(eg)
if base.ReturnType == 1 { //手动的
var data models.ServiceAwardReturnFlow
get, _ := sess.Where("coin_id=? and type=? and pvd=? and uid=?", req["coin_id"], 1, req["pvd"], req["uid"]).Get(&data)
if get == false {
data = models.ServiceAwardReturnFlow{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),
UpdateTime: time.Now(),
Type: 1,
Pvd: zhios_order_relate_utils.StrToInt(req["pvd"]),
CoinId: base.CoinId,
Date: zhios_order_relate_utils.StrToInt(date["now"]),
LastDate: zhios_order_relate_utils.StrToInt(date["last"]),
}
insert, err := sess.Insert(&data)
if insert == 0 || err != nil {
return 3
}
}
data.Price = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(data.Price) + zhios_order_relate_utils.StrToFloat64(req["price"]))
data.Sum = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(data.Sum) + zhios_order_relate_utils.StrToFloat64(req["amount"]))
data.UpdateTime = time.Now()
update, err := sess.Where("id=?", data.Id).Cols("sum,update_time").Update(&data)
if update == 0 || err != nil {
return 3
}
data1 := models.ServiceAwardReturnFlowHand{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),
UpdateTime: time.Now(),
Sum: req["amount"],
Type: 1,
HasReturnMoney: "0",
Price: req["price"],
Pvd: zhios_order_relate_utils.StrToInt(req["pvd"]),
CoinId: base.CoinId,
Date: zhios_order_relate_utils.StrToInt(date["now"]),
LastDate: zhios_order_relate_utils.StrToInt(date["last"]),
Oid: zhios_order_relate_utils.StrToInt64(req["oid"]),
}
update, err = sess.Insert(&data1)
if update == 0 || err != nil {
return 3
}
return 1
}
period := 0
switch req["pvd"] {
case "0":
period = base.CpsPeriod
if base.ReturnType == 1 {
period = base.HandCpsPeriod
}
break
case "1":
period = base.MallPeriod
if base.ReturnType == 1 {
period = base.HandMallPeriod
}
break
case "2":
period = base.MemberUplvPeriod
if base.ReturnType == 1 {
period = base.HandMemberUplvPeriod
}
break
case "3":
req["price"] = "0"
period = base.NewMemberPeriod
if base.ReturnType == 1 {
period = base.HandNewMemberPeriod
}
break
}
if period == 0 {
@@ -163,6 +129,7 @@ func AddPeriod(eg *xorm.Engine, sess *xorm.Session, req map[string]string) int {
Time: time.Now(),
UpdateTime: time.Now(),
Sum: req["amount"],
Type: base.ReturnType,
HasReturnMoney: "0",
Period: period,
Price: req["price"],
@@ -189,64 +156,32 @@ func AddPeriodEg(eg *xorm.Engine, req map[string]string) int {
return 2
}
date := GetCycle(eg)

if base.ReturnType == 1 { //手动的
var data models.ServiceAwardReturnFlow
get, _ := eg.Where("coin_id=? and type=? and pvd=? and uid=?", req["coin_id"], 1, req["pvd"], req["uid"]).Get(&data)
if get == false {
data = models.ServiceAwardReturnFlow{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),
UpdateTime: time.Now(),
Type: 1,
Pvd: zhios_order_relate_utils.StrToInt(req["pvd"]),
CoinId: base.CoinId,
Date: zhios_order_relate_utils.StrToInt(date["now"]),
LastDate: zhios_order_relate_utils.StrToInt(date["last"]),
}
insert, err := eg.Insert(&data)
if insert == 0 || err != nil {
return 3
}
}
data.Price = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(data.Price) + zhios_order_relate_utils.StrToFloat64(req["price"]))
data.Sum = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(data.Sum) + zhios_order_relate_utils.StrToFloat64(req["amount"]))
data.UpdateTime = time.Now()
update, err := eg.Where("id=?", data.Id).Cols("sum,update_time").Update(&data)
if update == 0 || err != nil {
return 3
}
data1 := models.ServiceAwardReturnFlowHand{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),
UpdateTime: time.Now(),
Sum: req["amount"],
Type: 1,
HasReturnMoney: "0",
Price: req["price"],
Pvd: zhios_order_relate_utils.StrToInt(req["pvd"]),
CoinId: base.CoinId,
Date: zhios_order_relate_utils.StrToInt(date["now"]),
LastDate: zhios_order_relate_utils.StrToInt(date["last"]),
Oid: zhios_order_relate_utils.StrToInt64(req["oid"]),
}
eg.Insert(&data1)
return 1
}
period := 0
switch req["pvd"] {
case "0":
period = base.CpsPeriod
if base.ReturnType == 1 {
period = base.HandCpsPeriod
}
break
case "1":
period = base.MallPeriod
if base.ReturnType == 1 {
period = base.HandMallPeriod
}
break
case "2":
period = base.MemberUplvPeriod
if base.ReturnType == 1 {
period = base.HandMemberUplvPeriod
}
break
case "3":
req["price"] = "0"
period = base.NewMemberPeriod
if base.ReturnType == 1 {
period = base.HandNewMemberPeriod
}
break
}
if period == 0 {
@@ -257,6 +192,7 @@ func AddPeriodEg(eg *xorm.Engine, req map[string]string) int {
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),
UpdateTime: time.Now(),
Type: base.ReturnType,
Sum: req["amount"],
HasReturnMoney: "0",
Price: req["price"],


Loading…
Cancel
Save