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
-62
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Repositories\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Modules\Sirsoft\Ecommerce\Models\EcommerceMailTemplate;
|
||||
|
||||
/**
|
||||
* 이커머스 메일 템플릿 리포지토리 인터페이스
|
||||
*/
|
||||
interface EcommerceMailTemplateRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* ID로 메일 템플릿을 조회합니다.
|
||||
*
|
||||
* @param int $id 템플릿 ID
|
||||
* @return EcommerceMailTemplate|null
|
||||
*/
|
||||
public function findById(int $id): ?EcommerceMailTemplate;
|
||||
|
||||
/**
|
||||
* 유형으로 메일 템플릿을 조회합니다.
|
||||
*
|
||||
* @param string $type 템플릿 유형
|
||||
* @return EcommerceMailTemplate|null
|
||||
*/
|
||||
public function findByType(string $type): ?EcommerceMailTemplate;
|
||||
|
||||
/**
|
||||
* 활성 상태인 특정 유형의 템플릿을 조회합니다.
|
||||
*
|
||||
* @param string $type 템플릿 유형
|
||||
* @return EcommerceMailTemplate|null
|
||||
*/
|
||||
public function getActiveByType(string $type): ?EcommerceMailTemplate;
|
||||
|
||||
/**
|
||||
* 전체 템플릿 목록을 조회합니다.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllTemplates(): Collection;
|
||||
|
||||
/**
|
||||
* 메일 템플릿을 수정합니다.
|
||||
*
|
||||
* @param EcommerceMailTemplate $template 수정 대상
|
||||
* @param array $data 수정 데이터
|
||||
* @return bool
|
||||
*/
|
||||
public function update(EcommerceMailTemplate $template, array $data): bool;
|
||||
|
||||
/**
|
||||
* 메일 템플릿 목록을 페이지네이션하여 조회합니다.
|
||||
*
|
||||
* @param array $filters 필터 조건
|
||||
* @param int $perPage 페이지 당 항목 수
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getPaginated(array $filters = [], int $perPage = 20): LengthAwarePaginator;
|
||||
}
|
||||
+8
@@ -53,4 +53,12 @@ interface OrderShippingRepositoryInterface
|
||||
* @return int 업데이트된 레코드 수
|
||||
*/
|
||||
public function transferByOrderOptionId(int $fromOrderOptionId, int $toOrderOptionId): int;
|
||||
|
||||
/**
|
||||
* 배송유형 코드로 사용 중인 배송 레코드 수를 조회합니다.
|
||||
*
|
||||
* @param string $shippingType 배송유형 코드
|
||||
* @return int 사용 중인 레코드 수
|
||||
*/
|
||||
public function countByShippingType(string $shippingType): int;
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Repositories\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Modules\Sirsoft\Ecommerce\Models\ShippingType;
|
||||
|
||||
/**
|
||||
* 배송유형 Repository 인터페이스
|
||||
*/
|
||||
interface ShippingTypeRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* 배송유형 목록 조회
|
||||
*
|
||||
* @param array $filters 필터 조건
|
||||
* @param array $with Eager loading 관계
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAll(array $filters = [], array $with = []): Collection;
|
||||
|
||||
/**
|
||||
* ID로 배송유형 조회
|
||||
*
|
||||
* @param int $id 배송유형 ID
|
||||
* @param array $with Eager loading 관계
|
||||
* @return ShippingType|null
|
||||
*/
|
||||
public function findById(int $id, array $with = []): ?ShippingType;
|
||||
|
||||
/**
|
||||
* 배송유형 생성
|
||||
*
|
||||
* @param array $data 배송유형 데이터
|
||||
* @return ShippingType
|
||||
*/
|
||||
public function create(array $data): ShippingType;
|
||||
|
||||
/**
|
||||
* 배송유형 수정
|
||||
*
|
||||
* @param int $id 배송유형 ID
|
||||
* @param array $data 수정 데이터
|
||||
* @return ShippingType
|
||||
*/
|
||||
public function update(int $id, array $data): ShippingType;
|
||||
|
||||
/**
|
||||
* 배송유형 삭제
|
||||
*
|
||||
* @param int $id 배송유형 ID
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(int $id): bool;
|
||||
|
||||
/**
|
||||
* 코드 중복 확인
|
||||
*
|
||||
* @param string $code 배송유형 코드
|
||||
* @param int|null $excludeId 제외할 배송유형 ID
|
||||
* @return bool
|
||||
*/
|
||||
public function existsByCode(string $code, ?int $excludeId = null): bool;
|
||||
|
||||
/**
|
||||
* 활성 배송유형 목록 조회
|
||||
*
|
||||
* @param string|null $category 카테고리 필터 (domestic, international, other, null=전체)
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveTypes(?string $category = null): Collection;
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Repositories;
|
||||
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Modules\Sirsoft\Ecommerce\Models\EcommerceMailTemplate;
|
||||
use Modules\Sirsoft\Ecommerce\Repositories\Contracts\EcommerceMailTemplateRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 이커머스 메일 템플릿 리포지토리 구현체
|
||||
*/
|
||||
class EcommerceMailTemplateRepository implements EcommerceMailTemplateRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findById(int $id): ?EcommerceMailTemplate
|
||||
{
|
||||
return EcommerceMailTemplate::find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findByType(string $type): ?EcommerceMailTemplate
|
||||
{
|
||||
return EcommerceMailTemplate::where('type', $type)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getActiveByType(string $type): ?EcommerceMailTemplate
|
||||
{
|
||||
return EcommerceMailTemplate::active()->byType($type)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAllTemplates(): Collection
|
||||
{
|
||||
return EcommerceMailTemplate::orderBy('id')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function update(EcommerceMailTemplate $template, array $data): bool
|
||||
{
|
||||
return $template->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPaginated(array $filters = [], int $perPage = 20): LengthAwarePaginator
|
||||
{
|
||||
$sortBy = $filters['sort_by'] ?? 'id';
|
||||
$sortOrder = $filters['sort_order'] ?? 'asc';
|
||||
$query = EcommerceMailTemplate::query()->orderBy($sortBy, $sortOrder);
|
||||
|
||||
if (! empty($filters['search'])) {
|
||||
$search = $filters['search'];
|
||||
$searchType = $filters['search_type'] ?? 'all';
|
||||
$query->where(function ($q) use ($search, $searchType) {
|
||||
$locales = config('app.supported_locales', ['ko', 'en']);
|
||||
|
||||
if ($searchType === 'subject' || $searchType === 'all') {
|
||||
foreach ($locales as $locale) {
|
||||
$q->orWhere("subject->{$locale}", 'like', "%{$search}%");
|
||||
}
|
||||
}
|
||||
|
||||
if ($searchType === 'body' || $searchType === 'all') {
|
||||
foreach ($locales as $locale) {
|
||||
$q->orWhere("body->{$locale}", 'like', "%{$search}%");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return $query->paginate($perPage);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\OrderStatusEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ShippingStatusEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\ShippingTypeEnum;
|
||||
use Modules\Sirsoft\Ecommerce\Models\Order;
|
||||
use Modules\Sirsoft\Ecommerce\Models\OrderOption;
|
||||
use Modules\Sirsoft\Ecommerce\Models\OrderShipping;
|
||||
@@ -335,7 +334,7 @@ class OrderRepository implements OrderRepositoryInterface
|
||||
'order_id' => $order->id,
|
||||
'order_option_id' => $option->id,
|
||||
'shipping_status' => ShippingStatusEnum::PENDING->value,
|
||||
'shipping_type' => ShippingTypeEnum::DOMESTIC_PARCEL->value,
|
||||
'shipping_type' => 'parcel',
|
||||
], $updateData));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,14 @@ class OrderShippingRepository implements OrderShippingRepositoryInterface
|
||||
->where('order_option_id', $fromOrderOptionId)
|
||||
->update(['order_option_id' => $toOrderOptionId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function countByShippingType(string $shippingType): int
|
||||
{
|
||||
return $this->model
|
||||
->where('shipping_type', $shippingType)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Repositories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Modules\Sirsoft\Ecommerce\Models\ShippingType;
|
||||
use Modules\Sirsoft\Ecommerce\Repositories\Contracts\ShippingTypeRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 배송유형 Repository 구현체
|
||||
*/
|
||||
class ShippingTypeRepository implements ShippingTypeRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param ShippingType $model 배송유형 모델
|
||||
*/
|
||||
public function __construct(
|
||||
protected ShippingType $model
|
||||
) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAll(array $filters = [], array $with = []): Collection
|
||||
{
|
||||
$query = $this->model->newQuery();
|
||||
|
||||
// 활성 상태 필터
|
||||
if (isset($filters['is_active'])) {
|
||||
$query->where('is_active', $filters['is_active']);
|
||||
}
|
||||
|
||||
// 카테고리 필터
|
||||
if (! empty($filters['category'])) {
|
||||
$query->where('category', $filters['category']);
|
||||
}
|
||||
|
||||
// 검색 키워드
|
||||
if (! empty($filters['search'])) {
|
||||
$keyword = $filters['search'];
|
||||
$locales = config('app.translatable_locales', ['ko', 'en']);
|
||||
$query->where(function ($q) use ($keyword, $locales) {
|
||||
foreach ($locales as $locale) {
|
||||
$q->orWhere("name->{$locale}", 'like', "%{$keyword}%");
|
||||
}
|
||||
$q->orWhere('code', 'like', "%{$keyword}%");
|
||||
});
|
||||
}
|
||||
|
||||
// 정렬
|
||||
$query->orderBy('sort_order')->orderBy('id');
|
||||
|
||||
// Eager loading
|
||||
if (! empty($with)) {
|
||||
$query->with($with);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findById(int $id, array $with = []): ?ShippingType
|
||||
{
|
||||
$query = $this->model->newQuery();
|
||||
|
||||
if (! empty($with)) {
|
||||
$query->with($with);
|
||||
}
|
||||
|
||||
return $query->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function create(array $data): ShippingType
|
||||
{
|
||||
return $this->model->create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function update(int $id, array $data): ShippingType
|
||||
{
|
||||
$type = $this->findById($id);
|
||||
$type->update($data);
|
||||
|
||||
return $type->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$type = $this->findById($id);
|
||||
|
||||
return $type->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function existsByCode(string $code, ?int $excludeId = null): bool
|
||||
{
|
||||
$query = $this->model->where('code', $code);
|
||||
|
||||
if ($excludeId !== null) {
|
||||
$query->where('id', '!=', $excludeId);
|
||||
}
|
||||
|
||||
return $query->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getActiveTypes(?string $category = null): Collection
|
||||
{
|
||||
$query = $this->model->newQuery()
|
||||
->active()
|
||||
->ordered();
|
||||
|
||||
if ($category !== null) {
|
||||
$query->ofCategory($category);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user