From 3b01dee9e8ce2011fca2618ca3ca999566d23b08 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 7 Sep 2022 17:29:20 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=8C=BA=E5=9D=97=E6=98=9F=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md/block_star_chain.go | 3 +++ rule/block_star_chain_settlement.go | 25 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/md/block_star_chain.go b/md/block_star_chain.go index 0e65b0b..517ab9e 100644 --- a/md/block_star_chain.go +++ b/md/block_star_chain.go @@ -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"` } diff --git a/rule/block_star_chain_settlement.go b/rule/block_star_chain_settlement.go index df461f0..ba86289 100644 --- a/rule/block_star_chain_settlement.go +++ b/rule/block_star_chain_settlement.go @@ -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 }