|
|
@@ -17,6 +17,24 @@ func InitForAppreciation(redisAddr string) (err error) { |
|
|
|
_, err = cache.SelectDb(md.RedisDataBase) |
|
|
|
return |
|
|
|
} |
|
|
|
func CalcAppreciationValueEg(eg *xorm.Engine) (err error, value float64) { |
|
|
|
var appreciationBase model.AppreciationBase |
|
|
|
//1、查询增值积分资产总值 |
|
|
|
has, err := eg.Table("appreciation_base").Where("is_use =1").Get(&appreciationBase) |
|
|
|
if err != nil { |
|
|
|
return err, value |
|
|
|
} |
|
|
|
if !has { |
|
|
|
return errors.New("未查询到`增值积分资产总值`记录"), value |
|
|
|
} |
|
|
|
if zhios_order_relate_utils.StrToFloat64(appreciationBase.Sum) == 0 { //默认是1 |
|
|
|
return nil, 1 |
|
|
|
} |
|
|
|
sum, _ := decimal.NewFromString(appreciationBase.Sum) //总资产 |
|
|
|
flowSum, _ := decimal.NewFromString(appreciationBase.FlowSum) //流通资产 |
|
|
|
value, _ = sum.Div(flowSum).RoundFloor(4).Float64() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
计算增值积分当前价值 |
|
|
|