|
|
@@ -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 |
|
|
|
} |