瀏覽代碼

update

master
DengBiao 9 月之前
父節點
當前提交
08e0d27096
共有 5 個文件被更改,包括 352 次插入3 次删除
  1. +167
    -0
      db/db_one_circles_green_energy_price.go
  2. +167
    -0
      db/db_one_circles_user_activity.go
  3. +8
    -0
      db/model/one_circles_green_energy_price.go
  4. +7
    -0
      db/model/one_circles_user_activity.go
  5. +3
    -3
      rule/one_circles/one_circles_public_platoon_give_activty_coin.go

+ 167
- 0
db/db_one_circles_green_energy_price.go 查看文件

@@ -0,0 +1,167 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"errors"
"fmt"
"reflect"
"xorm.io/xorm"
)

// BatchSelectOneCirclesGreenEnergyPrices 批量查询数据 TODO::和下面的方法重复了,建议采用下面的 `OneCirclesGreenEnergyPriceFindByParams` 方法
func BatchSelectOneCirclesGreenEnergyPrices(Db *xorm.Engine, params map[string]interface{}) (*[]model.OneCirclesGreenEnergyPrice, error) {
var OneCirclesGreenEnergyPriceData []model.OneCirclesGreenEnergyPrice
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).
Find(&OneCirclesGreenEnergyPriceData); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
return &OneCirclesGreenEnergyPriceData, nil
}

// OneCirclesGreenEnergyPriceInsert 插入单条数据
func OneCirclesGreenEnergyPriceInsert(Db *xorm.Engine, OneCirclesGreenEnergyPrice *model.OneCirclesGreenEnergyPrice) (int64, error) {
_, err := Db.InsertOne(OneCirclesGreenEnergyPrice)
if err != nil {
return 0, err
}
return OneCirclesGreenEnergyPrice.Id, nil
}

// BatchAddOneCirclesGreenEnergyPrices 批量新增数据
func BatchAddOneCirclesGreenEnergyPrices(Db *xorm.Engine, OneCirclesGreenEnergyPriceData []*model.OneCirclesGreenEnergyPrice) (int64, error) {
affected, err := Db.Insert(OneCirclesGreenEnergyPriceData)
if err != nil {
return 0, err
}
return affected, nil
}

func GetOneCirclesGreenEnergyPriceCount(Db *xorm.Engine) int {
var OneCirclesGreenEnergyPrice model.OneCirclesGreenEnergyPrice
session := Db.Where("")
count, err := session.Count(&OneCirclesGreenEnergyPrice)
if err != nil {
return 0
}
return int(count)
}

// OneCirclesGreenEnergyPriceDelete 删除记录
func OneCirclesGreenEnergyPriceDelete(Db *xorm.Engine, id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return Db.In("id", id).Delete(model.OneCirclesGreenEnergyPrice{})
} else {
return Db.Where("id = ?", id).Delete(model.OneCirclesGreenEnergyPrice{})
}
}

// OneCirclesGreenEnergyPriceUpdate 更新记录
func OneCirclesGreenEnergyPriceUpdate(session *xorm.Session, id interface{}, OneCirclesGreenEnergyPrice *model.OneCirclesGreenEnergyPrice, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = session.Where("id=?", id).Cols(forceColums...).Update(OneCirclesGreenEnergyPrice)
} else {
affected, err = session.Where("id=?", id).Update(OneCirclesGreenEnergyPrice)
}
if err != nil {
return 0, err
}
return affected, nil
}

// OneCirclesGreenEnergyPriceGetOneByParamsBySession 通过传入的参数查询数据(单条)
func OneCirclesGreenEnergyPriceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.OneCirclesGreenEnergyPrice, error) {
var m model.OneCirclesGreenEnergyPrice
var query = fmt.Sprintf("%s =?", params["key"])
has, err := session.Where(query, params["value"]).Get(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, errors.New("未查询到相应的 block_star_chain 记录")
}
return &m, nil
}

// OneCirclesGreenEnergyPriceGetOneByParams 通过传入的参数查询数据(单条)
func OneCirclesGreenEnergyPriceGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.OneCirclesGreenEnergyPrice, error) {
var m model.OneCirclesGreenEnergyPrice
var query = fmt.Sprintf("%s =?", params["key"])
if has, err := Db.Where(query, params["value"]).Get(&m); err != nil || has == false {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

// OneCirclesGreenEnergyPriceFindByParams 通过传入的参数查询数据(多条)
func OneCirclesGreenEnergyPriceFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[]model.OneCirclesGreenEnergyPrice, error) {
var m []model.OneCirclesGreenEnergyPrice
if params["value"] == nil {
return nil, errors.New("参数有误")
}
if params["key"] == nil {
//查询全部数据
err := Db.Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
} else {
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
return &m, nil
} else {
var query = fmt.Sprintf("%s =?", params["key"])
err := Db.Where(query, params["value"]).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

}
}

func OneCirclesGreenEnergyPriceFindByParamsByPage(Db *xorm.Engine, params map[string]interface{}, page, pageSize int) (*[]model.OneCirclesGreenEnergyPrice, error) {
var m []model.OneCirclesGreenEnergyPrice
if params["value"] == nil {
return nil, errors.New("参数有误")
}
if page == 0 && pageSize == 0 {
page = 1
pageSize = 10
}

if params["key"] == nil {
//查询全部数据
err := Db.Limit(pageSize, (page-1)*pageSize).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
} else {
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Limit(pageSize, (page-1)*pageSize).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
return &m, nil
} else {
var query = fmt.Sprintf("%s =?", params["key"])
err := Db.Where(query, params["value"]).Limit(pageSize, (page-1)*pageSize).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

}
}

+ 167
- 0
db/db_one_circles_user_activity.go 查看文件

@@ -0,0 +1,167 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"errors"
"fmt"
"reflect"
"xorm.io/xorm"
)

// BatchSelectOneCirclesUserActivitys 批量查询数据 TODO::和下面的方法重复了,建议采用下面的 `OneCirclesUserActivityFindByParams` 方法
func BatchSelectOneCirclesUserActivitys(Db *xorm.Engine, params map[string]interface{}) (*[]model.OneCirclesUserActivity, error) {
var OneCirclesUserActivityData []model.OneCirclesUserActivity
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).
Find(&OneCirclesUserActivityData); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
return &OneCirclesUserActivityData, nil
}

// OneCirclesUserActivityInsert 插入单条数据
func OneCirclesUserActivityInsert(Db *xorm.Engine, OneCirclesUserActivity *model.OneCirclesUserActivity) (int64, error) {
_, err := Db.InsertOne(OneCirclesUserActivity)
if err != nil {
return 0, err
}
return OneCirclesUserActivity.Id, nil
}

// BatchAddOneCirclesUserActivitys 批量新增数据
func BatchAddOneCirclesUserActivitys(Db *xorm.Engine, OneCirclesUserActivityData []*model.OneCirclesUserActivity) (int64, error) {
affected, err := Db.Insert(OneCirclesUserActivityData)
if err != nil {
return 0, err
}
return affected, nil
}

func GetOneCirclesUserActivityCount(Db *xorm.Engine) int {
var OneCirclesUserActivity model.OneCirclesUserActivity
session := Db.Where("")
count, err := session.Count(&OneCirclesUserActivity)
if err != nil {
return 0
}
return int(count)
}

// OneCirclesUserActivityDelete 删除记录
func OneCirclesUserActivityDelete(Db *xorm.Engine, id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return Db.In("id", id).Delete(model.OneCirclesUserActivity{})
} else {
return Db.Where("id = ?", id).Delete(model.OneCirclesUserActivity{})
}
}

// OneCirclesUserActivityUpdate 更新记录
func OneCirclesUserActivityUpdate(session *xorm.Session, id interface{}, OneCirclesUserActivity *model.OneCirclesUserActivity, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = session.Where("id=?", id).Cols(forceColums...).Update(OneCirclesUserActivity)
} else {
affected, err = session.Where("id=?", id).Update(OneCirclesUserActivity)
}
if err != nil {
return 0, err
}
return affected, nil
}

