|
@@ -4,6 +4,7 @@ import ( |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache" |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/shopspring/decimal" |
|
|
"github.com/shopspring/decimal" |
|
@@ -11,13 +12,26 @@ import ( |
|
|
"xorm.io/xorm" |
|
|
"xorm.io/xorm" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const LockKey = "auto_release_exchange_green_energy_lock_key" |
|
|
|
|
|
|
|
|
// AutoReleaseExchangeGreenEnergy 结算绿色能量自动释放成可用绿色能量 |
|
|
// AutoReleaseExchangeGreenEnergy 结算绿色能量自动释放成可用绿色能量 |
|
|
func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err error) { |
|
|
func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err error) { |
|
|
now := time.Now() |
|
|
now := time.Now() |
|
|
if now.Hour() > 1 && now.Hour() > 8 { |
|
|
|
|
|
|
|
|
if now.Hour() > 1 && now.Hour() < 8 { |
|
|
//TODO::只在凌晨一点 ~ 凌晨 8 点运行 |
|
|
//TODO::只在凌晨一点 ~ 凌晨 8 点运行 |
|
|
return errors.New("非运行时间") |
|
|
return errors.New("非运行时间") |
|
|
} |
|
|
} |
|
|
|
|
|
//TODO::增加“悲观锁”防止串行 |
|
|
|
|
|
getString, _ := cache.GetString(LockKey) |
|
|
|
|
|
//if err != nil { |
|
|
|
|
|
// return err |
|
|
|
|
|
//} |
|
|
|
|
|
if getString != "" { |
|
|
|
|
|
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次结算未执行完") |
|
|
|
|
|
return errors.New("上一次结算未执行完") |
|
|
|
|
|
} |
|
|
|
|
|
cache.SetEx(LockKey, "running", 3600*8) //8小时 |
|
|
|
|
|
|
|
|
//1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 |
|
|
//1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 |
|
|
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ |
|
|
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ |
|
|
"key": "is_open", |
|
|
"key": "is_open", |
|
|