瀏覽代碼

update 区块星链

tags/v3.0.0
DengBiao 2 年之前
父節點
當前提交
66d0712dff
共有 2 個文件被更改,包括 16 次插入10 次删除
  1. +1
    -1
      md/block_star_chain.go
  2. +15
    -9
      rule/block_star_chain_settlement.go

+ 1
- 1
md/block_star_chain.go 查看文件

@@ -6,7 +6,7 @@ const (
)

const (
RedisDataBase = 2 //TODO::区块星链的缓存统一存入redis 2 号库
RedisDataBase = 0 //TODO::区块星链的缓存统一存入redis 2 号库
UserVirtualAmountRedisKey = "%s:user_virtual_amount:%d:user:%d"
)



+ 15
- 9
rule/block_star_chain_settlement.go 查看文件

@@ -220,9 +220,10 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub
amount := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(item.Amount)) //用户贡献值余额
getCoin := amount.Div(sumStaticValue).Mul(publishCoinValue) //得到的区块币
needDestroyContribution := getCoin.Mul(platformGuidePriceForCoinValue) //需销毁贡献值

//3.1判断静态贡献值是否足够
if needDestroyContribution.GreaterThan(amount) {
//TODO::公式【得到的区块币 - ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】
//TODO::公式【得到的区块币 = ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】
tempCoin := (needDestroyContribution.Sub(amount)).Div(platformGuidePriceForCoinValue)
getCoin = getCoin.Sub(tempCoin)
unassignedTotalCoin.Add(tempCoin)
@@ -253,7 +254,7 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub
OrdId: "",
CoinId: chain.Coin2,
Uid: item.Uid,
Amount: zhios_order_relate_utils.StrToFloat64(getCoin.String()),
Amount: zhios_order_relate_utils.StrToFloat64(needDestroyContribution.String()),
})
if err != nil {
return err, unassignedTotalCoinValue
@@ -287,8 +288,8 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu
}
sumStaticValue := decimal.NewFromFloat(sumStatic)

//2、查询出所有拥有态贡献值的用户
err = session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin3).And("amount > 0").Find(&userVirtualAmounts)
//2、查询出所有拥有态贡献值的用户
err = session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin2).And("amount > 0").Find(&userVirtualAmounts)
if err != nil {
return err, unassignedTotalCoinValue
}
@@ -303,7 +304,7 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu
//TODO::公式【得到的区块币 - ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】
tempCoin := (needDestroyContribution.Sub(amount)).Div(platformGuidePriceForCoinValue)
getCoin = getCoin.Sub(tempCoin)
unassignedTotalCoin.Add(tempCoin)
unassignedTotalCoin.Add(getCoin)
needDestroyContribution = amount
}

@@ -331,7 +332,7 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu
OrdId: "",
CoinId: chain.Coin2,
Uid: item.Uid,
Amount: zhios_order_relate_utils.StrToFloat64(getCoin.String()),
Amount: zhios_order_relate_utils.StrToFloat64(needDestroyContribution.String()),
})
if err != nil {
return err, unassignedTotalCoinValue
@@ -339,8 +340,10 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu
}

//4、处理未分配完的区块币-动态区
unassignedTotalCoinValue = zhios_order_relate_utils.StrToFloat64(unassignedTotalCoin.String())
if unassignedTotalCoinValue > 0 {
//unassignedTotalCoinValue = zhios_order_relate_utils.StrToFloat64(unassignedTotalCoin.String())
if publishCoinValue.GreaterThan(unassignedTotalCoin) {
//if unassignedTotalCoinValue > 0 {
unassignedTotalCoinValue, _ = publishCoinValue.Sub(unassignedTotalCoin).Float64()
err := DealDestroyCoin(session, int(enum.DynamicallyUnallocatedAndDestroy), unassignedTotalCoinValue, enum.DynamicallyUnallocatedAndDestroy.String(), &chain)
if err != nil {
return err, unassignedTotalCoinValue
@@ -675,6 +678,7 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) {
userVirtualCoinFlow.Title = req.Title
userVirtualCoinFlow.TransferType = req.TransferType
userVirtualCoinFlow.Uid = req.Uid
userVirtualCoinFlow.BeforeAmout = coinAmount
userVirtualCoinFlow.Amout = amountValue.String()
userVirtualCoinFlow.CreateTime = now

@@ -688,7 +692,9 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) {
err = errors.New("错误的kind类型")
return err
}

if zhios_order_relate_utils.StrToFloat64(userVirtualCoinFlow.AfterAmout) < 0 {
return errors.New("用户虚拟币积分不足,无法扣除。")
}
//3、插入 `user_virtual_coin_flow` 记录
_, err = db.UserVirtualCoinFlowInsert(session, &userVirtualCoinFlow)
if err != nil {


Loading…
取消
儲存