uru-ruru/nexway-dto
Composer 安装命令:
composer require uru-ruru/nexway-dto
包简介
DTOs for NexWay integrations
关键字:
README 文档
README
Models for NexWay integrations
Описание API - https://apidoc.nexway.store/docs/category/api-guides/index.html
Установка
composer require uru-ruru/nexway-dto
Использование
Добавление или обновление продукта:
$data = new ProductRequest(); if ($variant->getServiceCatalogueId()) { $data->setCatalogId($variant->getServiceCatalogueId()); } $data->setCustomerId($this->customerId); $data->setSellingStores([$this->storeId]); $data->setStatus($variantComplex->isActive() ? Status::ENABLED : Status::DISABLED); $data->setProductFamily($variant->position->getName()); $data->setPublisherRefId($variant->getId()); $data->setGenericName($variantComplex->getFullName()); $data->setType(ProductType::SOFTWARE); $data->setBusinessSegment(BusinessSegment::B2B); $data->setSalesMode(SalesMode::STANDARD); if ($this->fulfilmentTemplateId) { $data->setFulfillmentTemplate($this->fulfilmentTemplateId); } $prices = new Prices(); $prices->setDefaultCurrency(self::DEFAULT_CURRENCY); $priceByCountryByCurrency = new PriceByCountryByCurrency(); $priceByCountryByCurrency->setCurrency(self::DEFAULT_CURRENCY); $priceByCountryByCurrency->setValue($variantComplex->getPriceUser()); $prices->setPriceByCountryByCurrency($priceByCountryByCurrency); $data->setPrices($prices); $data->setLifeTime(self::DEFAULT_LIFETIME); // товар с подпиской if ($variant->isSubscribeExist()) { $data->setLifeTime($variant->getSubscribe()->subscriptionType?->getPeriod()); $data->setSubscriptionTemplate(SubscriptionTemplate::getTemplateForLifetime($variant->getSubscribe()->subscriptionType?->getPeriod())); } // output to curl echo json_encode($data);
Добавление описания товара:
$data = new ProductDescriptionRequest(); $data->setId($variant->getServiceDescriptionId()); $data->setCustomerId($this->customerId); if ($variant->getServiceCatalogueId()) { $data->setCatalogId($variant->getServiceCatalogueId()); } $data->setDescription($variantComplex->getFullName()); if ($variant->getPreviewText()) { $data->setDescription($variant->getPreviewText()); } if ($variant->getDetailText()) { $data->setDescription($variant->getDetailText()); } $data->setFallbackLocale(self::DEFAULT_LOCALE); $data->setMarketingName($variantComplex->getFullName()); $data->addLocalizedMarketingName(self::DEFAULT_LOCALE, $variantComplex->getFullName()); if ('' !== $variant->getDetailText()) { $data->addLocalizedLongDesc(self::DEFAULT_LOCALE, $variant->getDetailText()); } if ('' !== $variant->getPreviewText()) { $data->addLocalizedShortDesc(self::DEFAULT_LOCALE, $variant->getPreviewText()); }
Создание корзины:
$data = new CartRequest(); $data->setLocale(self::DEFAULT_LOCALE); $data->setStoreId($this->storeId); $data->setHideCrossSell(true); $data->setHideUpSell(true); $externalContext = new ExternalContext(); $externalContext->setOrderId($order->getId()); foreach ($order->getBasket()->getBasketItems() as $basketItem) { /** @var BasketItem $basketItem */ $variant = $basketItem->getVariantComplex()->getVariant(); if ($variant->isSubscribe() && !$basketItem->getPropertySmuaId()) { continue; } $item = new CartRequest\Products(); $item->setId($variant->getServiceId()); $item->setQuantity($basketItem->getQuantity()); $item->setCurrency(self::DEFAULT_CURRENCY); $item->setOfferId($order->getId()); $item->setOfferLineId($basketItem->getId()); $item->setRemotePrice(true); $data->addWantedProduct($item); $externalBasketItem = new BasketItems(); $externalBasketItem->setItemId($basketItem->getId()); $externalBasketItem->setQuantity($basketItem->getQuantity()); $externalBasketItem->setPrice($basketItem->getPrice()); $externalContext->addBasketItem($externalBasketItem); } $data->setExternalContext($this->cryptService->encrypt($externalContext, true)); $user = User::getById($order->getUserId()); $endUser = new CartRequest\EndUser(); $endUser->setFirstName($user->getFirstName() ?? ''); $endUser->setLastName($user->getLastName() ?? ''); $company = new CartRequest\Company(); $company->setCompanyName($user->getCompanyName() ?? ''); $endUser->setCompany($company); $endUser->setCity($user->getBillingAddressCity() ?? ''); $endUser->setEmail($user->getEmail() ?? ''); $endUser->setLocale(self::DEFAULT_LOCALE); $endUser->setZipCode($user->getBillingAddressCode() ?? ''); $endUser->setCountry($user->getISOCountryCode() ?? ''); $endUser->setStreetAddress($user->getBillingAddressStreet() ?? ''); $data->setEndUser($endUser); if ($order->getCountry()) { $data->setCountry($order->getCountry()->getISOCountryCode() ?? ''); } // output to curl echo json_encode($data);
uru-ruru/nexway-dto 适用场景与选型建议
uru-ruru/nexway-dto 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.28k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「models」 「integration」 「dto」 「nexway」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 uru-ruru/nexway-dto 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 uru-ruru/nexway-dto 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 uru-ruru/nexway-dto 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Wordpress Query Builder class library for custom models and data querying.
PHP library for the MUMSYS project
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
A simple library that allows transform any kind of data to native php data or whatever
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
A Laravel package for managing model drafts.
统计信息
- 总下载量: 1.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-28