定制 ingenius/orders 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ingenius/orders

最新稳定版本:1.6.0

Composer 安装命令:

composer require ingenius/orders

包简介

Ingenius Orders Package

README 文档

README

This package provides order management functionality for the Ingenius platform.

Features

  • Order creation and management
  • Order status transitions
  • Extensible order processing through extensions
  • Multi-tenancy support

Installation

Add the package to your project's composer.json:

"require": {
    "ingenius/orders": "*"
}

Or install via Composer:

composer require ingenius/orders

Configuration

Publish the configuration files:

php artisan vendor:publish --provider="Ingenius\Orders\Providers\OrdersServiceProvider" --tag="orders-config"

Environment Variables

PRODUCT_MODEL=Ingenius\Products\Models\Product

Note: For backward compatibility, ORDERS_PRODUCT_MODEL is still supported but PRODUCT_MODEL is preferred as it's used across all packages.

Usage

Creating an Order

use Ingenius\Orders\Actions\CreateOrderAction;
use Ingenius\Orders\Http\Requests\CreateOrderRequest;

class YourController
{
    public function store(CreateOrderRequest $request, CreateOrderAction $action)
    {
        $order = $action->handle($request);
        
        return response()->json([
            'data' => $order,
            'message' => 'Order created successfully'
        ]);
    }
}

Changing Order Status

use Ingenius\Orders\Actions\ChangeOrderStatusAction;

$action = app(ChangeOrderStatusAction::class);
$order = $action->handle($orderId, 'completed');

Extending Order Processing

You can extend the order processing by creating a class that implements the OrderExtensionInterface or extends the BaseOrderExtension class:

use Ingenius\Orders\Extensions\BaseOrderExtension;
use Ingenius\Orders\Models\Order;

class YourOrderExtension extends BaseOrderExtension
{
    public function processOrder(Order $order, array $validatedData, array &$context): array
    {
        // Your custom processing logic
        
        return [
            'custom_data' => 'value'
        ];
    }
    
    public function calculateSubtotal(Order $order, float $currentSubtotal, array &$context): float
    {
        // Your custom subtotal calculation logic
        
        return $currentSubtotal + 500; // Add $5.00 to the subtotal
    }
    
    public function getPriority(): int
    {
        return 10; // Lower numbers run first
    }
}

Then register your extension in a service provider:

use Ingenius\Orders\Services\OrderExtensionManager;

public function boot()
{
    $this->app->resolving(OrderExtensionManager::class, function ($manager) {
        $manager->register(new YourOrderExtension());
    });
}

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 55
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-24