浏览代码

update 一个圈圈

master
dengbiao 8 个月前
父节点
当前提交
9be27efdce
共有 1 个文件被更改,包括 32 次插入34 次删除
  1. +32
    -34
      rule/one_circles/one_circles_deal_available_green_energy_points.go

+ 32
- 34
rule/one_circles/one_circles_deal_available_green_energy_points.go 查看文件

@@ -5,9 +5,7 @@ import (
"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/rule/one_circles/enum"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"encoding/json"
"errors"
"github.com/shopspring/decimal"
"time"
"xorm.io/xorm"
@@ -451,44 +449,44 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
//更新 `one_circles_green_energy_basic_setting` 表
if chain.NowPrice != nowPriceValue {
chain.NowPrice = nowPriceValue
// 新增 / 更新 one_circles_green_energy_price 记录
date := now.Format("2006-01-02")
hour := zhios_order_relate_utils.IntToStr(now.Hour())
oneCirclesGreenEnergyPrice, err := db.OneCirclesGreenEnergyPriceGetOneByParamsBySession(session, date, hour)
_, err := db.OneCirclesGreenEnergyBasicSettingUpdate(session, chain.Id, chain, "now_price")
if err != nil {
return err
}
if oneCirclesGreenEnergyPrice == nil {
oneCirclesGreenEnergyPrice = &model.OneCirclesGreenEnergyPrice{
Price: nowPriceValue,
Date: date,
Hour: hour,
}
insertId, err1 := db.OneCirclesGreenEnergyPriceInsertBySession(session, oneCirclesGreenEnergyPrice)
if err1 != nil {
return err1
}
if insertId <= 0 {
return errors.New("插入 one_circles_green_energy_price 失败")
}
} else {
oneCirclesGreenEnergyPrice.Price = nowPriceValue
_, err1 := db.OneCirclesGreenEnergyPriceUpdate(session, oneCirclesGreenEnergyPrice.Id, oneCirclesGreenEnergyPrice, "price")
if err1 != nil {
return err1
}
//if updateAffected <= 0 {
// return errors.New("更新 one_circles_green_energy_price 失败")
//}
}
}
_, err := db.OneCirclesGreenEnergyBasicSettingUpdate(session, chain.Id, chain)
if err != nil {
return err
//// 新增 / 更新 one_circles_green_energy_price 记录
//date := now.Format("2006-01-02")
//hour := zhios_order_relate_utils.IntToStr(now.Hour())
//oneCirclesGreenEnergyPrice, err := db.OneCirclesGreenEnergyPriceGetOneByParamsBySession(session, date, hour)
//if err != nil {
// return err
//}
//if oneCirclesGreenEnergyPrice == nil {
// oneCirclesGreenEnergyPrice = &model.OneCirclesGreenEnergyPrice{
// Price: nowPriceValue,
// Date: date,
// Hour: hour,
// }
// insertId, err1 := db.OneCirclesGreenEnergyPriceInsertBySession(session, oneCirclesGreenEnergyPrice)
// if err1 != nil {
// return err1
// }
// if insertId <= 0 {
// return errors.New("插入 one_circles_green_energy_price 失败")
// }
//} else {
// oneCirclesGreenEnergyPrice.Price = nowPriceValue
// _, err1 := db.OneCirclesGreenEnergyPriceUpdate(session, oneCirclesGreenEnergyPrice.Id, oneCirclesGreenEnergyPrice, "price")
// if err1 != nil {
// return err1
// }
// //if updateAffected <= 0 {
// // return errors.New("更新 one_circles_green_energy_price 失败")
// //}
//}
}

//插入 `one_circles_available_green_energy_points_flow` 记录
_, err = db.OneCirclesAvailableGreenEnergyPointsFlowInsert(session, &oneCirclesAvailableGreenEnergyPointsFlow)
_, err := db.OneCirclesAvailableGreenEnergyPointsFlowInsert(session, &oneCirclesAvailableGreenEnergyPointsFlow)
if err != nil {
return err
}


正在加载...
取消
保存