diff --git a/contract/Forest/ForestContract_Buyers.cs b/contract/Forest/ForestContract_Buyers.cs index 001a606..d3f00f3 100644 --- a/contract/Forest/ForestContract_Buyers.cs +++ b/contract/Forest/ForestContract_Buyers.cs @@ -230,7 +230,7 @@ public override Empty BatchBuyNow(BatchBuyNowInput input) var userBalanceDic = new Dictionary(); var failPriceDic = new Dictionary(); var listOwnerAllowanceDic = new Dictionary(); - + var batchDealAmount = 0l; foreach (var fixPrice in input.FixPriceList) { Assert(fixPrice.Quantity > 0, "Invalid param Quantity."); @@ -247,7 +247,8 @@ public override Empty BatchBuyNow(BatchBuyNowInput input) Quantity = fixPrice.Quantity, Price = fixPrice.Price, StartTime = fixPrice.StartTime - }, userBalanceDic, failPriceDic, listOwnerAllowanceDic); + }, userBalanceDic, failPriceDic, listOwnerAllowanceDic, out var dealTotalAmount); + batchDealAmount += dealTotalAmount; } Context.Fire(new BatchBuyNowResult @@ -257,7 +258,8 @@ public override Empty BatchBuyNow(BatchBuyNowInput input) FailPriceList = new FailPriceList() { Value = { failPriceDic?.Values?.ToList() } - } + }, + TotalDealAmountPrice = batchDealAmount }); return new Empty(); @@ -266,8 +268,10 @@ public override Empty BatchBuyNow(BatchBuyNowInput input) private void SingleMakeOfferForBatchBuyNow(string symbol, FixPrice inputFixPrice , Dictionary userBalanceDic , Dictionary failPriceDic - , Dictionary listOwnerAllowanceDic) + , Dictionary listOwnerAllowanceDic, + out long dealTotalAmount) { + dealTotalAmount = 0; var nftInfo = State.TokenContract.GetTokenInfo.Call(new GetTokenInfoInput { Symbol = symbol, @@ -308,8 +312,8 @@ private void SingleMakeOfferForBatchBuyNow(string symbol, FixPrice inputFixPrice var listedNftInfo = affordableNftInfoList[dealResult.Index]; TryDealWithFixedPriceForBatch(sender, symbol, inputFixPrice, dealResult - , listedNftInfo, userBalanceDic, out var dealQuantity,nftInfo.Decimals); - + , listedNftInfo, userBalanceDic, out var dealQuantity,nftInfo.Decimals, out var dealAmount); + dealTotalAmount += dealAmount; long realFail = dealResult.Quantity - dealQuantity; if (realFail > 0) { @@ -689,7 +693,7 @@ private bool TryDealWithFixedPrice(Address sender, MakeOfferInput input, DealRes /// Sender is buyer. /// private bool TryDealWithFixedPriceForBatch(Address sender, string symbol, FixPrice input, DealResult dealResult, - ListedNFTInfo listedNftInfo, Dictionary userBalanceDic ,out long actualQuantity,int decimals) + ListedNFTInfo listedNftInfo, Dictionary userBalanceDic ,out long actualQuantity,int decimals, out long dealAmount) { var userBalanceKey = symbol + input.OfferTo; long senderBalanceCount; @@ -711,6 +715,7 @@ private bool TryDealWithFixedPriceForBatch(Address sender, string symbol, FixPri if (senderBalanceCount== 0) { actualQuantity = 0; + dealAmount = 0; return false; } var usePrice = input.Price.Clone(); @@ -720,6 +725,7 @@ private bool TryDealWithFixedPriceForBatch(Address sender, string symbol, FixPri if (actualQuantity == 0) { + dealAmount = 0; return false; } @@ -727,6 +733,7 @@ private bool TryDealWithFixedPriceForBatch(Address sender, string symbol, FixPri userBalanceDic[userBalanceKey]=senderBalanceCount; var totalAmount = usePrice.Amount.Mul(NumberHelper.DivideByPowerOfTen(actualQuantity, decimals)); + dealAmount = totalAmount; PerformDeal(new PerformDealInput { NFTFrom = input.OfferTo, diff --git a/protobuf/forest_contract.proto b/protobuf/forest_contract.proto index 3b37426..fbb3026 100755 --- a/protobuf/forest_contract.proto +++ b/protobuf/forest_contract.proto @@ -325,6 +325,7 @@ message BatchBuyNowResult{ string symbol = 1; bool all_success_flag = 2; FailPriceList fail_price_list = 3; + int64 total_deal_amount_price = 4; } message FailPriceList {