|
|
@@ -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 |
|
|
|
} |