喜爱鹿的/gift-card-proportional-value

GiftCardProportionalValue 模块。

2.0.0 2023-01-24 12:59 UTC

This package is auto-updated.

Last update: 2024-08-27 12:37:13 UTC


README

CI license

此包将安装一个新的表 foo_proportional_gift_card_value。默认情况下,此模块仅提供表和执行插件的功能,没有插件则不执行任何操作。

可能的插件将提供在

  • "fond-of-oryx/gift-card-proportional-value-no-payment-connector"
  • "fond-of-oryx/gift-card-proportional-value-payone-connector"

并且可以这样使用

<?php

namespace Pyz\Zed\GiftCardProportionalValue;

use FondOfOryx\Zed\GiftCardProportionalValue\GiftCardProportionalValueDependencyProvider as FooGiftCardProportionalValueDependencyProvider;
use FondOfOryx\Zed\GiftCardProportionalValueNoPaymentConnector\Communication\Plugin\GiftCardProportionalValue\NoPaymentProportionalValueCalculationPlugin;
use FondOfOryx\Zed\GiftCardProportionalValuePayoneConnector\Communication\Plugin\GiftCardProportionalValue\PayoneProportionalValueCalculationPlugin;

class GiftCardProportionalValueDependencyProvider extends FooGiftCardProportionalValueDependencyProvider
{
    /**
     * @return array|\FondOfOryx\Zed\GiftCardProportionalValueExtension\Dependency\Plugin\ProportionalValueCalculationPluginInterface[]
     */
    protected function getProportionalValueCalulationPlugins(): array
    {
        $plugins = [
            new PayoneProportionalValueCalculationPlugin(),
            new NoPaymentProportionalValueCalculationPlugin(),
        ];

        return array_merge(parent::getProportionalValueCalulationPlugins(), $plugins);
    }

}

安装

composer require fond-of-oryx/gift-card-proportional-value

配置

将 GiftCardProportionalValue 命令和条件注入 OMS。在 config_default.php 中添加

$config[KernelConstants::DEPENDENCY_INJECTOR_ZED] = [
    'Payment' => [
        ...
    ],
    'Oms' => [
        ...
        'GiftCardProportionalValue',
    ],
];

另一种方法是手动在 pyz OmsDependencyProvider 中添加它们

    /**
     * @param \Spryker\Zed\Kernel\Container $container
     *
     * @return \Spryker\Zed\Kernel\Container
     */
    public function provideBusinessLayerDependencies(Container $container)
    {
        $container = parent::provideBusinessLayerDependencies($container);

        $container->extend(static::CONDITION_PLUGINS, static function (ConditionCollectionInterface $conditionCollection) {
            ...
            $conditionCollection->add(new HasRedeemedGiftCardsConditionPlugin(), 'GiftCardProportionalValue/HasRedeemedGiftCards');

            return $conditionCollection;
        });

        $container->extend(self::COMMAND_PLUGINS, static function (CommandCollectionInterface $commandCollection) {
            ...
            $commandCollection->add(new GiftCardProportionalValueCalculatorCommandPlugin(), 'GiftCardProportionalValue/CalculateProportionalValues');

            return $commandCollection;
        });

        return $container;
    }

更新 oms 工作流程

如下。

config\zed\oms 中的 GiftCardProportionalValue01.xml

<?xml version="1.0"?>
<statemachine
    xmlns="spryker:oms-01"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="spryker:oms-01 http://static.spryker.com/oms-01.xsd"
>

    <process name="GiftCardProportionalValue01">
        <states>
            <state name="calculate proportional gift card values" display="oms.state.calculate-gift-card-proportional-values"/>
            <state name="gift card proportional values calculated" display="oms.state.gift-card-proportional-values-calculated"/>
        </states>

        <transitions>
            <transition condition="GiftCardProportionalValue/HasRedeemedGiftCards">
                <source>order confirmation sent</source>
                <target>calculate proportional gift card values</target>
                <event>wait for export</event>
            </transition>

            <transition>
                <source>calculate proportional gift card values</source>
                <target>gift card proportional values calculated</target>
                <event>calculate gift card proportional values</event>
            </transition>

            <transition>
                <source>gift card proportional values calculated</source>
                <target>export pending</target>
                <event>wait for export</event>
            </transition>

        </transitions>

        <events>
            <event name="calculate gift card proportional values" onEnter="true" command="GiftCardProportionalValue/CalculateProportionalValues"/>
            <event name="wait for export" onEnter="true"/>
        </events>
    </process>
</statemachine>

但请注意,这应该根据您的状态和事件进行编辑!