cable8mm/good-code
最新稳定版本:v2.8.1
Composer 安装命令:
composer create-project cable8mm/good-code
包简介
Create a general code specification for building a WMS (Warehouse Management System), and specify parsers and implementation guidelines.
README 文档
README
A robust code specification is crucial within the commercial market industry, especially for online stores like Amazon. The integration of online stores with Warehouse Management Systems (WMS) is essential as both systems handle extensive seller and product data. Therefore, we recommend implementing a solid structure and providing robust support for these systems.
These specifications cover a variety of online stores, including Coupang, 11th Street, Naver Storefarm, and many others for a while.
We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/good-code/ ❤️
Features
- Normal good code parser
- Gift good code parser
- Set good code parser
- Complex good code parser
- Option Good code parser(No code, it matched by name)
- Receipt code parser
- Location code parser
- SKU parser
Install
composer require cable8mm/good-code
Usage
Production codes for Laravel
Visit repository - https://github.com/cable8mm/aipro
<?php use App\Models\OptionGood; use Cable8mm\GoodCode\Enums\GoodCodeType; use Cable8mm\GoodCode\GoodCode; /** * For option products, retrieve the master_code of the option and update it. */ if (GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::OPTION) { $code = GoodCode::of( $this->data->get('sellerGoodsCd'), option: $this->data->get('option'), callback: function ($key, $option) { return OptionGood::findMasterCode($key)->option($option)->first()->masterCode(); } )->code(); $this->data->put('masterGoodsCd', $code); }
<?php use Cable8mm\GoodCode\Enums\GoodCodeType; use Cable8mm\GoodCode\GoodCode; use Cable8mm\GoodCode\ValueObjects\SetGood; /** * For composite and gift products, retrieve the set product and update the master_code. */ if ( GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::COMPLEX || GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::GIFT ) { $code = GoodCode::of( $this->data->get('sellerGoodsCd'), callback: function ($key) { return SetGood::findComCode($key)->master_code; } )->code(); $this->data->put('masterGoodsCd', $code); }
Example codes
set-code
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of('SET7369x4zz4235x6')->value(); //=> ['7369'=>4,'4235'=>6] print GoodCode::setCodeOf(['1234' => 2, '5678' => 1,])->code(); //=> 'set1234x2ZZ5678x1'
complex-code
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of('COM10', callback: function ($key) { $a = [ 10 => '123']; return $a[$key]; })->value(); //=> '123'
gift-code
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of('GIF11', callback: function ($key) { $a = [ 11 => '456', ]; return $a[$key]; }); //=> '456'
option-code
Tip
option-code are matching with both option-code and option-good-option name. Unfortunately all of online shops like Coupang and 11st have not send any key for option to sellers.
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of($optionCode, option: $optionName, callback: function ($key, $option) { $a = [ 10 => [ 'Super Smash Bros. Ultimate' => 'COM4', 'Animal Crossing: New Horizons' => '3124', 'The Legend of Zelda: Tears of the Kingdom' => '1234', 'Call of Duty®: Black Ops 6' => '2314', 'Grand Theft Auto V' => '43123', '42342', 'name' => 'Marvel\'s Spider-Man 2', ], ]; return $a[$key][$option]; })->value(); //=> '3124'
Special value object - SetGood
<?php use Cable8mm\GoodCode\ValueObjects\SetGood; print SetGood::of('SET43x3zz253x3')->goods(); //=> ['43' => 3, '253' => 3] print SetGood::ofArray(['43' => 3, '253' => 3])->code(); //=> SET43x3zz253x3
Receipt Code
<?php use Cable8mm\GoodCode\ReceiptCode; print ReceiptCode::of('PO-20250312-0001')->code; //=> PO-20250312-0001 print ReceiptCode::of('PO-20250312-0001')->prefix; //=> PO print ReceiptCode::of('PO-20250312-0001')->ymd; //=> 20250312 print ReceiptCode::of('PO-20250312-0001')->number; //=> 0001 print ReceiptCode::of('PO-20250312-0001')->nextCode(); //=> PO-20250312-0002 print ReceiptCode::of()->nextCode(); //=> PO-[Today's ymd]-0001 print ReceiptCode::of(prefix: 'CT')->nextCode(); //=> CT-[Today's ymd]-0001
Location Code
print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode(); print LocationCode::of(['warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32')->locationCode(); print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32'); //` Stringable` supported //=> AUK-R3-S32
SKU
print Sku::of(code: 123, prefix: 'PO'); //=> PO123 print Sku::of(123); //=> 123 print Sku::of(123, prefix: 'PO'); //=> PO123
Formatting
composer lint
Test
composer test
Support codes
| Type | Notation | Description | Implement |
|---|---|---|---|
Normal Code |
- | Match only one good | Yes |
Set Code |
SET | Match one more good, max 255 characters | Yes |
Complex Code |
COM | Shorten code for Set Code |
Yes |
Gift Code |
GIF | Alias Complex Code |
Yes |
Option Code |
OPT | Very complicated code. Not mastercode, but code + search name.(eq. wemakeprice, naver petWindow and all most OpenMarket options) | Yes |
License
The Phpunit Start Kit is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 366
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-21