Selaa lähdekoodia

购物金

master
huangjiajun 4 kuukautta sitten
vanhempi
commit
41d350d53f
1 muutettua tiedostoa jossa 62 lisäystä ja 5 poistoa
  1. +62
    -5
      rule/service_award_dividend/return.go

+ 62
- 5
rule/service_award_dividend/return.go Näytä tiedosto

@@ -14,10 +14,11 @@ 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),
}
res := map[string]string{}
if base != nil {
res = map[string]string{
"coin_id": zhios_order_relate_utils.IntToStr(base.CoinId),
}
ex := strings.Split(base.Day, ",")
if len(ex) > 0 {
day := now.Day()
@@ -89,6 +90,34 @@ func AddPeriod(eg *xorm.Engine, sess *xorm.Session, req map[string]string) int {
if base.CoinId != zhios_order_relate_utils.StrToInt(req["coin_id"]) {
return 2
}
date := GetCycle(eg)
if base.ReturnType == 1 { //手动的
var data models.ServiceAwardReturnFlow
get, _ := sess.Where("coin_id=? and type=? and pvd=? and date=? and uid=?", req["coin_id"], 1, req["pvd"], date["now"], 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.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
}
return 1
}
period := 0
switch req["pvd"] {
case "0":
@@ -107,7 +136,6 @@ func AddPeriod(eg *xorm.Engine, sess *xorm.Session, req map[string]string) int {
if period == 0 {
return 2
}
date := GetCycle(eg)
data := models.ServiceAwardReturnFlow{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),
@@ -137,6 +165,35 @@ func AddPeriodEg(eg *xorm.Engine, req map[string]string) int {
if base.CoinId != zhios_order_relate_utils.StrToInt(req["coin_id"]) {
return 2
}
date := GetCycle(eg)

if base.ReturnType == 1 { //手动的
var data models.ServiceAwardReturnFlow
get, _ := eg.Where("coin_id=? and type=? and pvd=? and date=? and uid=?", req["coin_id"], 1, req["pvd"], date["now"], 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.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
}
return 1
}
period := 0
switch req["pvd"] {
case "0":
@@ -155,7 +212,7 @@ func AddPeriodEg(eg *xorm.Engine, req map[string]string) int {
if period == 0 {
return 2
}
date := GetCycle(eg)
data := models.ServiceAwardReturnFlow{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
Time: time.Now(),


Ladataan…
Peruuta
Tallenna