Browse Source

add 区块星链

tags/v2.2.8
DengBiao 2 years ago
parent
commit
3b01dee9e8
2 changed files with 24 additions and 4 deletions
  1. +3
    -0
      md/block_star_chain.go
  2. +21
    -4
      rule/block_star_chain_settlement.go

+ 3
- 0
md/block_star_chain.go View File

@@ -29,6 +29,7 @@ const (
OfflineConsumeBeRewardTitleForUserVirtualCoinFlow = "区块星链-线下消费被打赏" OfflineConsumeBeRewardTitleForUserVirtualCoinFlow = "区块星链-线下消费被打赏"
OfflineConsumeRewardTitleForUserVirtualCoinFlow = "区块星链-线下消费打赏" OfflineConsumeRewardTitleForUserVirtualCoinFlow = "区块星链-线下消费打赏"
OfflineConsumeRewardTitleForMerchantVirtualCoinFlow = "区块星链-线下消费打赏(商家)" OfflineConsumeRewardTitleForMerchantVirtualCoinFlow = "区块星链-线下消费打赏(商家)"
GroupLotteryAndDestroyTitleForUserVirtualCoinFlow = "区块星链-自营拼团抽奖销毁"
) )


const ( const (
@@ -50,6 +51,7 @@ const (
OfflineConsumeBeRewardTransferTypeForUserVirtualCoinFlow = 114 //区块星链-线下消费被打赏 OfflineConsumeBeRewardTransferTypeForUserVirtualCoinFlow = 114 //区块星链-线下消费被打赏
OfflineConsumeRewardTransferTypeForUserVirtualCoinFlow = 115 //区块星链-线下消费打赏 OfflineConsumeRewardTransferTypeForUserVirtualCoinFlow = 115 //区块星链-线下消费打赏
OfflineConsumeRewardTransferTypeForMerchantVirtualCoinFlow = 116 //区块星链-线下消费打赏(商家) OfflineConsumeRewardTransferTypeForMerchantVirtualCoinFlow = 116 //区块星链-线下消费打赏(商家)
GroupLotteryAndDestroyTransferTypeForUserVirtualCoinFlow = 117 //区块星链-自营拼团抽奖销毁
) )


const DealUserCoinRequestIdPrefix = "%s:block_star_chain_deal_user_coin:%d:uid:%d" const DealUserCoinRequestIdPrefix = "%s:block_star_chain_deal_user_coin:%d:uid:%d"
@@ -69,6 +71,7 @@ type DealUserCoinReq struct {
} }


type DealLotteryDrawReq struct { type DealLotteryDrawReq struct {
Mid string `json:"mid"`
Uid int `json:"uid"` Uid int `json:"uid"`
Amount string `json:"amount"` Amount string `json:"amount"`
} }

+ 21
- 4
rule/block_star_chain_settlement.go View File

@@ -722,22 +722,39 @@ func DealLotteryDraw(session *xorm.Session, req md.DealLotteryDrawReq) (err erro
_ = session.Rollback() _ = session.Rollback()
return err return err
} }
//2、销毁
rewardValue, _ := decimal.NewFromString(req.Amount) rewardValue, _ := decimal.NewFromString(req.Amount)
rewardValue = rewardValue.Mul(decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(blockStarChain.LotteryDrawDestroyCoinRate) / 100)) rewardValue = rewardValue.Mul(decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(blockStarChain.LotteryDrawDestroyCoinRate) / 100))
platformGuidePriceForCoin, _ := decimal.NewFromString(blockStarChain.PlatformGuidePriceForCoin) platformGuidePriceForCoin, _ := decimal.NewFromString(blockStarChain.PlatformGuidePriceForCoin)
needDestroyCoin := rewardValue.Div(platformGuidePriceForCoin) //须销毁的米豆 needDestroyCoin := rewardValue.Div(platformGuidePriceForCoin) //须销毁的米豆
systemDestroyCoinValue, _ := needDestroyCoin.Float64() //系统销毁 区块币值
err = DealDestroyCoin(session, int(enum.GroupLotteryAndDestroy), systemDestroyCoinValue, enum.GroupLotteryAndDestroy.String(), blockStarChain)
destroyCoinValue, _ := needDestroyCoin.Float64() //系统销毁 区块币值

//2、用户扣除
err = DealUserCoin(session, md.DealUserCoinReq{
Kind: "sub",
Mid: req.Mid,
Title: md.GroupLotteryAndDestroyTitleForUserVirtualCoinFlow,
TransferType: md.GroupLotteryAndDestroyTransferTypeForUserVirtualCoinFlow,
OrdId: "",
CoinId: blockStarChain.Coin1,
Uid: req.Uid,
Amount: destroyCoinValue,
})
if err != nil {
_ = session.Rollback()
return err
}

//3、系统销毁
err = DealDestroyCoin(session, int(enum.GroupLotteryAndDestroy), destroyCoinValue, enum.GroupLotteryAndDestroy.String(), blockStarChain)
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
return err return err
} }

err = session.Commit() err = session.Commit()
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
return errors.New("事务提交失败") return errors.New("事务提交失败")
} }

return nil return nil
} }

Loading…
Cancel
Save