v7.0.0-beta.2 release
This commit is contained in:
1 parent
6595fd0eb5
commit
fa8eba7a0d
1165 files changed
+107118
-762127
No files matched your search
@@ -2,18 +2,30 @@
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Models;
|
||||
|
||||
use App\Models\Concerns\HasUserOverrides;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ClaimReasonFaultTypeEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ClaimReasonTypeEnum;
|
||||
|
||||
/**
|
||||
* 클래임 사유 모델
|
||||
* 클래임 사유 모델.
|
||||
*
|
||||
* 환불/교환/반품 등 클래임 사유 템플릿을 관리합니다.
|
||||
*
|
||||
* @since 7.0.0-beta.2 (HasUserOverrides 적용)
|
||||
*/
|
||||
class ClaimReason extends Model
|
||||
{
|
||||
use HasUserOverrides;
|
||||
|
||||
/**
|
||||
* 사용자 수정 보존 대상 필드.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected array $trackableFields = ['name', 'sort_order', 'is_active'];
|
||||
|
||||
protected $table = 'ecommerce_claim_reasons';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -26,6 +38,7 @@ class ClaimReason extends Model
|
||||
'sort_order',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'user_overrides',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -37,6 +50,7 @@ class ClaimReason extends Model
|
||||
'sort_order' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
'user_overrides' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Models;
|
||||
|
||||
use App\Models\Concerns\MailTemplateBehavior;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 이커머스 메일 템플릿 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $type
|
||||
* @property array $subject
|
||||
* @property array $body
|
||||
* @property array $variables
|
||||
* @property bool $is_active
|
||||
* @property bool $is_default
|
||||
* @property int|null $updated_by
|
||||
*/
|
||||
class EcommerceMailTemplate extends Model
|
||||
{
|
||||
use MailTemplateBehavior;
|
||||
|
||||
/**
|
||||
* @var string 테이블명
|
||||
*/
|
||||
protected $table = 'ecommerce_mail_templates';
|
||||
|
||||
/**
|
||||
* @var array<string, mixed> 기본 속성 값
|
||||
*/
|
||||
protected $attributes = [
|
||||
'variables' => '[]',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<int, string> 대량 할당 가능 필드
|
||||
*/
|
||||
protected $fillable = [
|
||||
'type',
|
||||
'subject',
|
||||
'body',
|
||||
'variables',
|
||||
'is_active',
|
||||
'is_default',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* 마지막 수정자 관계를 반환합니다.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function updater(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'updated_by');
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Modules\Sirsoft\Ecommerce\Database\Factories\OrderShippingFactory;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ShippingStatusEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ShippingTypeEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Models\ShippingType;
|
||||
|
||||
/**
|
||||
* 주문 배송 모델
|
||||
@@ -74,7 +74,6 @@ class OrderShipping extends Model
|
||||
'delivered_at' => 'datetime',
|
||||
'confirmed_at' => 'datetime',
|
||||
'shipping_status' => ShippingStatusEnum::class,
|
||||
'shipping_type' => ShippingTypeEnum::class,
|
||||
// 다중 통화 컬럼 (JSON)
|
||||
'mc_base_shipping_amount' => 'array',
|
||||
'mc_extra_shipping_amount' => 'array',
|
||||
@@ -180,11 +179,9 @@ class OrderShipping extends Model
|
||||
*/
|
||||
public function isDomestic(): bool
|
||||
{
|
||||
return in_array($this->shipping_type, [
|
||||
ShippingTypeEnum::DOMESTIC_PARCEL,
|
||||
ShippingTypeEnum::DOMESTIC_EXPRESS,
|
||||
ShippingTypeEnum::DOMESTIC_QUICK,
|
||||
]);
|
||||
$type = ShippingType::getCachedByCode($this->shipping_type);
|
||||
|
||||
return $type?->category === 'domestic';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,10 +191,9 @@ class OrderShipping extends Model
|
||||
*/
|
||||
public function isInternational(): bool
|
||||
{
|
||||
return in_array($this->shipping_type, [
|
||||
ShippingTypeEnum::INTERNATIONAL_EMS,
|
||||
ShippingTypeEnum::INTERNATIONAL_STANDARD,
|
||||
]);
|
||||
$type = ShippingType::getCachedByCode($this->shipping_type);
|
||||
|
||||
return $type?->category === 'international';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +203,7 @@ class OrderShipping extends Model
|
||||
*/
|
||||
public function isPickup(): bool
|
||||
{
|
||||
return $this->shipping_type === ShippingTypeEnum::PICKUP;
|
||||
return $this->shipping_type === 'pickup';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Models;
|
||||
|
||||
use App\Models\Concerns\HasUserOverrides;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@@ -9,9 +10,15 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* 배송사 모델
|
||||
*
|
||||
* 배송사 마스터 데이터를 관리합니다.
|
||||
*
|
||||
* ShippingCarrierSeeder 는 GenericEntitySyncHelper 기반으로 동작하므로,
|
||||
* 사용자가 관리자 UI 에서 수정한 필드는 `user_overrides` 에 기록되어
|
||||
* 재설치/재시드 시 보존됩니다.
|
||||
*/
|
||||
class ShippingCarrier extends Model
|
||||
{
|
||||
use HasUserOverrides;
|
||||
|
||||
/** @var array<string, array> 활동 로그 추적 필드 */
|
||||
public static array $activityLogFields = [
|
||||
'code' => ['label_key' => 'sirsoft-ecommerce::activity_log.fields.code', 'type' => 'text'],
|
||||
@@ -21,6 +28,15 @@ class ShippingCarrier extends Model
|
||||
'sort_order' => ['label_key' => 'sirsoft-ecommerce::activity_log.fields.sort_order', 'type' => 'number'],
|
||||
];
|
||||
|
||||
/** @var list<string> 사용자 수정 추적 필드 (시더 재실행 시 보존 대상) */
|
||||
protected array $trackableFields = [
|
||||
'name',
|
||||
'type',
|
||||
'tracking_url',
|
||||
'is_active',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
protected $table = 'ecommerce_shipping_carriers';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -30,6 +46,7 @@ class ShippingCarrier extends Model
|
||||
'tracking_url',
|
||||
'is_active',
|
||||
'sort_order',
|
||||
'user_overrides',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
@@ -38,6 +55,7 @@ class ShippingCarrier extends Model
|
||||
'name' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'user_overrides' => 'array',
|
||||
'created_by' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
];
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace Modules\Sirsoft\Ecommerce\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ChargePolicyEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ShippingMethodEnum;
|
||||
|
||||
/**
|
||||
* 배송정책 국가별 설정 모델
|
||||
@@ -20,6 +19,7 @@ class ShippingPolicyCountrySetting extends Model
|
||||
'shipping_policy_id',
|
||||
'country_code',
|
||||
'shipping_method',
|
||||
'custom_shipping_name',
|
||||
'currency_code',
|
||||
'charge_policy',
|
||||
'base_fee',
|
||||
@@ -43,7 +43,7 @@ class ShippingPolicyCountrySetting extends Model
|
||||
'extra_fee_enabled' => 'boolean',
|
||||
'extra_fee_multiply' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'shipping_method' => ShippingMethodEnum::class,
|
||||
'custom_shipping_name' => 'array',
|
||||
'charge_policy' => ChargePolicyEnum::class,
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Models;
|
||||
|
||||
use App\Models\Concerns\HasUserOverrides;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 배송유형 모델
|
||||
*
|
||||
* 배송유형 마스터 데이터를 관리합니다.
|
||||
*
|
||||
* @since 7.0.0-beta.2 (HasUserOverrides 적용)
|
||||
*/
|
||||
class ShippingType extends Model
|
||||
{
|
||||
use HasUserOverrides;
|
||||
|
||||
/** @var array<string, array> 활동 로그 추적 필드 */
|
||||
public static array $activityLogFields = [
|
||||
'code' => ['label_key' => 'sirsoft-ecommerce::activity_log.fields.code', 'type' => 'text'],
|
||||
'category' => ['label_key' => 'sirsoft-ecommerce::activity_log.fields.category', 'type' => 'text'],
|
||||
'is_active' => ['label_key' => 'sirsoft-ecommerce::activity_log.fields.is_active', 'type' => 'boolean'],
|
||||
'sort_order' => ['label_key' => 'sirsoft-ecommerce::activity_log.fields.sort_order', 'type' => 'number'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 사용자 수정 보존 대상 필드.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected array $trackableFields = ['name', 'category', 'is_active', 'sort_order'];
|
||||
|
||||
protected $table = 'ecommerce_shipping_types';
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'category',
|
||||
'is_active',
|
||||
'sort_order',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'user_overrides',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'name' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
'user_overrides' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* 요청 단위 캐시 (코드 → 모델)
|
||||
*
|
||||
* @var \Illuminate\Database\Eloquent\Collection|null
|
||||
*/
|
||||
protected static $codeCache = null;
|
||||
|
||||
/**
|
||||
* 생성자 관계
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정자 관계
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function updater(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'updated_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 로케일의 배송유형명 반환
|
||||
*
|
||||
* @param string|null $locale 로케일 (기본값: 현재 앱 로케일)
|
||||
* @return string
|
||||
*/
|
||||
public function getLocalizedName(?string $locale = null): string
|
||||
{
|
||||
$locale = $locale ?? app()->getLocale();
|
||||
$name = $this->name;
|
||||
|
||||
if (! is_array($name)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $name[$locale] ?? $name['ko'] ?? $name['en'] ?? $name[array_key_first($name)] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 국내 배송유형 여부
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDomestic(): bool
|
||||
{
|
||||
return $this->category === 'domestic';
|
||||
}
|
||||
|
||||
/**
|
||||
* 해외 배송유형 여부
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInternational(): bool
|
||||
{
|
||||
return $this->category === 'international';
|
||||
}
|
||||
|
||||
/**
|
||||
* 코드로 캐시된 ShippingType 조회
|
||||
*
|
||||
* shipping_types는 드물게 변경되므로 요청 단위 캐시 적용
|
||||
*
|
||||
* @param string $code 배송유형 코드
|
||||
* @return self|null
|
||||
*/
|
||||
public static function getCachedByCode(string $code): ?self
|
||||
{
|
||||
if (static::$codeCache === null) {
|
||||
static::$codeCache = self::all()->keyBy('code');
|
||||
}
|
||||
|
||||
return static::$codeCache[$code] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 캐시를 초기화합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clearCodeCache(): void
|
||||
{
|
||||
static::$codeCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 배송유형만 조회 스코프
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 정렬 순서대로 조회 스코프
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOrdered($query)
|
||||
{
|
||||
return $query->orderBy('sort_order')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 카테고리별 조회 스코프
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $category 카테고리 (domestic, international, other)
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOfCategory($query, string $category)
|
||||
{
|
||||
return $query->where('category', $category);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user