softrang/parcel-helper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

softrang/parcel-helper

Composer 安装命令:

composer require softrang/parcel-helper

包简介

A small helper to place orders using API keys from env/config.

README 文档

README

A simple, developer-friendly Parcel Helper for Laravel 12+ to easily create and manage consignments with SteadFast and other supported services. created by Softrang.

Features

  • Simple API for creating parcels/orders.
  • Supports SteadFast and other courier services.
  • Automatically stores consignment details in your database.
  • Clean, professional, and Laravel-native.

Requirements

  • PHP 8.1+
  • Laravel 12+
  • Composer

Installation

Install via Composer

composer require softrang/parcel-helper

Publish the config:

php artisan vendor:publish --tag= parcel-helpar

Environment Configuration

Add your API keys to your .env file:

PACKZY_API_KEY=your_api_key
PACKZY_SECRET_KEY=your_secret_key

Usage

Sample Controller

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Softrang\ParcelHelper\Facades\ParcelHelper;
use App\Models\Consignment;

    public function sendSteadFast(Request $request)
    {
        // Validate request
        $validated = $request->validate([
            'invoice' => 'required|string|max:50',
            'name' => 'required|string|max:255',
            'phone' => 'required|string|max:20',
            'address' => 'required|string|max:500',
            'amount' => 'required|numeric|min:0',
        ]);

        try {
            // Create order via ParcelHelper
            $response = ParcelHelper::steadfastCreateOrder([
                'invoice' => $validated['invoice'],
                'recipient_name' => $validated['name'],
                'recipient_phone' => $validated['phone'],
                'recipient_address' => $validated['address'],
                'cod_amount' => $validated['amount'],
            ]);

            if ($response['status'] === 200 && isset($response['consignment'])) {
                $c = $response['consignment'];

                // Save consignment in DB
                $consignment = Consignment::create([
                    'consignment_id' => $c['consignment_id'],
                    'invoice' => $c['invoice'],
                    'tracking_code' => $c['tracking_code'],
                    'recipient_name' => $c['recipient_name'],
                    'recipient_phone' => $c['recipient_phone'],
                    'recipient_address' => $c['recipient_address'],
                    'cod_amount' => $c['cod_amount'],
                    'status' => $c['status'],
                ]);

                return response()->json([
                    'success' => true,
                    'message' => 'Consignment created and saved successfully.',
                    'data' => $consignment,
                ], 201);
            }

            return response()->json([
                'success' => false,
                'message' => 'Failed to create consignment from API.',
                'api_response' => $response,
            ], 400);

        } catch (\Exception $e) {
            return response()->json([
                'success' => false,
                'message' => 'An error occurred while processing your request.',
                'error' => $e->getMessage(),
            ], 500);
        }
    }

Database Setup

Ensure you have a consignments table:

Schema::create('consignments', function (Blueprint $table) {
    $table->id();
    $table->string('consignment_id')->unique();
    $table->string('invoice');
    $table->string('tracking_code')->nullable();
    $table->string('recipient_name');
    $table->string('recipient_phone');
    $table->text('recipient_address');
    $table->decimal('cod_amount', 10, 2)->default(0);
    $table->string('status')->nullable();
    $table->timestamps();
});

softrang/parcel-helper 适用场景与选型建议

softrang/parcel-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 softrang/parcel-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 softrang/parcel-helper 我们能提供哪些服务?
定制开发 / 二次开发

基于 softrang/parcel-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-06