|
|
@@ -7,7 +7,6 @@ import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/svc" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"time" |
|
|
|
"xorm.io/xorm" |
|
|
@@ -50,32 +49,24 @@ func EggEnergyAutoRecordPrices(engine *xorm.Engine) { |
|
|
|
// 3. 当前时间已经有记录 更新价格 |
|
|
|
if lastPrice.Date == dateNowStr && lastPrice.Hour == hourNowStr { |
|
|
|
lastPrice.Price = eggEnergyCoreData.NowPrice |
|
|
|
affected, err2 := priceDb.EggEnergyPriceUpdate(lastPrice) |
|
|
|
_, err2 := priceDb.EggEnergyPriceUpdate(lastPrice) |
|
|
|
if err2 != nil { |
|
|
|
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if affected == 0 { |
|
|
|
fmt.Println("SaveEggEnergyPrice_ERR:::::", errors.New(fmt.Sprintf("%s 新增价格失败, 当前价格 %s", now.Format("2006-01-02 15:04:05"), eggEnergyCoreData.NowPrice))) |
|
|
|
} else { |
|
|
|
// 4. 保存当前价格 |
|
|
|
priceData := model.EggEnergyPrice{ |
|
|
|
Price: eggEnergyCoreData.NowPrice, |
|
|
|
Date: dateNowStr, |
|
|
|
Hour: hourNowStr, |
|
|
|
} |
|
|
|
_, err2 := priceDb.EggEnergyPriceInsert(&priceData) |
|
|
|
if err2 != nil { |
|
|
|
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 4. 保存当前价格 |
|
|
|
priceData := model.EggEnergyPrice{ |
|
|
|
Price: eggEnergyCoreData.NowPrice, |
|
|
|
Date: dateNowStr, |
|
|
|
Hour: hourNowStr, |
|
|
|
} |
|
|
|
id, err2 := priceDb.EggEnergyPriceInsert(&priceData) |
|
|
|
if err2 != nil { |
|
|
|
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if id == 0 { |
|
|
|
fmt.Println("SaveEggEnergyPrice_ERR:::::", errors.New(fmt.Sprintf("%s 新增价格失败, 当前价格 %s", now.Format("2006-01-02 15:04:05"), eggEnergyCoreData.NowPrice))) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |