@@ -0,0 +1,153 @@ | |||
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" | |||
) | |||
// BatchSelectBlockStarChainRewardRecords 批量查询数据 TODO::和下面的方法重复了,建议采用下面的 `BlockStarChainRewardRecordsFindByParams` 方法 | |||
func BatchSelectBlockStarChainRewardRecords(Db *xorm.Engine, params map[string]interface{}) (*[]model.BlockStarChainRewardRecords, error) { | |||
var BlockStarChainRewardRecordsData []model.BlockStarChainRewardRecords | |||
if err := Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]). | |||
Find(&BlockStarChainRewardRecordsData); err != nil { | |||
return nil, zhios_order_relate_logx.Warn(err) | |||
} | |||
return &BlockStarChainRewardRecordsData, nil | |||
} | |||
// BlockStarChainRewardRecordsInsert 插入单条数据 | |||
func BlockStarChainRewardRecordsInsert(Db *xorm.Engine, BlockStarChainRewardRecords *model.BlockStarChainRewardRecords) (int64, error) { | |||
_, err := Db.InsertOne(BlockStarChainRewardRecords) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return BlockStarChainRewardRecords.Id, nil | |||
} | |||
// BatchAddBlockStarChainRewardRecords 批量新增数据 | |||
func BatchAddBlockStarChainRewardRecords(Db *xorm.Engine, BlockStarChainRewardRecordsData []*model.BlockStarChainRewardRecords) (int64, error) { | |||
affected, err := Db.Insert(BlockStarChainRewardRecordsData) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func GetBlockStarChainRewardRecordsCount(Db *xorm.Engine) int { | |||
var BlockStarChainRewardRecords model.BlockStarChainRewardRecords | |||
session := Db.Where("") | |||
count, err := session.Count(&BlockStarChainRewardRecords) | |||
if err != nil { | |||
return 0 | |||
} | |||
return int(count) | |||
} | |||
// BlockStarChainRewardRecordsDelete 删除记录 | |||
func BlockStarChainRewardRecordsDelete(Db *xorm.Engine, id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.BlockStarChainRewardRecords{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.BlockStarChainRewardRecords{}) | |||
} | |||
} | |||
// BlockStarChainRewardRecordsUpdate 更新记录 | |||
func BlockStarChainRewardRecordsUpdate(session *xorm.Session, id interface{}, BlockStarChainRewardRecords *model.BlockStarChainRewardRecords, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = session.Where("id=?", id).Cols(forceColums...).Update(BlockStarChainRewardRecords) | |||
} else { | |||
affected, err = session.Where("id=?", id).Update(BlockStarChainRewardRecords) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
// BlockStarChainRewardRecordsGetOneByParams 通过传入的参数查询数据(单条) | |||
func BlockStarChainRewardRecordsGetOneByParams(session *xorm.Session, params map[string]interface{}) (*model.BlockStarChainRewardRecords, error) { | |||
var m model.BlockStarChainRewardRecords | |||
var query = fmt.Sprintf("%s =?", params["key"]) | |||
if has, err := session.Where(query, params["value"]).Get(&m); err != nil || has == false { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
// BlockStarChainRewardRecordsFindByParams 通过传入的参数查询数据(多条) | |||
func BlockStarChainRewardRecordsFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[]model.BlockStarChainRewardRecords, error) { | |||
var m []model.BlockStarChainRewardRecords | |||
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 BlockStarChainRewardRecordsFindByParamsByPage(Db *xorm.Engine, params map[string]interface{}, page, pageSize int) (*[]model.BlockStarChainRewardRecords, error) { | |||
var m []model.BlockStarChainRewardRecords | |||
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 | |||
} | |||
} | |||
} |
@@ -7,9 +7,9 @@ import ( | |||
type BlockStarChain struct { | |||
Id int `json:"id" xorm:"not null pk autoincr comment('主键id') INT(11)"` | |||
IsUse int `json:"is_use" xorm:"not null default 0 comment('是否开启(否:0;是:1)') TINYINT(1)"` | |||
Coin1 int `json:"coin_1" xorm:"not null default 0 comment('coinId_1(类似于区块币)') INT(11)"` | |||
Coin2 int `json:"coin_2" xorm:"not null default 0 comment('coinId_2(类似于静态贡献值)') INT(11)"` | |||
Coin3 int `json:"coin_3" xorm:"not null default 0 comment('coinId_3(类似于动态贡献值)') INT(11)"` | |||
Coin1 int `json:"coin_1" xorm:"coin_1 not null default 0 comment('coinId_1(类似于区块币)') INT(11)"` | |||
Coin2 int `json:"coin_2" xorm:"coin_2 not null default 0 comment('coinId_2(类似于静态贡献值)') INT(11)"` | |||
Coin3 int `json:"coin_3" xorm:"coin_3 not null default 0 comment('coinId_3(类似于动态贡献值)') INT(11)"` | |||
InitialEverydayPublishCoin string `json:"initial_everyday_publish_coin" xorm:"not null default 0.0000000000 comment('初始每日区块币发行数量') DECIMAL(28,10)"` | |||
NowEverydayPublishCoin string `json:"now_everyday_publish_coin" xorm:"not null default 0.0000000000 comment('当前每日区块币发行数量') DECIMAL(28,10)"` | |||
TodayPublishCoin string `json:"today_publish_coin" xorm:"not null default 0.0000000000 comment('今日区块币发行数量(若为0,则按当前每日区块币发行数量)') DECIMAL(28,10)"` | |||
@@ -0,0 +1,22 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type BlockStarChainRewardRecords struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
CoinIdForReward int `json:"coin_id_for_reward" xorm:"not null default 0 comment('打赏-虚拟币id') INT(11)"` | |||
CoinIdForDestroyAndDistribute int `json:"coin_id_for_destroy_and_distribute" xorm:"not null default 0 comment('销毁&派发-虚拟币id') INT(11)"` | |||
Amount string `json:"amount" xorm:"not null default 0.0000000000 comment('消费金额') DECIMAL(28,10)"` | |||
RewardUid int `json:"reward_uid" xorm:"not null default 0 comment('打赏uid') INT(11)"` | |||
BeRewardUid int `json:"be_reward_uid" xorm:"not null default 0 comment('被打赏uid') INT(11)"` | |||
RewardAccountPhone int64 `json:"reward_account_phone" xorm:"not null default 0 comment('被打赏账号') BIGINT(20)"` | |||
RewardValue string `json:"reward_value" xorm:"not null default 0.0000000000 comment('打赏值') DECIMAL(28,10)"` | |||
DeductionCoin string `json:"deduction_coin" xorm:"not null default 0.0000000000 comment('扣除虚拟币值') DECIMAL(28,10)"` | |||
DestroyCoinForSystem string `json:"destroy_coin_for_system" xorm:"not null default 0.0000000000 comment('销毁虚拟币-系统') DECIMAL(28,10)"` | |||
DistributeCoinForTeam string `json:"distribute_coin_for_team" xorm:"not null default 0.0000000000 comment('派发虚拟币-团队') DECIMAL(28,10)"` | |||
DestroyCoinForTeam string `json:"destroy_coin_for_team" xorm:"not null default 0.0000000000 comment('销毁虚拟币-团队') DECIMAL(28,10)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -17,15 +17,37 @@ const ( | |||
OtherTitleForUserVirtualCoinFlow = "区块星链-其他发放" | |||
StaticIssueAndDestroyStaticContributionTitleForUserVirtualCoinFlow = "区块星链-静态发放(销毁静态贡献值)" | |||
DynamicIssueAndDestroyStaticContributionTitleForUserVirtualCoinFlow = "区块星链-动态发放(销毁静态贡献值)" | |||
RegisterRewardTitleForUserVirtualCoinFlow = "区块星链-注册奖励" | |||
InviteRegisterRewardTitleForUserVirtualCoinFlow = "区块星链-邀请注册奖励" | |||
OfflineConsumeDirectPushRewardByUserTitleForUserVirtualCoinFlow = "区块星链-线下消费直推奖励(用户)" | |||
OfflineConsumeDirectPushRewardByBusinessTitleForUserVirtualCoinFlow = "区块星链-线下消费直推奖励(商家)" | |||
OfflineConsumeGroupRewardByUserTitleForUserVirtualCoinFlow = "区块星链-线下消费团队奖励(用户)" | |||
OfflineConsumeGroupRewardUnallocatedAndDestroyByUserTitleForUserVirtualCoinFlow = "区块星链-线下消费团队奖励未分配完销毁(用户)" | |||
OfflineConsumeGroupRewardByBusinessTitleForUserVirtualCoinFlow = "区块星链-线下消费团队奖励(商家)" | |||
OfflineConsumeGroupRewardUnallocatedAndDestroyByBusinessTitleForUserVirtualCoinFlow = "区块星链-线下消费团队奖励未分配完销毁(商家)" | |||
OnlineConsumeDirectPushRewardTitleForUserVirtualCoinFlow = "区块星链-线上消费直推奖励" | |||
OnlineConsumeGroupRewardTitleForUserVirtualCoinFlow = "区块星链-线上消费团队奖励" | |||
) | |||
const ( | |||
StaticAreaDistributionTransferTypeForUserVirtualCoinFlow = 100 | |||
DynamicAreaDistributionTransferTypeForUserVirtualCoinFlow = 101 | |||
StaticIssueAndDestroyStaticContributionTransferTypeForUserVirtualCoinFlow = 102 | |||
DynamicIssueAndDestroyStaticContributionTransferTypeForUserVirtualCoinFlow = 103 | |||
OperationCenterTransferTypeForUserVirtualCoinFlow = 104 | |||
OtherTransferTypeForUserVirtualCoinFlow = 105 | |||
StaticAreaDistributionTransferTypeForUserVirtualCoinFlow = 100 // 区块星链-静态区发放 | |||
DynamicAreaDistributionTransferTypeForUserVirtualCoinFlow = 101 // 区块星链-动态区发放 | |||
StaticIssueAndDestroyStaticContributionTransferTypeForUserVirtualCoinFlow = 102 // 区块星链-静态发放(销毁静态贡献值) | |||
DynamicIssueAndDestroyStaticContributionTransferTypeForUserVirtualCoinFlow = 103 // 区块星链-动态发放(销毁静态贡献值) | |||
OperationCenterTransferTypeForUserVirtualCoinFlow = 104 // 区块星链-运营中心发放 | |||
OtherTransferTypeForUserVirtualCoinFlow = 105 // 区块星链-其他发放 | |||
RegisterRewardTransferTypeForUserVirtualCoinFlow = 106 //区块星链-注册奖励 | |||
InviteRegisterRewardTransferTypeForUserVirtualCoinFlow = 107 //区块星链-邀请注册奖励 | |||
OfflineConsumeDirectPushRewardByUserTransferTypeForUserVirtualCoinFlow = 108 //区块星链-线下消费直推奖励(用户) | |||
OfflineConsumeDirectPushRewardByBusinessTransferTypeForUserVirtualCoinFlow = 109 //区块星链-线下消费直推奖励(商家) | |||
OfflineConsumeGroupRewardByUserTransferTypeForUserVirtualCoinFlow = 110 //区块星链-线下消费团队奖励(用户) | |||
OfflineConsumeGroupRewardUnallocatedAndDestroyByUserTransferTypeForUserVirtualCoinFlow = 111 //区块星链-线下消费团队奖励未分配完销毁(用户) | |||
OfflineConsumeGroupRewardByBusinessTransferTypeForUserVirtualCoinFlow = 112 //区块星链-线下消费团队奖励(商家) | |||
OfflineConsumeGroupRewardUnallocatedAndDestroyByBusinessTransferTypeForUserVirtualCoinFlow = 113 //区块星链-线下消费团队奖励未分配完销毁(商家) | |||
OnlineConsumeDirectPushRewardTransferTypeForUserVirtualCoinFlow = 114 //区块星链-线上消费直推奖励 | |||
OnlineConsumeGroupRewardTypeForUserVirtualCoinFlow = 115 //区块星链-线上消费团队奖励 | |||
) | |||
const DealUserCoinRequestIdPrefix = "%s:block_star_chain_deal_user_coin:%d:uid:%d" | |||