Browse Source

test

tags/v4.3.1
huangjiajun 1 year ago
parent
commit
ad6b5f3144
2 changed files with 24 additions and 15 deletions
  1. +2
    -2
      db/db_mall_ord_capital_pool_total.go
  2. +22
    -13
      rule/self_buy_global.go

+ 2
- 2
db/db_mall_ord_capital_pool_total.go View File

@@ -6,9 +6,9 @@ import (
"xorm.io/xorm" "xorm.io/xorm"
) )


func GetMaxPrice(eg *xorm.Engine, uid string) *model.MallOrdCapitalPoolTotal {
func GetMaxPrice(eg *xorm.Engine, uid string, price float64) *model.MallOrdCapitalPoolTotal {
var data model.MallOrdCapitalPoolTotal var data model.MallOrdCapitalPoolTotal
get, err := eg.Where("uid=? and type=?", uid, 0).Get(&data)
get, err := eg.Where("uid=? and type=? and other_price<?", uid, 0, price).Get(&data)
if err != nil { if err != nil {
return nil return nil
} }


+ 22
- 13
rule/self_buy_global.go View File

@@ -38,22 +38,31 @@ func AddOrder(eg *xorm.Engine, req map[string]string) {
eg.Insert(data) eg.Insert(data)
} }
} else { } else {
if price < minMOney {
return
}
var data = &model.MallOrdCapitalPoolTotal{
Uid: zhios_order_relate_utils.StrToInt(req["uid"]),
OtherPrice: req["price"],
LeavePrice: req["price"],
Num: 1,
UpdateTime: time.Now(),
Oid: req["oid"],
Type: 0,
}
eg.Insert(data)
getPrice(eg, req, minMOney*capitalPoolMul, price)
} }
return return
} }
func getPrice(eg *xorm.Engine, req map[string]string, minMoney float64, leavePrice float64) {
if leavePrice <= 0 {
return
}
max := db.GetMaxPrice(eg, req["uid"], minMoney)
if max != nil {
sum := zhios_order_relate_utils.StrToFloat64(max.OtherPrice) + leavePrice
if sum >= minMoney { //如果超过了498
leavePrice = sum - minMoney
if leavePrice > 0 {
getPrice(eg, req, minMoney, leavePrice)
}
leavePrice = minMoney - zhios_order_relate_utils.StrToFloat64(max.OtherPrice)
max.Num = 1
}
max.LeavePrice = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(max.LeavePrice)+leavePrice, 3)
max.OtherPrice = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(max.OtherPrice)+leavePrice, 3)
max.UpdateTime = time.Now()
eg.Where("id=?", max.Id).AllCols().Update(max)
}
}


func Pool(eg *xorm.Engine, price string) error { func Pool(eg *xorm.Engine, price string) error {
if zhios_order_relate_utils.StrToFloat64(price) == 0 { if zhios_order_relate_utils.StrToFloat64(price) == 0 {


Loading…
Cancel
Save