|
@@ -128,3 +128,51 @@ func AddPeriod(eg *xorm.Engine, sess *xorm.Session, req map[string]string) int { |
|
|
} |
|
|
} |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
|
|
|
|
func AddPeriodEg(eg *xorm.Engine, 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"]), |
|
|
|
|
|
LastDate: zhios_order_relate_utils.StrToInt(date["last"]), |
|
|
|
|
|
Oid: zhios_order_relate_utils.StrToInt64(req["oid"]), |
|
|
|
|
|
} |
|
|
|
|
|
insert, err := eg.Insert(&data) |
|
|
|
|
|
if insert == 0 || err != nil { |
|
|
|
|
|
return 3 |
|
|
|
|
|
} |
|
|
|
|
|
return 1 |
|
|
|
|
|
} |