mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-23 04:29:38 +08:00
涉及库存的物品获取应该使用 Guid 而不是 ItemId
This commit is contained in:
parent
b4b099c5b0
commit
8c6d125c96
@ -1244,8 +1244,8 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
{
|
{
|
||||||
long offerId = DataRequest.GetDictionaryJsonObject<long>(requestData, OffersQuery.Column_Id);
|
long offerId = DataRequest.GetDictionaryJsonObject<long>(requestData, OffersQuery.Column_Id);
|
||||||
OfferActionType action = DataRequest.GetDictionaryJsonObject<OfferActionType>(requestData, "action");
|
OfferActionType action = DataRequest.GetDictionaryJsonObject<OfferActionType>(requestData, "action");
|
||||||
List<long> offerorItems = DataRequest.GetDictionaryJsonObject<List<long>>(requestData, "offerorItems") ?? [];
|
List<Guid> offerorItems = DataRequest.GetDictionaryJsonObject<List<Guid>>(requestData, "offerorItems") ?? [];
|
||||||
List<long> offereeItems = DataRequest.GetDictionaryJsonObject<List<long>>(requestData, "offereeItems") ?? [];
|
List<Guid> offereeItems = DataRequest.GetDictionaryJsonObject<List<Guid>>(requestData, "offereeItems") ?? [];
|
||||||
long userId = Server.User.Id;
|
long userId = Server.User.Id;
|
||||||
|
|
||||||
Offer? offer = SQLHelper.GetOffer(offerId);
|
Offer? offer = SQLHelper.GetOffer(offerId);
|
||||||
@ -1309,7 +1309,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
|
|
||||||
case OfferActionType.OffereeRevise:
|
case OfferActionType.OffereeRevise:
|
||||||
// 接收方修改报价
|
// 接收方修改报价
|
||||||
if (!isOfferor && (offer.Status == OfferState.Sent || offer.Status == OfferState.NegotiationAccepted))
|
if (!isOfferor && offer.NegotiatedTimes >= 3)
|
||||||
|
{
|
||||||
|
msg = "当前协商次数已达上限(3次),不允许接收方修改。";
|
||||||
|
}
|
||||||
|
else if (!isOfferor && (offer.Status == OfferState.Sent || offer.Status == OfferState.NegotiationAccepted))
|
||||||
{
|
{
|
||||||
// 备份
|
// 备份
|
||||||
SQLHelper.BackupOfferItem(offer);
|
SQLHelper.BackupOfferItem(offer);
|
||||||
@ -1329,7 +1333,7 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OfferActionType.OffereeSend:
|
case OfferActionType.OffereeSend:
|
||||||
if (!isOfferor && (offer.Status == OfferState.Sent || offer.Status == OfferState.Negotiating))
|
if (!isOfferor && (offer.Status == OfferState.OffereeConfirmed))
|
||||||
{
|
{
|
||||||
if (offer.NegotiatedTimes < 3)
|
if (offer.NegotiatedTimes < 3)
|
||||||
{
|
{
|
||||||
@ -1337,7 +1341,7 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
SQLHelper.UpdateOfferNegotiatedTimes(offerId, offer.NegotiatedTimes + 1);
|
SQLHelper.UpdateOfferNegotiatedTimes(offerId, offer.NegotiatedTimes + 1);
|
||||||
canProceed = true;
|
canProceed = true;
|
||||||
}
|
}
|
||||||
else msg = "协商次数已达上限(3次)。";
|
else msg = "当前协商次数已达上限(3次),不允许接收方发送。";
|
||||||
}
|
}
|
||||||
else msg = "当前状态不允许接收方修改。";
|
else msg = "当前状态不允许接收方修改。";
|
||||||
break;
|
break;
|
||||||
@ -1351,13 +1355,13 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
{
|
{
|
||||||
// 更新物品
|
// 更新物品
|
||||||
SQLHelper.DeleteOfferItemsByOfferId(offerId);
|
SQLHelper.DeleteOfferItemsByOfferId(offerId);
|
||||||
foreach (long itemId in offerorItems)
|
foreach (Guid itemGuid in offerorItems)
|
||||||
{
|
{
|
||||||
SQLHelper.AddOfferItem(offerId, offer.Offeror, itemId);
|
SQLHelper.AddOfferItem(offerId, offer.Offeror, itemGuid);
|
||||||
}
|
}
|
||||||
foreach (long itemId in offereeItems)
|
foreach (Guid itemGuid in offereeItems)
|
||||||
{
|
{
|
||||||
SQLHelper.AddOfferItem(offerId, offer.Offeree, itemId);
|
SQLHelper.AddOfferItem(offerId, offer.Offeree, itemGuid );
|
||||||
}
|
}
|
||||||
|
|
||||||
offer = SQLHelper.GetOffer(offerId);
|
offer = SQLHelper.GetOffer(offerId);
|
||||||
@ -1452,31 +1456,39 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
{
|
{
|
||||||
if (offer.Status == OfferState.Completed)
|
if (offer.Status == OfferState.Completed)
|
||||||
{
|
{
|
||||||
|
User offeree = Server.User;
|
||||||
User? offeror = SQLHelper.GetUserById(offer.Offeror);
|
User? offeror = SQLHelper.GetUserById(offer.Offeror);
|
||||||
if (offeror != null)
|
if (offeror != null)
|
||||||
{
|
{
|
||||||
foreach (Item item in offer.OffereeItems)
|
foreach (Guid itemGuid in offer.OffereeItems)
|
||||||
{
|
{
|
||||||
Item newItem = item.Copy();
|
if (offeree.Inventory.Items.FirstOrDefault(i => i.Guid == itemGuid) is Item item)
|
||||||
newItem.User = offeror;
|
{
|
||||||
newItem.IsSellable = false;
|
offeree.Inventory.Items.Remove(item);
|
||||||
newItem.IsTradable = false;
|
Item newItem = item.Copy();
|
||||||
newItem.NextSellableTime = DateTimeUtility.GetTradableTime();
|
newItem.User = offeror;
|
||||||
newItem.NextTradableTime = DateTimeUtility.GetTradableTime();
|
newItem.IsSellable = false;
|
||||||
offeror.Inventory.Items.Add(newItem);
|
newItem.IsTradable = false;
|
||||||
|
newItem.NextSellableTime = DateTimeUtility.GetTradableTime();
|
||||||
|
newItem.NextTradableTime = DateTimeUtility.GetTradableTime();
|
||||||
|
offeror.Inventory.Items.Add(newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (Guid itemGuid in offer.OfferorItems)
|
||||||
|
{
|
||||||
|
if (offeror.Inventory.Items.FirstOrDefault(i => i.Guid == itemGuid) is Item item)
|
||||||
|
{
|
||||||
|
offeror.Inventory.Items.Remove(item);
|
||||||
|
Item newItem = item.Copy();
|
||||||
|
newItem.User = offeree;
|
||||||
|
newItem.IsSellable = false;
|
||||||
|
newItem.IsTradable = false;
|
||||||
|
newItem.NextSellableTime = DateTimeUtility.GetTradableTime();
|
||||||
|
newItem.NextTradableTime = DateTimeUtility.GetTradableTime();
|
||||||
|
offeree.Inventory.Items.Add(newItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SQLHelper.UpdateInventory(offeror.Inventory);
|
SQLHelper.UpdateInventory(offeror.Inventory);
|
||||||
User offeree = Server.User;
|
|
||||||
foreach (Item item in offer.OfferorItems)
|
|
||||||
{
|
|
||||||
Item newItem = item.Copy();
|
|
||||||
newItem.User = offeree;
|
|
||||||
newItem.IsSellable = false;
|
|
||||||
newItem.IsTradable = false;
|
|
||||||
newItem.NextSellableTime = DateTimeUtility.GetTradableTime();
|
|
||||||
newItem.NextTradableTime = DateTimeUtility.GetTradableTime();
|
|
||||||
offeree.Inventory.Items.Add(newItem);
|
|
||||||
}
|
|
||||||
SQLHelper.UpdateInventory(offeree.Inventory);
|
SQLHelper.UpdateInventory(offeree.Inventory);
|
||||||
SQLHelper.Commit();
|
SQLHelper.Commit();
|
||||||
resultData.Add("offer", offer);
|
resultData.Add("offer", offer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user