|
@@ -9,11 +9,13 @@ import (
|
|
|
)
|
|
|
|
|
|
func GetPricingStrategy(ctx context.Context, fansLow int64, fansUp int64, feeForm int64, platForm int64) (*gorm_model.InfoPricingStrategy, error) {
|
|
|
- db := GetReadDB(context.Background())
|
|
|
- PricingStrategys := []gorm_model.InfoPricingStrategy{}
|
|
|
+ db := GetReadDB(ctx)
|
|
|
+ var PricingStrategys []gorm_model.InfoPricingStrategy
|
|
|
whereStr := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up >= %d", feeForm, platForm, fansLow, fansLow)
|
|
|
orStr := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up >= %d", feeForm, platForm, fansUp, fansUp)
|
|
|
- err := db.Model(gorm_model.InfoPricingStrategy{}).Where(whereStr).Or(orStr).Scan(&PricingStrategys).Error
|
|
|
+ orStr1 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low >= %d and fans_up <= %d", feeForm, platForm, fansLow, fansUp)
|
|
|
+ orStr2 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up >= %d", feeForm, platForm, fansLow, fansUp)
|
|
|
+ err := db.Model(gorm_model.InfoPricingStrategy{}).Where(whereStr).Or(orStr).Or(orStr1).Or(orStr2).Scan(&PricingStrategys).Error
|
|
|
if err != nil {
|
|
|
log.Println("DB GetLastAutoDefaultID:", err)
|
|
|
return nil, err
|
|
@@ -22,6 +24,7 @@ func GetPricingStrategy(ctx context.Context, fansLow int64, fansUp int64, feeFor
|
|
|
if feeForm == 1 {
|
|
|
var maxCharge float64 = 0
|
|
|
for _, v := range PricingStrategys {
|
|
|
+ fmt.Println(v.ServiceCharge)
|
|
|
if v.ServiceCharge >= maxCharge {
|
|
|
maxCharge = v.ServiceCharge
|
|
|
PricingStrategy = v
|
|
@@ -30,12 +33,12 @@ func GetPricingStrategy(ctx context.Context, fansLow int64, fansUp int64, feeFor
|
|
|
} else {
|
|
|
var maxRate int64 = 0
|
|
|
for _, v := range PricingStrategys {
|
|
|
+ fmt.Println(v.ServiceRate)
|
|
|
if v.ServiceRate >= maxRate {
|
|
|
maxRate = v.ServiceRate
|
|
|
PricingStrategy = v
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //fmt.Printf("auto task %+v %+v", result, LastTask)
|
|
|
return &PricingStrategy, nil
|
|
|
}
|