fix: purchasing from client-side vendors
This commit is contained in:
parent
79299db475
commit
332389ccd8
@ -50,23 +50,24 @@ export const handlePurchase = async (
|
|||||||
const inventoryChanges: IInventoryChanges = {};
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
if (purchaseRequest.PurchaseParams.Source == 7) {
|
if (purchaseRequest.PurchaseParams.Source == 7) {
|
||||||
const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
|
const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
|
||||||
if (!manifest) {
|
if (manifest) {
|
||||||
throw new Error(`unknown vendor id: ${purchaseRequest.PurchaseParams.SourceId!}`);
|
const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }).ItemId;
|
||||||
|
const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId);
|
||||||
|
if (!offer) {
|
||||||
|
throw new Error(`unknown vendor offer: ${ItemId}`);
|
||||||
|
}
|
||||||
|
if (offer.ItemPrices) {
|
||||||
|
await handleItemPrices(
|
||||||
|
accountId,
|
||||||
|
offer.ItemPrices,
|
||||||
|
purchaseRequest.PurchaseParams.Quantity,
|
||||||
|
inventoryChanges
|
||||||
|
);
|
||||||
|
}
|
||||||
|
purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier;
|
||||||
|
} else if (!ExportVendors[purchaseRequest.PurchaseParams.SourceId!]) {
|
||||||
|
throw new Error(`unknown vendor: ${purchaseRequest.PurchaseParams.SourceId!}`);
|
||||||
}
|
}
|
||||||
const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }).ItemId;
|
|
||||||
const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId);
|
|
||||||
if (!offer) {
|
|
||||||
throw new Error(`unknown vendor offer: ${ItemId}`);
|
|
||||||
}
|
|
||||||
if (offer.ItemPrices) {
|
|
||||||
await handleItemPrices(
|
|
||||||
accountId,
|
|
||||||
offer.ItemPrices,
|
|
||||||
purchaseRequest.PurchaseParams.Quantity,
|
|
||||||
inventoryChanges
|
|
||||||
);
|
|
||||||
}
|
|
||||||
purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const purchaseResponse = await handleStoreItemAcquisition(
|
const purchaseResponse = await handleStoreItemAcquisition(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user