Browse Source

add egg energy modify price

master
shenjiachi 1 month ago
parent
commit
e6d5ae4fce
2 changed files with 57 additions and 2 deletions
  1. +56
    -0
      app/task/svc/svc_egg_energy_modify_price.go
  2. +1
    -2
      go.mod

+ 56
- 0
app/task/svc/svc_egg_energy_modify_price.go View File

@@ -0,0 +1,56 @@
package svc

import (
"applet/app/cfg"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_system_rules.git"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/svc"
"fmt"
"xorm.io/xorm"
)

// EggEnergyModifyPrice 蛋蛋能量-价格调整
func EggEnergyModifyPrice(engine *xorm.Engine) {
fmt.Println("modify_price...")
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
return
}
}()

// 1. 获取并解析价格设置
conn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(engine, conn)
settingStr, err1 := cfgDb.SysCfgGetOne(enum.PriceSetting)
if err1 != nil {
fmt.Println("EggEnergyModifyPrice_ERR:::::", err1.Error())
return
}
var setting md.PriceSettingStruct
utils.Unserialize([]byte(settingStr.Val), &setting)

// 2. 查询当前价格
egg_system_rules.Init(cfg.RedisAddr)
eggEnergyCoreData, cb, err2 := svc.GetEggEnergyCoreData(engine)
if err2 != nil {
fmt.Println("EggEnergyModifyPrice_ERR:::::", err2.Error())
return
}
if cb != nil {
defer cb() // 释放锁
}

// 3.判断价格是否在范围内
if eggEnergyCoreData.NowPrice > setting.PriceBelowValue && eggEnergyCoreData.NowPrice < setting.PriceBelowValue {
// 3.1 在价格范围内
return
} else {
// 3.2 不在价格范围内 调整价格
// todo 调整价格
}
}

+ 1
- 2
go.mod View File

@@ -4,7 +4,6 @@ go 1.19

//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models

//
//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules

require (
@@ -35,7 +34,7 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241115090315-a9a84aba8235
code.fnuoos.com/EggPlanet/egg_models.git v0.0.5
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.3
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible


Loading…
Cancel
Save