// OneCirclesUserActivityGetOneByParamsBySession 通过传入的参数查询数据(单条)
func OneCirclesUserActivityGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.OneCirclesUserActivity, error) {
var m model.OneCirclesUserActivity
var query = fmt.Sprintf("%s =?", params["key"])
has, err := session.Where(query, params["value"]).Get(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, errors.New("未查询到相应的 block_star_chain 记录")
}
return &m, nil
}

// OneCirclesUserActivityGetOneByParams 通过传入的参数查询数据(单条)
func OneCirclesUserActivityGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.OneCirclesUserActivity, error) {
var m model.OneCirclesUserActivity
var query = fmt.Sprintf("%s =?", params["key"])
if has, err := Db.Where(query, params["value"]).Get(&m); err != nil || has == false {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

// OneCirclesUserActivityFindByParams 通过传入的参数查询数据(多条)
func OneCirclesUserActivityFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[]model.OneCirclesUserActivity, error) {
var m []model.OneCirclesUserActivity
if params["value"] == nil {
return nil, errors.New("参数有误")
}
if params["key"] == nil {
//查询全部数据
err := Db.Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
} else {
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
return &m, nil
} else {
var query = fmt.Sprintf("%s =?", params["key"])
err := Db.Where(query, params["value"]).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

}
}

func OneCirclesUserActivityFindByParamsByPage(Db *xorm.Engine, params map[string]interface{}, page, pageSize int) (*[]model.OneCirclesUserActivity, error) {
var m []model.OneCirclesUserActivity
if params["value"] == nil {
return nil, errors.New("参数有误")
}
if page == 0 && pageSize == 0 {
page = 1
pageSize = 10
}

if params["key"] == nil {
//查询全部数据
err := Db.Limit(pageSize, (page-1)*pageSize).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
} else {
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Limit(pageSize, (page-1)*pageSize).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
return &m, nil
} else {
var query = fmt.Sprintf("%s =?", params["key"])
err := Db.Where(query, params["value"]).Limit(pageSize, (page-1)*pageSize).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

}
}

+ 8
- 0
db/model/one_circles_green_energy_price.go 查看文件

@@ -0,0 +1,8 @@
package model

type OneCirclesGreenEnergyPrice struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Price string `json:"price" xorm:"not null default 0.0000000000 comment('价格') DECIMAL(28,10)"`
Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"`
Hour string `json:"hour" xorm:"not null default '00' comment('小时') CHAR(50)"`
}

+ 7
- 0
db/model/one_circles_user_activity.go 查看文件

@@ -0,0 +1,7 @@
package model

type OneCirclesUserActivity struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"`
}

+ 3
- 3
rule/one_circles/one_circles_public_platoon_give_activty_coin.go 查看文件

@@ -131,9 +131,9 @@ func SettlementPublicGiveActivityCoin(engine *xorm.Engine, masterId string, uid
func CalcUserContinuousDailyActivityDays(engine *xorm.Engine, masterId string, uid int, startDate string, endDate string) (err error, days int, isContinuousDailyActivity bool) {
startAt, err := time.ParseInLocation("2006-01-02", startDate, time.Local) //起始时间
endAt, err := time.ParseInLocation("2006-01-02", endDate, time.Local) //起始时间
var list []model.OneCirclesGreenEnergySignIn
err = engine.Where("start_time >= ?", startAt.Format("2006-01-02 15:04:05")).
And("start_time < ?", endAt.Format("2006-01-02 15:04:05")).
var list []model.OneCirclesUserActivity
err = engine.Where("date >= ?", startAt.Format("2006-01-02")).
And("date < ?", endAt.Format("2006-01-02")).
And("uid =?", uid).Find(&list)
if err != nil {
fmt.Println("err:::::1111", err)


Loading…
取消
儲存