Ver a proveniência

add 区块星链

tags/v2.2.8
DengBiao há 2 anos
ascendente
cometimento
3b01dee9e8
2 ficheiros alterados com 24 adições e 4 eliminações
  1. +3
    -0
      md/block_star_chain.go
  2. +21
    -4
      rule/block_star_chain_settlement.go

+ 3
- 0
md/block_star_chain.go Ver ficheiro

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

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

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

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

+ 21
- 4
rule/block_star_chain_settlement.go Ver ficheiro

@@ -722,22 +722,39 @@ func DealLotteryDraw(session *xorm.Session, req md.DealLotteryDrawReq) (err erro
_ = session.Rollback()
return err
}
//2、销毁
rewardValue, _ := decimal.NewFromString(req.Amount)
rewardValue = rewardValue.Mul(decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(blockStarChain.LotteryDrawDestroyCoinRate) / 100))
platformGuidePriceForCoin, _ := decimal.NewFromString(blockStarChain.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 {
_ = session.Rollback()
return err
}

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

return nil
}

Carregando…
Cancelar
Guardar