From 88583af03c395131532dcdd3bb2f8f20468215e9 Mon Sep 17 00:00:00 2001 From: younghyeong ryu Date: Thu, 26 Dec 2024 11:36:44 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BF=A0=ED=8F=B0=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 쿠폰 적용 --- composer.json | 3 +- src/Console/InstallCommand.php | 32 +- src/Console/InstallsBladeStack.php | 15 +- src/Events/OrderShipped.php | 4 +- src/Facades/DeliveryFee.php | 14 + .../Admin/CancelReturnExchangeController.php | 51 +- .../Admin/Config/BankController.php | 8 +- .../Admin/Config/CompanyController.php | 22 +- .../Admin/Config/DeliveryController.php | 8 +- .../Controllers/Admin/Config/PgController.php | 9 +- .../Admin/Config/SmsController.php | 8 +- .../Admin/Config/TemplateController.php | 14 +- .../Admin/Coupon/CouponController.php | 67 +++ .../Admin/Coupon/CouponIssueController.php | 82 +++ .../Controllers/Admin/Dev/MailController.php | 38 +- src/Http/Controllers/Admin/ItemController.php | 150 ++++-- .../Controllers/Admin/OrderController.php | 7 +- src/Http/Controllers/CartController.php | 66 ++- src/Http/Controllers/FavoriteController.php | 8 +- src/Http/Controllers/MarketController.php | 30 +- .../Mypage/CancelReturnExchangeController.php | 14 +- .../Controllers/Mypage/CouponController.php | 66 +++ .../Controllers/Mypage/FavoriteController.php | 4 +- .../Controllers/Mypage/OrderController.php | 2 +- src/Http/Controllers/OrderController.php | 139 +++-- src/Http/Controllers/PagesController.php | 15 +- src/Http/Controllers/SearchController.php | 18 +- src/Listeners/MarketEventSubscriber.php | 17 +- src/MarketServiceProvider.php | 15 +- src/Models/MarketBanner.php | 19 - src/Models/MarketCoupon.php | 13 + src/Models/MarketCouponIssue.php | 12 + src/Models/MarketItem.php | 35 ++ src/Models/MarketItemSpec.php | 11 + .../OrderShippedNotification.php | 41 +- src/Services/DeliveryFee.php | 35 ++ src/Services/OrderService.php | 43 +- src/Services/ViewerService.php | 9 - src/Traits/CancelReturnExchange.php | 30 ++ src/Traits/Favorite.php | 6 +- src/View/Components/MailFooter.php | 29 + src/config/pondol-market.php | 6 +- .../2024_09_11_000001_market_all.php | 66 +-- .../2024_11_29_000001_create_banner.php | 35 ++ ...2024_12_05_000001_create_market_detail.php | 34 ++ .../2024_12_06_000001_update_mall_config.php | 34 ++ ...2024_12_20_000001_create_market_coupon.php | 63 +++ src/helpers.php | 36 +- src/resources/lang/en/market.php | 16 +- src/resources/lang/ko/market.php | 16 +- src/resources/market/common.js | 498 +++++------------- src/resources/market/magnifier.js | 70 +++ .../auth/default-market/register.blade.php | 17 +- .../mail/default-market/register.blade.php | 7 +- .../cancel-return-exchange/index.blade.php | 8 +- .../views/admin/config/company.blade.php | 70 +-- .../views/admin/config/delivery.blade.php | 11 +- .../views/admin/coupon/create.blade.php | 177 +++++++ .../views/admin/coupon/index.blade.php | 125 +++++ .../views/admin/coupon/issue.blade.php | 191 +++++++ .../views/admin/coupon/issues.blade.php | 132 +++++ .../admin/coupon/modal-find-product.blade.php | 73 +++ .../views/admin/coupon/sel-category.blade.php | 147 ++++++ src/resources/views/admin/dev/mail.blade.php | 40 +- .../views/admin/item/create.blade.php | 30 +- .../views/admin/item/sub-category.blade.php | 11 - .../views/admin/item/sub-image.blade.php | 2 +- .../views/admin/item/sub-option.blade.php | 2 +- .../views/admin/item/sub-spec.blade.php | 51 ++ .../views/admin/order/index.blade.php | 6 +- .../views/admin/order/view.blade.php | 2 +- .../views/components/app-admin.blade.php | 9 +- src/resources/views/components/app.blade.php | 2 +- .../views/components/mail-footer.blade.php | 6 + .../partials/navigation-admin.blade.php | 33 +- src/resources/views/market/app.blade.php | 2 +- .../templates/cart/default/cart.blade.php | 3 - .../layouts/default/front-header.blade.php | 1 - .../templates/mail/default/notice.blade.php | 7 +- .../templates/mail/default/order.blade.php | 7 +- .../templates/mail/default/sample.blade.php | 6 +- .../templates/order/default/order.blade.php | 81 ++- .../templates/shop/default/sns.blade.php | 26 +- .../templates/shop/default/view.blade.php | 14 +- .../default/address/create-modal.blade.php | 2 + .../userpage/default/address/index.blade.php | 2 +- .../cancel-return-exchange/index.blade.php | 2 +- .../cancel-return-exchange/view.blade.php | 2 +- .../userpage/default/coupons.blade.php | 76 +++ .../userpage/default/order/orders.blade.php | 6 +- .../userpage/default/order/view.blade.php | 16 +- .../templates/userpage/default/qnas.blade.php | 2 +- .../templates/userpage/default/tabs.blade.php | 8 + .../templates/userpage/default/user.blade.php | 2 +- src/routes/admin.php | 212 +++----- src/routes/web.php | 14 +- 96 files changed, 2629 insertions(+), 1097 deletions(-) create mode 100644 src/Facades/DeliveryFee.php create mode 100644 src/Http/Controllers/Admin/Coupon/CouponController.php create mode 100644 src/Http/Controllers/Admin/Coupon/CouponIssueController.php create mode 100644 src/Http/Controllers/Mypage/CouponController.php create mode 100644 src/Models/MarketCoupon.php create mode 100644 src/Models/MarketCouponIssue.php create mode 100644 src/Models/MarketItemSpec.php create mode 100644 src/Services/DeliveryFee.php create mode 100644 src/Traits/CancelReturnExchange.php create mode 100644 src/View/Components/MailFooter.php create mode 100644 src/database/migrations/2024_11_29_000001_create_banner.php create mode 100644 src/database/migrations/2024_12_05_000001_create_market_detail.php create mode 100644 src/database/migrations/2024_12_06_000001_update_mall_config.php create mode 100644 src/database/migrations/2024_12_20_000001_create_market_coupon.php create mode 100644 src/resources/market/magnifier.js create mode 100644 src/resources/views/admin/coupon/create.blade.php create mode 100644 src/resources/views/admin/coupon/index.blade.php create mode 100644 src/resources/views/admin/coupon/issue.blade.php create mode 100644 src/resources/views/admin/coupon/issues.blade.php create mode 100644 src/resources/views/admin/coupon/modal-find-product.blade.php create mode 100644 src/resources/views/admin/coupon/sel-category.blade.php create mode 100644 src/resources/views/admin/item/sub-spec.blade.php create mode 100644 src/resources/views/components/mail-footer.blade.php create mode 100644 src/resources/views/market/templates/userpage/default/coupons.blade.php diff --git a/composer.json b/composer.json index d125ca0..a6c4546 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "wangta69/laravel-market", "description": "e-commerce plugins", "keywords": ["laravel", "market", "pondol" , "쇼핑몰", "mall", "독립형", "korea", "라라벨"], - "homepage": "https://mall.onstory.fun", + "homepage": "https://www.onstory.fun/packages/laravel-market", "license": "MIT", "authors": [ { @@ -25,6 +25,7 @@ "wangta69/laravel-delivery-tracking": "*", "wangta69/laravel-mailer": "*", "wangta69/laravel-visitors-statistics": "*", + "wangta69/laravel-meta": "*", "wangta69/laravel-index-now": "*" }, "autoload": { diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 7d7e281..28e9d96 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -31,7 +31,6 @@ public function handle() { $type = $this->argument('type'); return $this->installBladeStack($type); - } @@ -112,6 +111,37 @@ protected function replaceInFile($search, $replace, $path) { file_put_contents($path, str_replace($search, $replace, file_get_contents($path))); } + + protected function chageOtherConfig() { + $configs = [ + 'pondol-auth'=>[ + 'component.admin.layout'=>['pondol-auth::admin', 'market::app-admin'], + 'route_auth_admin.prefix'=>['auth/admin', 'admin/auth'] + ], + 'pondol-mailer'=>[ + 'component.admin.layout'=>['pondol-mailer::admin', 'market::app-admin'], + 'prefix'=>['mailer', 'admin/mailer'] + ], + 'pondol-visitor'=>[ + 'component.admin.layout'=>['visitors::admin', 'market::app-admin'], + 'route_admin.prefix'=>['visitors/admin', 'admin/visitors'] + ] + ]; + + foreach($configs as $key => $val) { + foreach($val as $k => $v) { + if (config($key.'.'.$k) == $v[0]) { + $this->comment( $key); + $this->comment( $k); + $this->comment( $v[0]); + $this->comment( $v[1]); + set_config($key, [$k => $v[1]]); + } + } + } + } + + /* protected static function flushNodeModules() diff --git a/src/Console/InstallsBladeStack.php b/src/Console/InstallsBladeStack.php index 6aabe46..27512ee 100644 --- a/src/Console/InstallsBladeStack.php +++ b/src/Console/InstallsBladeStack.php @@ -49,13 +49,13 @@ protected function installBladeStack($type) $this->updateWebpackMix(); // 기존 web.php 백업시킨다. - copy(base_path('routes/web.php'), base_path('routes/web.back.php')); - copy(__DIR__.'/../routes/web-blank.php', base_path('routes/web.php')); + // copy(base_path('routes/web.php'), base_path('routes/web.back.php')); + // copy(__DIR__.'/../routes/web-blank.php', base_path('routes/web.php')); $this->replaceInFile('/home', '/', app_path('Providers/RouteServiceProvider.php')); $this->call('pondol:install-editor'); - $this->call('pondol:install-auth', ['type'=> 'only']); + $this->call('pondol:install-auth', ['type'=> 'simple']); $this->call('pondol:install-mailer', ['type'=> 'only']); // laravel board \Artisan::call('vendor:publish', [ @@ -73,11 +73,20 @@ protected function installBladeStack($type) '--provider' => 'Pondol\Market\MarketServiceProvider' ]); + // meta install + \Artisan::call('vendor:publish', [ + '--force'=> true, + '--provider' => 'Pondol\Meta\MetaServiceProvider' + ]); + // auth 관련 변경 configSet('pondol-auth', ['activate' => 'auto', 'template.user'=>'default-market', 'template.mail'=>'default-market']); // \Artisan::call('migrate'); + // 연관 패키지의 config 변경 + $this->chageOtherConfig(); + $this->comment('Please execute the "npm install" && "npm run dev" commands to build your assets.'); } } diff --git a/src/Events/OrderShipped.php b/src/Events/OrderShipped.php index 175a4e3..7898212 100644 --- a/src/Events/OrderShipped.php +++ b/src/Events/OrderShipped.php @@ -20,11 +20,9 @@ class OrderShipped * @return void */ public $order; - public $user; - public function __construct($user, $order) + public function __construct($order) { - $this->user = $user; $this->order = $order; } diff --git a/src/Facades/DeliveryFee.php b/src/Facades/DeliveryFee.php new file mode 100644 index 0000000..f2694a0 --- /dev/null +++ b/src/Facades/DeliveryFee.php @@ -0,0 +1,14 @@ +select( - 're.id', 're.type', 're.created_at', 're.qty', 're.item_price', 're.option_price','re.options', - 're.status', - 'it.name', 'it.model', 'it.image', - 'o.o_id', 'o.created_at as order_created_at' - )->withTrashed() - - - ->join('market_items as it', function($join){ - $join->on('it.id', '=', 're.item_id'); - }) + // \DB::enableQueryLog(); + $types = $request->types; + $from_date = $request->from_date; + $to_date = $request->to_date; + + if (!$types) { + $types = ['refund', 'exchange']; + $request->merge(['types' => $types]); + } - ->join('market_orders as o', function($join){ - $join->on('re.order_id', '=', 'o.id'); - }) - - ->whereNull("re.deleted_at") - ->orderBy('re.id', 'desc')->paginate(15)->withQueryString(); + $items = $this->_index(); + $items = $items->whereIn('re.type', $types); + // $items = $items->whereIn('re.type', ['refund', 'exchange']); + if ($from_date) { + if (!$to_date) { + $to_date = date("Y-m-d"); + } + + $from_date = Carbon::createFromFormat('Y-m-d', $from_date); + $to_date = Carbon::createFromFormat('Y-m-d', $to_date); + $items = $items->whereBetween('re.created_at', [$from_date->startOfDay(), $to_date->endOfDay()]); + } + + $items = $items->orderBy('re.id', 'desc') + ->paginate(15)->withQueryString(); foreach($items as $item) { $item->displayOptions = extractOptions($item); } + // print_r(\DB::getQueryLog()); + return view('market::admin.cancel-return-exchange.index', [ 'items'=>$items, 'return_status' => config('pondol-market.return_status'), diff --git a/src/Http/Controllers/Admin/Config/BankController.php b/src/Http/Controllers/Admin/Config/BankController.php index a0b531c..4a3acee 100644 --- a/src/Http/Controllers/Admin/Config/BankController.php +++ b/src/Http/Controllers/Admin/Config/BankController.php @@ -5,7 +5,6 @@ use App\Http\Controllers\Controller; use DB; use Illuminate\Support\Facades\Log; -use Pondol\Market\Services\ConfigService; use Pondol\Market\Models\MarketBank; class BankController extends Controller @@ -16,11 +15,8 @@ class BankController extends Controller * @return void */ public function __construct( - ConfigService $configSvc ) { - // $this->middleware('auth'); - $this->configSvc = $configSvc; } /** @@ -34,7 +30,7 @@ public function index() // $cat1 = $this->subCategory(''); $banks = MarketBank::where('type', 'manager')->paginate(20)->appends(request()->query()); - $codes = $this->configSvc->get('banks'); + $codes = config('pondol-market.banks'); return view('market::admin.config.bank', [ 'banks'=>$banks, 'codes' => $codes @@ -45,7 +41,7 @@ public function create() { // [TACKBAE_MONEY] => 1000 - $codes = $this->configSvc->get('banks'); + $codes = config('pondol-market.banks'); return view('market::admin.config.bank-create', [ 'codes' => $codes ]); diff --git a/src/Http/Controllers/Admin/Config/CompanyController.php b/src/Http/Controllers/Admin/Config/CompanyController.php index 8d472c9..f92a2bc 100644 --- a/src/Http/Controllers/Admin/Config/CompanyController.php +++ b/src/Http/Controllers/Admin/Config/CompanyController.php @@ -5,8 +5,8 @@ use App\Http\Controllers\Controller; use DB; use Illuminate\Support\Facades\Log; -use Pondol\Market\Services\ConfigService; -use Pondol\Market\Models\MarketBank; + +use Pondol\Common\Facades\JsonKeyValue; // use Pondol\Auth\Models\User\UserConfig; class CompanyController extends Controller @@ -17,11 +17,8 @@ class CompanyController extends Controller * @return void */ public function __construct( - ConfigService $configSvc ) { - // $this->middleware('auth'); - $this->configSvc = $configSvc; } /** @@ -32,13 +29,12 @@ public function __construct( public function index() { - $company = $this->configSvc->get('company'); - // $termsOfUse = UserConfig::where('key', 'termsOfUse')->first(); - // $termsOfPersonal = UserConfig::where('key', 'termsOfPersonal')->first(); + + $company = JsonKeyValue::getAsJson('company'); + $company->copyright = isset($company->copyright) ? $company->copyright: ''; + - return view('market::admin.config.company', [ - 'company'=>$company - ]); + return view('market::admin.config.company', compact('company')); } public function update(Request $request) { @@ -51,9 +47,11 @@ public function update(Request $request) { 'representative' => $request->representative, 'tel1' => $request->tel1, 'fax1' => $request->fax1, + 'copyright' => $request->copyright, ]; - $this->configSvc->set('company', $params ); + set_config('pondol-market.company', $params ); + JsonKeyValue::storeAsJson('company', $params); return response()->json(['error'=>false]); } diff --git a/src/Http/Controllers/Admin/Config/DeliveryController.php b/src/Http/Controllers/Admin/Config/DeliveryController.php index 6966d6f..d26f907 100644 --- a/src/Http/Controllers/Admin/Config/DeliveryController.php +++ b/src/Http/Controllers/Admin/Config/DeliveryController.php @@ -5,7 +5,6 @@ use App\Http\Controllers\Controller; use DB; use Illuminate\Support\Facades\Log; -use Pondol\Market\Services\ConfigService; class DeliveryController extends Controller @@ -16,11 +15,8 @@ class DeliveryController extends Controller * @return void */ public function __construct( - ConfigService $configSvc ) { - // $this->middleware('auth'); - $this->configSvc = $configSvc; } /** @@ -33,7 +29,7 @@ public function index() // config()->set('app.name','My Project App'); // $cat1 = $this->subCategory(''); // \Artisan::call('config:clear'); // 만약 production mode이고 config를 cache 하여 사용하면 - $cfg = $this->configSvc->get(); + $cfg = config('pondol-market'); return view('market::admin.config.delivery', [ 'cfg'=>$cfg @@ -47,7 +43,7 @@ public function update(Request $request) { 'min' => $request->min ]; // [TACKBAE_MONEY] => 1000 - $this->configSvc->set('delivery', $config ); + set_config('pondol-market.delivery', $config ); } diff --git a/src/Http/Controllers/Admin/Config/PgController.php b/src/Http/Controllers/Admin/Config/PgController.php index a95934e..8d57668 100644 --- a/src/Http/Controllers/Admin/Config/PgController.php +++ b/src/Http/Controllers/Admin/Config/PgController.php @@ -5,7 +5,6 @@ use App\Http\Controllers\Controller; use DB; use Illuminate\Support\Facades\Log; -use Pondol\Market\Services\ConfigService; use Pondol\Market\Models\MarketBank; class PgController extends Controller @@ -16,11 +15,8 @@ class PgController extends Controller * @return void */ public function __construct( - ConfigService $configSvc ) { - // $this->middleware('auth'); - $this->configSvc = $configSvc; } /** @@ -34,8 +30,7 @@ public function index() // $cat1 = $this->subCategory(''); // $banks = MarketBank::paginate(20)->appends(request()->query()); - // $codes = $this->configSvc->get('banks'); - $payment = $this->configSvc->get('payment'); + $payment = config('pondol-market.payment'); $pgs = ['inicis'=>'Inicis', 'kcp'=>'KCP', 'lg'=>'LG']; $simples = ['naver'=>'네이버 페이', 'kakao'=>'카카오 페이']; // simplePayments return view('market::admin.config.pg', [ @@ -57,7 +52,7 @@ public function update(Request $request) { 'kakao' => $request->kakao ? true : false, ]; Log::info($params); - $this->configSvc->set('payment', $params ); + set_config('pondol-market.payment', $params ); return response()->json(['error'=>false]); } diff --git a/src/Http/Controllers/Admin/Config/SmsController.php b/src/Http/Controllers/Admin/Config/SmsController.php index 3534811..b5ed7a2 100644 --- a/src/Http/Controllers/Admin/Config/SmsController.php +++ b/src/Http/Controllers/Admin/Config/SmsController.php @@ -5,7 +5,6 @@ use App\Http\Controllers\Controller; use DB; use Illuminate\Support\Facades\Log; -use Pondol\Market\Services\ConfigService; use Pondol\Market\Models\MarketBank; class SmsController extends Controller @@ -16,11 +15,8 @@ class SmsController extends Controller * @return void */ public function __construct( - ConfigService $configSvc ) { - // $this->middleware('auth'); - $this->configSvc = $configSvc; } /** @@ -31,7 +27,7 @@ public function __construct( public function index() { - $sms = $this->configSvc->get('sms'); + $sms = config('pondol-market.sms'); $vendors = ['smsto'=>'SMS.TO', 'directsend'=>'DIRECTSEND']; $sms = isset($sms) ? $sms : []; @@ -53,7 +49,7 @@ public function update(Request $request) { 'manager_rec_order' => $request->manager_rec_order ? true : false ]; Log::info($params); - $this->configSvc->set('sms', $params ); + set_config('pondol-market.sms', $params ); return response()->json(['error'=>false]); } diff --git a/src/Http/Controllers/Admin/Config/TemplateController.php b/src/Http/Controllers/Admin/Config/TemplateController.php index 27c4d7f..a39a29d 100644 --- a/src/Http/Controllers/Admin/Config/TemplateController.php +++ b/src/Http/Controllers/Admin/Config/TemplateController.php @@ -9,7 +9,6 @@ use Storage; use App\Http\Controllers\Controller; -use Pondol\Market\Services\ConfigService; class TemplateController extends Controller @@ -20,11 +19,8 @@ class TemplateController extends Controller * @return void */ public function __construct( - ConfigService $configSvc ) { - // $this->middleware('auth'); - $this->configSvc = $configSvc; } /** @@ -79,7 +75,7 @@ public function view() $pages_dir = resource_path('views/market/templates/pages'); $pages = array_map('basename',\File::directories($pages_dir)); - $template = $this->configSvc->get('template'); + $template = config('pondol-market.template'); return view('market::admin.config.template', [ 'template'=>$template, @@ -98,7 +94,7 @@ public function view() } public function update(Request $request) { - $template = $this->configSvc->get('template'); + $template = config('pondol-market.template'); $template['layout']['theme'] = $request->layout; $template['main']['theme'] = $request->main; @@ -115,7 +111,7 @@ public function update(Request $request) { $template['mail']['theme'] = $request->mail; $template['pages']['theme'] = $request->pages; - $this->configSvc->set('template', $template ); + set_config('pondol-market.template', $template ); return response()->json(['error'=>false]); } @@ -132,7 +128,7 @@ public function updateCI(Request $request) { // $path=\Storage::put($filepath, $file); // $result = $file->storeAs($filepath, $fileName); - $this->configSvc->set('template.ci', $fileName ); + set_config('pondol-market.template.ci', $fileName ); } return redirect()->back(); @@ -149,7 +145,7 @@ public function updateFavicon(Request $request) { // $path=\Storage::put($filepath, $file); // $result = $file->storeAs($filepath, $fileName); - $this->configSvc->set('template.favicon', $fileName ); + set_config('pondol-market.template.favicon', $fileName ); } // return redirect()->back(); diff --git a/src/Http/Controllers/Admin/Coupon/CouponController.php b/src/Http/Controllers/Admin/Coupon/CouponController.php new file mode 100644 index 0000000..bdfdd26 --- /dev/null +++ b/src/Http/Controllers/Admin/Coupon/CouponController.php @@ -0,0 +1,67 @@ +orderSvc = $orderSvc; + // $this->middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + + $items = MarketCoupon::orderBy('id', 'desc')->paginate(15)->withQueryString(); + return view('market::admin.coupon.index', compact('items')); + } + + public function create(Request $request) { + $item = new MarketCoupon; + return view('market::admin.coupon.create', compact('item')); + } + + public function store(Request $request) { + print_r($request->all); + $coupon = new MarketCoupon; + + $coupon->title = $request->title; + $coupon->apply_type = $request->apply_type; + $coupon->item_id = $request->item_id; + $coupon->category = $request->category; + $coupon->min_price = str_replace(',', '', $request->min_price); + $coupon->apply_amount_type = $request->apply_amount_type; + $coupon->price = $request->price ? str_replace(',', '', $request->price): null; + $coupon->percentage = $request->percentage; + $coupon->percentage_max_price = $request->percentage_max_price ? str_replace(',', '', $request->percentage_max_price): null; + $coupon->save(); + + return redirect()->route('market.admin.coupons'); + + } + + +} diff --git a/src/Http/Controllers/Admin/Coupon/CouponIssueController.php b/src/Http/Controllers/Admin/Coupon/CouponIssueController.php new file mode 100644 index 0000000..165e0f1 --- /dev/null +++ b/src/Http/Controllers/Admin/Coupon/CouponIssueController.php @@ -0,0 +1,82 @@ +join('market_coupons', function($join){ + $join->on('market_coupons.id', '=', 'market_coupon_issues.coupon_id'); + }) + ->join('users', function($join){ + $join->on('users.id', '=', 'market_coupon_issues.user_id'); + })->orderBy('market_coupon_issues.id', 'desc')->paginate(15)->withQueryString(); + return view('market::admin.coupon.issues', compact('items')); + } + + public function create(MarketCoupon $coupon, Request $request) { + + return view('market::admin.coupon.issue', compact('coupon')); + } + + public function store($coupon, Request $request) { + $to = $request->to; + $recv_users = $request->recv_users; + $expired_at = Carbon::createFromFormat('Y-m-d', $request->expired_at)->endOfDay(); + + switch($to) { + case 'all': + $users = User::select('id')->get()->pluck('id')->toArray(); + break; + case 'individual': + $users = explode(',', $recv_users); + break; + } + + foreach($users as $user) { + $issue = new MarketCouponIssue; + $issue->user_id = $user; + $issue->coupon_id = $coupon; + $issue->expired_at = $expired_at; + $issue->save(); + + } + return redirect()->route('market.admin.coupon.issues'); + + } + + +} diff --git a/src/Http/Controllers/Admin/Dev/MailController.php b/src/Http/Controllers/Admin/Dev/MailController.php index 680bff9..7451492 100644 --- a/src/Http/Controllers/Admin/Dev/MailController.php +++ b/src/Http/Controllers/Admin/Dev/MailController.php @@ -2,7 +2,9 @@ namespace Pondol\Market\Http\Controllers\Admin\Dev; use Illuminate\Http\Request; -use Illuminate\Auth\Events\Registered; +// use Illuminate\Auth\Events\Registered; +use Pondol\Auth\Events\Registered; +use Pondol\Auth\Events\ResetPasswordToken; use Pondol\Market\Events\OrderShipped; use DB; @@ -42,7 +44,7 @@ public function view(Request $request) public function send(Request $request) { - $user = User::select('id', 'email', 'name')->find($request->to); + switch($request->type) { case 'notice': @@ -52,12 +54,18 @@ public function send(Request $request) break; case 'order': - event(new OrderShipped($user, $request->o_id)); + $user = User::select('id', 'email', 'name')->find($request->to); + event(new OrderShipped($request->o_id)); break; case 'register': // $this->mailSvc->registerMail($user); + $user = User::select('id', 'email', 'name')->find($request->to); event(new Registered($user)); break; + case 'resetpassword': + $user = User::select('id', 'email', 'name')->where('email', $request->email)->first(); + event(new ResetPasswordToken($user)); + break; } // return view('market.::admin.dev.mail', []); @@ -65,22 +73,20 @@ public function send(Request $request) public function preview(Request $request) { - - $user = User::select('id', 'email', 'name')->find($request->to); - $mailData = $request; - $mailData->user = $user; - + $mailData = $request; switch($request->type) { case 'notice': + $user = User::select('id', 'email', 'name')->find($request->to); + $mailData->user = $user; return view('market.templates.mail.'.config('pondol-market.template.mail.theme').'.'.$request->type, ['mailData'=>$mailData]); break; case 'order': - + $mailData->items = $this->orderSvc->orderItemsByOrderid($mailData->o_id)->orderBy('market_orders.id', 'desc')->get(); $mailData->display = $this->orderSvc->orderDetailByOrderid($mailData->o_id); - + $user = User::select('id', 'email', 'name')->find($mailData->display->user_id); foreach($mailData->items as $item) { $item->displayOptions = extractOptions($item); @@ -89,13 +95,19 @@ public function preview(Request $request) return view('market.templates.mail.'.config('pondol-market.template.mail.theme').'.'.$request->type, ['user'=>$user, 'data'=>$mailData]); break; case 'register': - + $user = User::select('id', 'email', 'name')->find($request->to); return view('auth.templates.mail.'.config('pondol-auth.template.mail').'.register', ['notifiable'=>$user]); break; + + case 'resetpassword': + $user = User::select('id', 'email', 'name')->where('email', $request->email)->first(); + $token=app('auth.password.broker')->createToken($user); + $actionUrl = route('password.reset', [$token]); + + return view('auth.templates.mail.'.config('pondol-auth.template.mail').'.resetpassword', ['notifiable'=>$user, 'actionUrl'=>$actionUrl, 'token'=>$token]); + break; } } - - } diff --git a/src/Http/Controllers/Admin/ItemController.php b/src/Http/Controllers/Admin/ItemController.php index 3f6504c..1ab34ac 100644 --- a/src/Http/Controllers/Admin/ItemController.php +++ b/src/Http/Controllers/Admin/ItemController.php @@ -8,13 +8,16 @@ use File; use Storage; + use Pondol\Market\Models\MarketItem; use Pondol\Market\Models\MarketItemCategory; use Pondol\Market\Models\MarketItemOption; +use Pondol\Market\Models\MarketItemSpec; use Pondol\Market\Models\MarketItemDisplay; use Pondol\Market\Models\MarketItemImage; use Pondol\Market\Models\MarketItemTag; - +use Pondol\Editor\Facades\Editor; +use Pondol\Meta\Facades\Meta; use App\Http\Controllers\Controller; class ItemController extends Controller @@ -56,17 +59,18 @@ public function index(Request $request) $from_date = Carbon::createFromFormat('Y-m-d', $from_date); $to_date = Carbon::createFromFormat('Y-m-d', $to_date); $items = $items->whereBetween('market_items.created_at', [$from_date->startOfDay(), $to_date->endOfDay()]); + } - - // $items = $users->where(function ($q) use($from_date, $to_date) { - // $q->whereRaw("DATE(market_items.created_at) >= '".$from_date."' AND DATE(market_items.created_at)<= '".$to_date."'" ); - // }); + if($request->ajax()){ + return response()->json(['error'=>false, 'items'=>$items->get()], 200);//500, 203 + } else { + $items = $items->orderBy('id', 'desc')->paginate(15)->withQueryString(); + return view('market::admin.item.index', [ + 'items'=>$items + ]); } - $items = $items->orderBy('id', 'desc')->paginate(15)->withQueryString(); - return view('market::admin.item.index', [ - 'items'=>$items - ]); + } /** @@ -96,7 +100,7 @@ public function store(Request $request) { $file = $request->file; $option = $request->option; - + $specs = $request->specs; $item = new MarketItem; // $item->category = $category; @@ -116,40 +120,53 @@ public function store(Request $request) { $item->image = $path[0]; } - $this->storeOption($item->id, $option); + $this->storeOption($item->id, $option); // 등록옵션 입력 + $this->storeSpec($item->id, $specs); // 추가필드 입력 $item->category = $this->storeCategory($item->id, $category1, $category2, $category3); $this->storeDisplay($item->id, $request->display); $this->storeTags($item->id, $request->tags); $this->contents_update($item); $item->save(); + + // $meta 처리하기 + Meta::set('market.item', ['item'=>(string)$item->id]) + ->title($item->name) + ->description($item->shorten_description) + ->extractKeywordsFromArray($item->tags, 'tag') + ->image(\Storage::url($item->image)) + ->update(); + return redirect()->route('market.admin.items'); } /** * 상품 수정 폼 */ - public function modify(MarketItem $item) { + public function edit(MarketItem $item) { $display = $item->display->pluck('name')->all(); // display option // $categories = $item->categories->toJson(); $categories = $item->categories()->select('category')->get()->toJson(); $images = $item->images()->select('image')->get()->toJson(); $options = $this->creteOptionForm($item); - $tags = MarketItemTag::select( - 't.id', 't.tag' - )->join('market_tags as t', function($join){ - $join->on('market_item_tags.tag_id', '=', 't.id'); - })->where('market_item_tags.item_id', $item->id)->get(); - - if ($tags->isEmpty()) { - $tags = []; - } + // $tags = MarketItemTag::select( + // 't.id', 't.tag' + // )->join('market_tags as t', function($join){ + // $join->on('market_item_tags.tag_id', '=', 't.id'); + // })->where('market_item_tags.item_id', $item->id)->get(); + + + // if ($tags->isEmpty()) { + // $tags = []; + // } + // $temp = ; + return view('market::admin.item.create', [ 'item' => $item, 'display' => $display, 'categories' => $categories, 'images' => $images, 'options' => json_encode($options), - 'tags' => json_encode($tags) + 'tags' => json_encode($item->tags) ]); } @@ -161,6 +178,7 @@ public function update(MarketItem $item, Request $request) { $file = $request->file; $option = $request->option; + $specs = $request->specs; // $item->category = $category; $item->name = $request->name; @@ -171,40 +189,32 @@ public function update(MarketItem $item, Request $request) { $item->stock = $request->stock; $item->description = $request->description; $item->shorten_description = $request->shorten_description; - - // 제품이미지 업로드 - // $filepath = 'public/market/items/'.$item->id; - // if(is_array($request->file('files'))) { - // foreach ($request->file('files') as $index => $upload) { - - // if ($upload == null) { - // continue; - // } - - // // 기존 이미지는 삭제 - // \Storage::delete($item->image); - - // $filename = $upload->getClientOriginalName(); - // $path=\Storage::put($filepath, $upload); // //Storage::disk('local')->put($name,$file,'public'); - // $item->image = $path; - // } - // } - $item->save(); + // 업로드 이미지 처리 $path = $this->storeImage($item->id, $request->file('files')); if(isset($path[0])) { $item->image = $path[0]; - } - $this->storeOption($item->id, $option); + + + + $this->storeOption($item->id, $option); // 등록옵션 입력 + $this->storeSpec($item->id, $specs); // 추가필드 입력 $item->category = $this->storeCategory($item->id, $category1, $category2, $category3); $this->storeDisplay($item->id, $request->display); $this->storeTags($item->id, $request->tags); $this->contents_update($item); $item->save(); + // $meta 처리하기 + Meta::set('market.item', ['item'=>(string)$item->id]) + ->title($item->name) + ->description($item->shorten_description) + ->extractKeywordsFromArray($item->tags, 'tag') + ->image(\Storage::url($item->image)) + ->update(); return redirect()->route('market.admin.items'); } @@ -213,19 +223,20 @@ public function update(MarketItem $item, Request $request) { private function storeImage($item_id, $files) { $pathes = []; $filepath = 'public/market/items/'.$item_id; + + if(is_array($files)) { - foreach ($files as $index => $upload) { - if ($upload == null) { + $max = max(array_keys($files)); + echo 'max:'.$max.PHP_EOL; + for($i = 0; $i <= $max; $i++) { + if(isset($files[$i])) { + $upload = $files[$i]; + $filename = $upload->getClientOriginalName(); + $path=\Storage::put($filepath, $upload); // //Storage::disk('local')->put($name,$file,'public'); + array_push($pathes, $path); + } else { array_push($pathes, null); - continue; } - - // 기존 이미지는 삭제 - // \Storage::delete($item->image); - - $filename = $upload->getClientOriginalName(); - $path=\Storage::put($filepath, $upload); // //Storage::disk('local')->put($name,$file,'public'); - array_push($pathes, $path); } } @@ -268,6 +279,27 @@ private function storeOption($item_id, $option) { } } + /** + * 추가필드 입력 + */ + private function storeSpec($item_id, $specs) { + // 옵션등록 + // 1. 기존 옵션은 삭제 + MarketItemSpec::where('item_id', $item_id)->delete(); + // 옵션 등록 + if(isset($specs['name'])) { + foreach($specs['name'] as $k=>$title) { + $comment = $specs['val'][$k]; + + $specsItem = new MarketItemSpec; + $specsItem->item_id = $item_id; + $specsItem->title = $title; + $specsItem->comment = $comment; + $specsItem->save(); + } + } + } + // display option 저장 private function storeCategory($item_id, $cat1, $cat2, $cat3) { @@ -347,16 +379,18 @@ private function creteOptionForm($item) { * description에 있는 이미지들을 제품 이미지 쪽으로 옮기고 기존 temp에 있는 이미지들을 리셑한다. */ private function contents_update($item) { + // editor의 임시 파일일 경우 파일을 이동 처리한다. $sourceDir = storage_path() .'/app/public/tmp/editor/'. session()->getId(); $destinationDir = storage_path() .'/app/public/market/items/'.$item->id.'/editor'; - - $item->description = str_replace('/storage/tmp/editor/'.session()->getId(), '/storage/market/items/'.$item->id.'/editor', $item->description); - - $item->save(); - $success = File::copyDirectory($sourceDir, $destinationDir); + $item->description = str_replace('/storage/tmp/editor/'.session()->getId(), '/storage/market/items/'.$item->id.'/editor', $item->description); + // 현재 tmp directory 삭제 Storage::deleteDirectory('public/tmp/editor/'. session()->getId()); + // 본문속 이미지가 base64로 된 경우 특정 위치로 이동 처리한다. + $item->description = Editor::extractBase64Image($item->description, $destinationDir, '/storage/market/items/'.$item->id.'/editor/'); + + $item->save(); return; } diff --git a/src/Http/Controllers/Admin/OrderController.php b/src/Http/Controllers/Admin/OrderController.php index b05205c..ddac106 100644 --- a/src/Http/Controllers/Admin/OrderController.php +++ b/src/Http/Controllers/Admin/OrderController.php @@ -10,7 +10,6 @@ use Pondol\Market\Models\MarketBuyer; use Pondol\Market\Models\MarketPayment; -use Pondol\Market\Services\ConfigService; use Pondol\Market\Services\OrderService; use Pondol\DeliveryTracking\Traits\Tracking; @@ -26,11 +25,9 @@ class OrderController extends Controller use Tracking; public function __construct( - ConfigService $configSvc, OrderService $ordergSvc ) { - $this->configSvc = $configSvc; $this->orderSvc = $ordergSvc; } @@ -108,8 +105,8 @@ public function view($o_id) { $couriers = $this->_couriers(); - $delivery_status = $this->configSvc->get('delivery_status'); - $pay_status = $this->configSvc->get('pay_status'); + $delivery_status = config('pondol-market.delivery_status'); + $pay_status = config('pondol-market.pay_status'); return view('market::admin.order.view', [ diff --git a/src/Http/Controllers/CartController.php b/src/Http/Controllers/CartController.php index b65f11b..7092f9c 100644 --- a/src/Http/Controllers/CartController.php +++ b/src/Http/Controllers/CartController.php @@ -9,8 +9,8 @@ use Pondol\Market\Models\MarketItem; use Pondol\Market\Models\MarketCart; -use Pondol\Market\Services\CalDeliveryFee; - +use Pondol\Market\Facades\DeliveryFee; +use Pondol\Meta\Facades\Meta; use App\Http\Controllers\Controller; class CartController extends Controller @@ -23,9 +23,9 @@ class CartController extends Controller * * @return void */ - public function __construct(CalDeliveryFee $delivery) + public function __construct() { - $this->delivery = $delivery; + } public function index(Request $request) @@ -33,6 +33,7 @@ public function index(Request $request) $user = $request->user(); $c_id = $this->cart_cookie(); + $meta = Meta::get(); $items = MarketCart::select( @@ -42,9 +43,12 @@ public function index(Request $request) $join->on('market_items.id', '=', 'market_carts.item_id'); }); if($user) { // 로그인 된 회원이면 + if($c_id) { // 로그인전 cart에 담은 것을 업데이트 한다. + MarketCart::whereNull('user_id')->where('c_id', $c_id)->update(['user_id'=>$user->id]); + } $items->where('market_carts.user_id', $user->id); } else if($c_id) { - $items->where('market_carts.c_id', $c_id); + $items->where('market_carts.c_id', $c_id)->whereNull('market_carts.user_id'); } $items = $items->orderby('market_carts.id', 'desc')->get(); @@ -56,9 +60,7 @@ public function index(Request $request) // 옵션을 분리하여 처리한다. - return view('market.templates.cart.'.config('pondol-market.template.cart.theme').'.cart', [ - 'items' => $items - ]); + return view('market.templates.cart.'.config('pondol-market.template.cart.theme').'.cart', compact('items', 'meta')); } public function store(Request $request) @@ -66,6 +68,7 @@ public function store(Request $request) $c_id = $this->cart_cookie(); $user = $request->user(); + $item_id = $request->item; $options = $request->options; $qty = $request->qty; @@ -108,6 +111,8 @@ public function store(Request $request) if ($user) { // 로그인전 장바구니에 넣었다가 로그인 한 경우 이곳을 업데이트 한다. MarketCart::where('c_id', $c_id)->whereNull('user_id')->update(['user_id'=>$user->id]); + // 기존 장바구니 쿠키는 삭제한다. + } $cart = new MarketCart; @@ -171,9 +176,9 @@ private function parsingOptions($option_ids, $item) { /** - * 카트의 item 삭제 + * 카트의 개별 item 삭제 */ - public function delete(MarketCart $cart, Request $request) { + public function destroy(MarketCart $cart, Request $request) { $c_id = $this->cart_cookie(); $user = $request->user(); @@ -189,6 +194,38 @@ public function delete(MarketCart $cart, Request $request) { } } + /** + * 카트의 선택 아이템 삭제 + */ + public function destroyChecked(Request $request) { // MarketCart $cart, + + $c_id = $this->cart_cookie(); + $user = $request->user(); + $ids = $request->order; + if(is_array($ids)) { + foreach($ids as $id) { + $cart = MarketCart::find($id); + if($cart->c_id == $c_id || ($user->id && $user->id == $cart->user_id)) { + $cart->delete(); + } + } + return response()->json([ + 'error' => false + ]); + } + + return response()->json([ + 'error' => '장바구니에서 삭제할 상품을 선택해 주세요' + ]); + + + // } else { + // return response()->json([ + // 'error' => '잘못된 접근입니다.' + // ]); + // } + } + public function updateQty(Request $request) { $user = $request->user(); $c_id = $this->cart_cookie(); @@ -210,7 +247,14 @@ public function updateQty(Request $request) { public function updateOverview(Request $request) { $orders = $request->order; + $display = new \stdClass; + if(!$orders) { + $display->totalPrice = 0; + $display->delivery_fee = 0; + + return response()->json(['error' => false, 'display'=>$display]); + } $items = MarketCart:: select( 'market_carts.qty', 'market_carts.item_price', 'market_carts.option_price') @@ -225,7 +269,7 @@ public function updateOverview(Request $request) { } // 배송비 계산 - $display->delivery_fee = $this->delivery->cal($display->totalPrice); + $display->delivery_fee = DeliveryFee::cal($display->totalPrice); return response()->json(['error' => false, 'display'=>$display]); } diff --git a/src/Http/Controllers/FavoriteController.php b/src/Http/Controllers/FavoriteController.php index d453f0a..0f157aa 100644 --- a/src/Http/Controllers/FavoriteController.php +++ b/src/Http/Controllers/FavoriteController.php @@ -28,13 +28,13 @@ public function __construct( * * @return \Illuminate\Http\Response */ - public function _store(Request $request, $item) + public function store(Request $request, $item) { - return response()->json($this->store($request, $item)); + return response()->json($this->_store($request, $item)); } - public function _destroy(Request $request, $fav) + public function destroy(Request $request, $fav) { - return response()->json($this->destroy($request, $fav)); + return response()->json($this->_destroy($request, $fav)); } } \ No newline at end of file diff --git a/src/Http/Controllers/MarketController.php b/src/Http/Controllers/MarketController.php index 3dae714..c857ab3 100644 --- a/src/Http/Controllers/MarketController.php +++ b/src/Http/Controllers/MarketController.php @@ -13,7 +13,7 @@ use Pondol\Market\Models\MarketCategory; use Pondol\Market\Traits\Item; -use Pondol\Market\Services\Meta; +use Pondol\Meta\Facades\Meta; class MarketController extends Controller { @@ -25,10 +25,8 @@ class MarketController extends Controller * * @return void */ - public function __construct(Meta $meta) + public function __construct() { - $this->meta = $meta; - \Log::info(url()->previous()); } /** @@ -50,16 +48,17 @@ public function category($category, Request $request) $categoryObj = $this->buildCategory($category); $keywords = []; - $this->meta->title = $categoryObj->path[0]->name; + // $this->meta->title = $categoryObj->path[0]->name; + $meta = Meta::get(); array_push($keywords, $categoryObj->path[0]->name); if(isset($categoryObj->path[1])) { - $this->meta->title = $categoryObj->path[1]->name; + // $this->meta->title = $categoryObj->path[1]->name; array_push($keywords, $categoryObj->path[1]->name); } if(isset($categoryObj->path[2])) { - $this->meta->title = $categoryObj->path[2]->name; + // $this->meta->title = $categoryObj->path[2]->name; array_push($keywords, $categoryObj->path[2]->name); } @@ -69,14 +68,10 @@ public function category($category, Request $request) } } - $this->meta->keywords = implode(',', $keywords); + // $this->meta->keywords = implode(',', $keywords); - return view('market.templates.shop.'.config('pondol-market.template.shop.theme').'.category', [ - 'category' => $category, - 'items' => $items, - 'categoryObj' => $categoryObj, - 'meta' => $this->meta, - ]); + return view('market.templates.shop.'.config('pondol-market.template.shop.theme').'.category', + compact('category', 'items', 'categoryObj', 'meta')); } public function view(MarketItem $item, Request $request) @@ -128,10 +123,13 @@ public function view(MarketItem $item, Request $request) } } - $this->meta->setItem($item); + // $this->meta->setItem($item); + $meta = Meta::get(); + // $meta->title(''); + // return; return view('market.templates.shop.'.config('pondol-market.template.shop.theme').'.view', [ - 'meta' => $this->meta, + 'meta' => $meta, 'item' => $item, 'images' => $images, 'options' => $options, diff --git a/src/Http/Controllers/Mypage/CancelReturnExchangeController.php b/src/Http/Controllers/Mypage/CancelReturnExchangeController.php index ec3b37c..b0ceb78 100644 --- a/src/Http/Controllers/Mypage/CancelReturnExchangeController.php +++ b/src/Http/Controllers/Mypage/CancelReturnExchangeController.php @@ -50,7 +50,7 @@ public function index(Request $request) { ->where("re.user_id", $user->id) ->orderBy('re.id', 'desc')->paginate(15)->withQueryString(); - $return_status = config('pondol-market.return_status'); + $refund_status = config('pondol-market.refund_status'); $exchange_status = config('pondol-market.exchange_status'); foreach($items as $item) { $item->displayOptions = extractOptions($item); @@ -58,15 +58,15 @@ public function index(Request $request) { case 'exchange': $item->statusStr = $exchange_status[$item->status]; break; - case 'return': - $item->statusStr = $return_status[$item->status]; + case 'refund': + $item->statusStr = $refund_status[$item->status]; break; } } return view('market.templates.userpage.'.config('pondol-market.template.userpage.theme').'.cancel-return-exchange.index', [ 'items'=>$items, - 'return_status' => config('pondol-market.return_status'), + 'refund_status' => config('pondol-market.refund_status'), 'exchange_status' => config('pondol-market.exchange_status') ]); } @@ -102,7 +102,7 @@ public function create($type, $o_id, Request $request) $typeStr = ''; switch($type) { - case 'return': + case 'refund': $typeStr = '반품'; break; case 'exchange': @@ -203,8 +203,8 @@ public function view($id, Request $request) { switch($item->type) { - case 'return': - $configs = config('pondol-market.return_status'); + case 'refund': + $configs = config('pondol-market.refund_status'); break; case 'exchange': $configs = config('pondol-market.exchange_status'); diff --git a/src/Http/Controllers/Mypage/CouponController.php b/src/Http/Controllers/Mypage/CouponController.php new file mode 100644 index 0000000..e7b0776 --- /dev/null +++ b/src/Http/Controllers/Mypage/CouponController.php @@ -0,0 +1,66 @@ +user(); + + $items = MarketCouponIssue::select( + 'market_coupon_issues.*', + 'market_coupons.title', 'market_coupons.apply_type', 'market_coupons.min_price', 'market_coupons.apply_amount_type', 'market_coupons.price', + 'market_coupons.percentage', 'market_coupons.percentage_max_price' + ) + ->join('market_coupons', function($join){ + $join->on('market_coupons.id', '=', 'market_coupon_issues.coupon_id'); + })->where('market_coupon_issues.user_id', $user->id)->orderBy('market_coupon_issues.id', 'desc')->paginate(15)->withQueryString(); + + foreach($items as $item) { + $item->enable = true; + if($item->used_at) { + $item->enable = false; + } else if($item->expired_at < Carbon::now()) { + $item->enable = false; + } + } + + // print_r($items); + return view('market.templates.userpage.'.config('pondol-market.template.userpage.theme').'.coupons', [ + 'items' => $items, + ]); + } + + + + + + +} diff --git a/src/Http/Controllers/Mypage/FavoriteController.php b/src/Http/Controllers/Mypage/FavoriteController.php index 931e320..00e50ab 100644 --- a/src/Http/Controllers/Mypage/FavoriteController.php +++ b/src/Http/Controllers/Mypage/FavoriteController.php @@ -24,12 +24,12 @@ public function __construct( * * @return \Illuminate\Http\Response */ - public function _index(Request $request) + public function index(Request $request) { // 마켙order 접근시 비회원 경우는 o_id가 있어야한다. $user = $request->user(); - $items = $this->index($request, $user); + $items = $this->_index($request, $user); // 현재 선택한 상품을 리스트업 한다. $items = $items->orderBy('market_item_favorites.id', 'desc')->paginate(15)->withQueryString(); diff --git a/src/Http/Controllers/Mypage/OrderController.php b/src/Http/Controllers/Mypage/OrderController.php index 5149db4..070b03d 100644 --- a/src/Http/Controllers/Mypage/OrderController.php +++ b/src/Http/Controllers/Mypage/OrderController.php @@ -42,7 +42,7 @@ public function index(Request $request) if(!$user && !$o_id) { - return redirect()->route('market.login', ['f'=>'market.mypage.order']); + return redirect()->route('login', ['f'=>'market.mypage.order']); } else if($o_id){ // 주문 아이디가 있을 경우 바로 상세 보기로 넘긴다. return redirect()->route('market.mypage.order.view', [$o_id]); } diff --git a/src/Http/Controllers/OrderController.php b/src/Http/Controllers/OrderController.php index 182de07..68ca1bb 100644 --- a/src/Http/Controllers/OrderController.php +++ b/src/Http/Controllers/OrderController.php @@ -7,6 +7,7 @@ use DB; use Validator; +use Carbon\Carbon; use Pondol\Market\Models\MarketItem; use Pondol\Market\Models\MarketCart; @@ -15,9 +16,9 @@ use Pondol\Market\Models\MarketPayment; use Pondol\Market\Models\MarketOrder; use Pondol\Market\Models\MarketAddress; +use Pondol\Market\Models\MarketCouponIssue; -use Pondol\Market\Services\ConfigService; -use Pondol\Market\Services\CalDeliveryFee; +use Pondol\Market\Facades\DeliveryFee; use Pondol\Market\Events\OrderShipped; use Pondol\Auth\Traits\Point; @@ -33,14 +34,8 @@ class OrderController extends Controller * @return void */ public function __construct( - ConfigService $configSvc, - CalDeliveryFee $delivery - // PointService $pointSvc ){ - $this->configSvc = $configSvc; - $this->delivery = $delivery; - // $this->pointSvc = $pointSvc; - } + } /** * Show the application dashboard. @@ -51,11 +46,12 @@ public function index(Request $request) { $user = $request->user(); + if(!$user && config('pondol-market.guest_enable_order') == false) { + return redirect()->route('login'); + } $orders = session()->get('orderItmes'); // $o_id = session()->get('o_id'); $o_id = $this->order_session('new'); - - if(!$orders) { return redirect()->route('market.cart'); @@ -64,7 +60,7 @@ public function index(Request $request) $items = MarketCart:: select( 'market_carts.qty', 'market_carts.item_price', 'market_carts.option_price', 'market_carts.options', - 'market_items.id', 'market_items.name', 'market_items.image', 'market_items.model', 'market_items.price') + 'market_items.id', 'market_items.category', 'market_items.name', 'market_items.image', 'market_items.model', 'market_items.price') ->whereIn('market_carts.id', $orders) ->leftjoin('market_items', function($join){ $join->on('market_items.id', '=', 'market_carts.item_id'); @@ -92,7 +88,6 @@ public function index(Request $request) } } - $display = new \stdClass; $display->totalPrice = 0; $display->products = $items[0]->name; @@ -100,15 +95,13 @@ public function index(Request $request) $display->products .= '외 '.(count($items)-1).'종'; } - - foreach($items as $v) { $display->totalPrice += ($v->item_price + $v->option_price) * $v->qty; } $display->user_point = $user->point ?? 0; // 배송비 계산 - $display->delivery_fee = $this->delivery->cal($display->totalPrice); + $display->delivery_fee = DeliveryFee::cal($display->totalPrice); // 주문을 시도했던 것은 다시 내용을 보여주고 만약 결제가 완료(주문 완료시점에 모든 세션삭제해야되지만 에러로 인해)된 것이라면 @@ -118,9 +111,7 @@ public function index(Request $request) $buyer = new \stdClass; } - // if ($o_id) { - // $buyer = MarketBuyer::where('o_id', $o_id)->first(); - // } else if($default_addr) { + $buyer->o_id = $o_id; $buyer->tel1 = isset($buyer->tel1) ? $buyer->tel1 : isset($default_addr->tel1) ? $default_addr->tel1 : null; $buyer->name = isset($buyer->name) ? $buyer->name : isset($default_addr->name) ? $default_addr->name : null; @@ -128,7 +119,7 @@ public function index(Request $request) $buyer->addr1 = isset($buyer->addr1) ? $buyer->addr1 : isset($default_addr->addr1) ? $default_addr->addr1 : null; $buyer->addr2 = isset($buyer->addr2) ? $buyer->addr2 : isset($default_addr->addr2) ? $default_addr->addr2 : null; $buyer->message = isset($buyer->message) ? $buyer->message : isset($default_addr->message) ? $default_addr->message : null; - // } + if($buyer->tel1) { $tel1 = explode('-', $buyer->tel1); @@ -139,20 +130,87 @@ public function index(Request $request) $buyer->tel1_3 = isset($tel1[2]) ? $tel1[2] : ''; // 무통장 계좌 가져오기] - $codes = $this->configSvc->get('banks'); + $codes = config('pondol-market.banks'); $banks = MarketBank::get(); foreach($banks as $v) { $v->name = $codes[$v->code]['name']; } + + // 쿠폰 가져오기 + $coupons = MarketCouponIssue::select( + 'market_coupon_issues.*', + 'market_coupons.title', 'market_coupons.apply_type', 'market_coupons.item_id','market_coupons.category', + 'market_coupons.min_price', 'market_coupons.apply_amount_type', 'market_coupons.price', + 'market_coupons.percentage', 'market_coupons.percentage_max_price' + ) + ->join('market_coupons', function($join){ + $join->on('market_coupons.id', '=', 'market_coupon_issues.coupon_id'); + }) + ->where('market_coupon_issues.user_id', $user->id) + ->whereNull('market_coupon_issues.used_at') + ->where('market_coupon_issues.expired_at', '>', Carbon::now()) + ->orderBy('market_coupon_issues.id', 'desc')->get(); + + // 현재 결제 정보를 이용하여 쿠폰 enable disable 시키기 + foreach($coupons as $coupon) { + $coupon->enable = true; + $coupon->enable_price = 0; + + if($display->totalPrice < $coupon->min_price) { // 최소 구매 금액을 충족시키지 못할 경우 + $coupon->enable = false; + } else { + switch($coupon->apply_type) { // 각각의 경우에 따라 적용금액 산정 + case 'all': // + $coupon->enable_price = $this->couponApplyAmount($coupon, $display->totalPrice); + break; + case 'product': // 특정 제품일 경우 특정 제품에 한정하여 처리 + $item_price = 0; + foreach($items as $item) { + if ($item.id == $coupon.item_id) { + $item_price += ($item->item_price + $item->option_price) * $item->qty; + } + } + + if($item_price == 0) { + $coupon->enable = false; + } else { + $coupon->enable_price = $this->couponApplyAmount($coupon, $item_price); + } + + break; + case 'category': // subcategory 까지포함한다. + $item_price = 0; + foreach($items as $item) { + if (substr($item.category, 0, strlen($coupon.category)) == $coupon.category) { + $item_price += ($item->item_price + $item->option_price) * $item->qty; + } + } + + if($item_price == 0) { + $coupon->enable = false; + } else { + $coupon->enable_price = $this->couponApplyAmount($coupon, $item_price); + } + break; + } + } + } + - return view('market.templates.order.'.config('pondol-market.template.order.theme').'.order', [ - 'user' => $user, - 'items' => $items, - 'buyer' => $buyer, - 'display' => $display, - 'banks' => $banks, - 'addresses' => $addresses - ]); + + return view('market.templates.order.'.config('pondol-market.template.order.theme').'.order', + compact('user','items','buyer','display','banks','addresses','coupons')); + } + + private function couponApplyAmount($coupon, $amount) { + switch($coupon->apply_amount_type) { + case 'price': + return $coupon->price; + case 'percent': + $calPrice = floor($coupon->percentage / 100 * $amount); + return $calPrice > $coupon->percentage_max_price ? $coupon->percentage_max_price : $calPrice; + break; + } } public function setOrderItems(Request $request) @@ -224,7 +282,7 @@ public function storeAddress(Request $request) { $buyer->save(); // address에 신규 address 자동 추가 - if($user->id) { + if($user) { $address = MarketAddress::where('user_id', $buyer->user_id) ->where('zip', $buyer->zip) ->where('addr1', $buyer->addr1) @@ -262,6 +320,10 @@ public function storePayment(Request $request) { $user = $request->user(); $paytype = $request->paytype; // online / card + + $coupon_id = $request->coupon_id; + $coupon_enable_price = $request->coupon_enable_price; + $pointamount = (int)str_replace(',', '', $request->pointamount); $total = str_replace(',', '', $request->total); // 실제 결제 금액 $bank = $request->bank; @@ -295,7 +357,7 @@ public function storePayment(Request $request) { $user_point = $user->point ?? 0; // 배송비 계산 - $delivery_fee = $this->delivery->cal($totalPrice); + $delivery_fee = DeliveryFee::cal($totalPrice); if($user_point < $pointamount) { @@ -304,8 +366,8 @@ public function storePayment(Request $request) { ]); } - $sum = $totalPrice + $delivery_fee - $pointamount; - \Log::info('totalPrice:'.$totalPrice .', delivery_fee:'. $delivery_fee.', pointamount:'. $pointamount); + $sum = $totalPrice + $delivery_fee - $pointamount - $coupon_enable_price; + \Log::info('totalPrice:'.$totalPrice .', delivery_fee:'. $delivery_fee.', pointamount:'. $pointamount.', coupon_enable_price:'. $coupon_enable_price); \Log::info('sum:'.$sum .', total:'. $total); if($sum != $total) { return response()->json([ @@ -326,6 +388,8 @@ public function storePayment(Request $request) { $payment->amt_point = $pointamount; $payment->amt_product = $totalPrice; $payment->amt_delivery = $delivery_fee; + $payment->coupon_issue_id = $coupon_id; + $payment->amt_coupon = $coupon_enable_price; $payment->amt_total = $total; $payment->save(); // 회원 포인트 변경 @@ -349,8 +413,15 @@ public function storePayment(Request $request) { MarketCart::where('id', $v->id)->delete(); } + // 쿠폰 아이디가 있을 경우 used_at update + if($coupon_id) { + $coupon_issue = MarketCouponIssue::find($coupon_id); + $coupon_issue->used_at = Carbon::now(); + $coupon_issue->save(); + } + // $user-> - event(new OrderShipped($user, $o_id)); + event(new OrderShipped($o_id)); DB::commit(); diff --git a/src/Http/Controllers/PagesController.php b/src/Http/Controllers/PagesController.php index 3247c64..7b60023 100644 --- a/src/Http/Controllers/PagesController.php +++ b/src/Http/Controllers/PagesController.php @@ -5,8 +5,8 @@ use App\Http\Controllers\Controller; use DB; use Illuminate\Support\Facades\Log; -use Pondol\Auth\Models\User\UserConfig; - +// use Pondol\Auth\Models\User\UserConfig; +use Pondol\Common\Facades\JsonKeyValue; use Pondol\Market\Services\Meta; @@ -33,14 +33,13 @@ public function show(Request $request, $page) switch($page) { case 'privacy-policy': $this->meta->title = "개인정보처리방침"; - - $privacyPolicy = UserConfig::where('key', 'privacyPolicy')->first(); - $item = $privacyPolicy->value; + $item = JsonKeyValue::get('user.aggrement.privacy-policy'); break; case 'terms-of-use': $this->meta->title = "서비스이용약관"; - $termsOfUse = UserConfig::where('key', 'termsOfUse')->first(); - $item = $termsOfUse->value; + // $termsOfUse = UserConfig::where('key', 'termsOfUse')->first(); + // $item = $termsOfUse->value; + $item = JsonKeyValue::get('user.aggrement.term-of-use'); break; } @@ -48,8 +47,6 @@ public function show(Request $request, $page) 'meta' => $this->meta, 'item' => $item, ]); - - } // protected function get_order_num($params=null){ diff --git a/src/Http/Controllers/SearchController.php b/src/Http/Controllers/SearchController.php index 8fc8c5e..494ab1f 100644 --- a/src/Http/Controllers/SearchController.php +++ b/src/Http/Controllers/SearchController.php @@ -7,8 +7,8 @@ use Illuminate\Support\Facades\Log; use Pondol\Market\Models\MarketCategory; -use Pondol\Market\Services\Meta; use Pondol\Market\Traits\Item; +use Pondol\Meta\Facades\Meta; class SearchController extends Controller { @@ -19,9 +19,8 @@ class SearchController extends Controller * * @return void */ - public function __construct(Meta $meta) + public function __construct() { - $this->meta = $meta; } @@ -37,14 +36,13 @@ public function index(Request $request) { ->orderBy('category', 'asc') ->get(); - $this->meta->title = $request->q; - $this->meta->description = $request->q.'에 대한 검색결과'; + $meta = Meta::get() + ->title($request->q) + ->description($request->q.'에 대한 검색결과'); + // print_r(DB::getQueryLog()); - return view('market.templates.search.'.config('pondol-market.template.search.theme').'.search', [ - 'items'=> $items, - 'meta' => $this->meta, - 'categories'=>$categories - ]); + return view('market.templates.search.'.config('pondol-market.template.search.theme').'.search', + compact('items', 'meta', 'categories')); } diff --git a/src/Listeners/MarketEventSubscriber.php b/src/Listeners/MarketEventSubscriber.php index 5f4ec04..c4456e4 100644 --- a/src/Listeners/MarketEventSubscriber.php +++ b/src/Listeners/MarketEventSubscriber.php @@ -5,6 +5,9 @@ use Pondol\Market\Events\OrderShipped; use Illuminate\Support\Facades\Notification; use Pondol\Market\Notifications\OrderShippedNotification; +use Pondol\Market\Services\OrderService; +use Pondol\Auth\Models\User\User; + class MarketEventSubscriber { @@ -25,7 +28,19 @@ public function __construct() // MailService $mailSvc public function ordered($event) { - $event->user->notify(new OrderShippedNotification($event->user, $event->order)); + // if($event->user) { // 회원구매시, + // $event->user->notify(new OrderShippedNotification($event->order)); + $orderSvc = new OrderService; + $data = new \stdClass; + $data->items = $orderSvc->orderItemsByOrderid($event->order)->orderBy('market_orders.id', 'desc')->get(); + $data->display = $orderSvc->orderDetailByOrderid($event->order); + + $user = User::find($data->display->user_id); + $user->notify(new OrderShippedNotification($data)); + // new OrderShippedNotification($event->order); + // } else { // 비회원 구매시는 어떻게 처리할 것인가? + + // } } /** diff --git a/src/MarketServiceProvider.php b/src/MarketServiceProvider.php index 9fe6621..f5f10e7 100644 --- a/src/MarketServiceProvider.php +++ b/src/MarketServiceProvider.php @@ -11,6 +11,8 @@ use Pondol\Market\View\Components\MarketCategory; use Pondol\Market\View\Components\MarketNavyCategory; use Pondol\Market\View\Components\Banner; +use Pondol\Market\View\Components\MailFooter; +use Pondol\Market\Services\DeliveryFee; class MarketServiceProvider extends ServiceProvider { // implements DeferrableProvider /** @@ -20,6 +22,9 @@ class MarketServiceProvider extends ServiceProvider { // implements DeferrableP */ public function register() { + $this->app->singleton('market-delivery-fee', function () { + return new DeliveryFee(); + }); } /** @@ -35,10 +40,14 @@ public function boot(\Illuminate\Routing\Router $router) Blade::component('market-category', MarketCategory::class); Blade::component('market-navy-category', MarketNavyCategory::class); Blade::component('market-banner', Banner::class); + Blade::component('market-mail-footer', MailFooter::class); + + if (!config()->has('pondol-market')) { + $this->publishes([ + __DIR__ . '/config/pondol-market.php' => config_path('pondol-market.php'), + ], 'config'); + } - $this->publishes([ - __DIR__ . '/config/pondol-market.php' => config_path('pondol-market.php'), - ], 'config'); $this->mergeConfigFrom( __DIR__ . '/config/pondol-market.php', 'pondol-market' diff --git a/src/Models/MarketBanner.php b/src/Models/MarketBanner.php index 8fae0ef..bd04ee6 100644 --- a/src/Models/MarketBanner.php +++ b/src/Models/MarketBanner.php @@ -10,22 +10,3 @@ class MarketBanner extends Model use SoftDeletes; } - -/* -CREATE TABLE `market_banners` ( - `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, - `name` VARCHAR(50) NULL DEFAULT NULL COMMENT '베너위치값' COLLATE 'utf8mb4_unicode_ci', - `image` VARCHAR(255) NULL DEFAULT NULL COMMENT '이미지' COLLATE 'utf8mb4_unicode_ci', - `title` VARCHAR(50) NULL DEFAULT NULL COMMENT '베너타이틀' COLLATE 'utf8mb4_unicode_ci', - `description` VARCHAR(255) NULL DEFAULT NULL COMMENT '베너설명' COLLATE 'utf8mb4_unicode_ci', - `url` VARCHAR(255) NULL DEFAULT NULL COMMENT '베너 링크' COLLATE 'utf8mb4_unicode_ci', - `created_at` TIMESTAMP NULL DEFAULT NULL, - `updated_at` TIMESTAMP NULL DEFAULT NULL, - `deleted_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE -) -COLLATE='utf8mb4_unicode_ci' -ENGINE=InnoDB -; - -*/ \ No newline at end of file diff --git a/src/Models/MarketCoupon.php b/src/Models/MarketCoupon.php new file mode 100644 index 0000000..b033097 --- /dev/null +++ b/src/Models/MarketCoupon.php @@ -0,0 +1,13 @@ +hasMany('Pondol\Market\Models\MarketItemOption', 'item_id'); } + + public function specs() + { + return $this->hasMany('Pondol\Market\Models\MarketItemSpec', 'item_id'); + } public function reviews() { @@ -38,6 +43,36 @@ public function qnas() { return $this->hasMany('Pondol\Market\Models\MarketItemQna', 'item_id'); } + + + public function getTagsAttribute() { + $tags = $this->hasMany('Pondol\Market\Models\MarketItemTag', 'item_id')->join('market_tags as t', function($join){ + $join->on('market_item_tags.tag_id', '=', 't.id'); + })->get()->toArray(); + + return $tags; + } + + /* + public function tags() { + $tags = $this->hasMany('Pondol\Market\Models\MarketItemTag', 'item_id')->join('market_tags as t', function($join){ + $join->on('market_item_tags.tag_id', '=', 't.id'); + }); + // $tags = MarketItemTag::select( + // 't.id', 't.tag' + // )->join('market_tags as t', function($join){ + // $join->on('market_item_tags.tag_id', '=', 't.id'); + // })->where('market_item_tags.item_id', $item->id)->get(); + + + // if ($tags->isEmpty()) { + // $tags = []; + // } + + return $tags; + } +*/ + } diff --git a/src/Models/MarketItemSpec.php b/src/Models/MarketItemSpec.php new file mode 100644 index 0000000..c105dec --- /dev/null +++ b/src/Models/MarketItemSpec.php @@ -0,0 +1,11 @@ +user = $user; - $this->order = $order; + // $this->user = $user; + $this->data = $data; + // $this->toMail(); // $this->orderSvc = $ordergSvc; } @@ -35,6 +37,7 @@ public function __construct($user, $order) // OrderService $ordergSvc */ public function via($notifiable) { + return ['mail']; } @@ -47,36 +50,14 @@ public function via($notifiable) public function toMail($notifiable) { - \Log::info('toMail OrderShippedNotification'); - // \Log::info('toMail 11 ====================================='); - // \Log::info($notifiable); - // \Log::info('this->order:'.$this->order); - // \Log::info('endnotifiable ====================================='); - $orderSvc = new OrderService; - $data = new \stdClass; - $data->items = $orderSvc->orderItemsByOrderid($this->order)->orderBy('market_orders.id', 'desc')->get(); - $data->display = $orderSvc->orderDetailByOrderid($this->order); - $user = $this->user; - // \Log::info('display data start ====================================='); - // \Log::info(json_encode($data)); - // \Log::info(json_encode($this->user)); - // \Log::info(json_encode('market.templates.mail.'.config('pondol-market.template.mail.theme').'.order')); - // \Log::info('end ====================================='); return (new MailMessage) - ->subject($user->name.'님의 주문정보입니다.') + ->subject($notifiable->name.'님의 주문정보입니다.') ->markdown('market.templates.mail.'.config('pondol-market.template.mail.theme').'.order', [ - 'user' => $this->user, - 'data' => $data + 'user' => $notifiable, + 'data' => $this->data ]); - // return (new MailMessage)->subject($notifiable->name.'님의 주문정보입니다.') - // ->view('market.templates.mail.'.config('pondol-market.template.mail.theme').'.order') - // ->with([ - // 'user' => $user, - // 'data' => $data - // ]); - } /** diff --git a/src/Services/DeliveryFee.php b/src/Services/DeliveryFee.php new file mode 100644 index 0000000..0a116db --- /dev/null +++ b/src/Services/DeliveryFee.php @@ -0,0 +1,35 @@ +Join('market_orders as order', function($join){ - // $join->on('market_buyers.o_id', '=', 'order.o_id'); - // }) - // ->Join(DB::raw("(SELECT o_id, COUNT(o_id) as count, MAX(id) as max_id FROM market_orders GROUP BY market_orders.o_id) item_count"), function($join){ - // $join->on('order.id', 'item_count.max_id'); - // }) - // ->Join('market_items as it', function($join){ - // $join->on('it.id', '=', 'order.item_id'); - // }) - // ->Join('market_payments as pay', function($join){ - // $join->on('pay.o_id', '=', 'order.o_id'); - // }) - - // ->Join('users as u', function($join){ - // $join->on('order.user_id', '=', 'u.id'); - // }); - - // if($user !== 'admin') { // admin이 아닐경우 사용자 본인것만 보여준다. - // $items->where('order.user_id', $user); - // } - // // ->orderBy('market_orders.id', 'desc'); - // return $items; // ->paginate(15)->withQueryString(); - - // } - - public function orderList($user) { $items = MarketOrder::select( 'market_orders.user_id', 'market_orders.o_id', 'market_orders.qty', 'market_orders.item_price', 'market_orders.option_price', 'market_orders.created_at', @@ -96,12 +61,16 @@ public function orderItemsByOrderid($o_id) { return $items; // ->paginate(15)->withQueryString(); } + /** + * 주문지 정보 / 결제 정보등을 가져온다. + */ public function orderDetailByOrderid($o_id) { $detail = MarketBuyer::select( - 'market_buyers.o_id', 'market_buyers.name', 'market_buyers.zip', 'market_buyers.addr1', 'market_buyers.addr2', 'market_buyers.tel1', + 'market_buyers.o_id', 'market_buyers.user_id', 'market_buyers.name', 'market_buyers.zip', 'market_buyers.addr1', 'market_buyers.addr2', 'market_buyers.tel1', 'market_buyers.message', 'market_buyers.courier', 'market_buyers.delivery_status','market_buyers.invoice_no', 'pay.method', 'pay.status as pay_status', 'pay.inputer', 'pay.bank', 'pay.amt_point', 'pay.amt_product', 'pay.amt_delivery', 'pay.amt_total', - 'bank.code', 'bank.no', 'bank.owner' + 'pay.amt_coupon', + 'bank.code', 'bank.no', 'bank.owner' ) ->leftJoin('market_payments as pay', function($join) { diff --git a/src/Services/ViewerService.php b/src/Services/ViewerService.php index f71d52d..2b5a1da 100644 --- a/src/Services/ViewerService.php +++ b/src/Services/ViewerService.php @@ -3,15 +3,6 @@ use Pondol\Image\GetHttpImage; class ViewerService { - /** - * 기존 스토리지 경로를 public 경로로 변경 - */ - static function getImageUrl($url) { - return \Storage::url($url); - } - - - /** * @param String $file public/bbs/5/201804/37/filename.jpeg diff --git a/src/Traits/CancelReturnExchange.php b/src/Traits/CancelReturnExchange.php new file mode 100644 index 0000000..9342edf --- /dev/null +++ b/src/Traits/CancelReturnExchange.php @@ -0,0 +1,30 @@ +select( + 're.id', 're.type', 're.created_at', 're.qty', 're.item_price', 're.option_price','re.options', + 're.status', + 'it.name', 'it.model', 'it.image', + 'o.o_id', 'o.created_at as order_created_at' + )->withTrashed() + + + ->join('market_items as it', function($join){ + $join->on('it.id', '=', 're.item_id'); + }) + + ->join('market_orders as o', function($join){ + $join->on('re.order_id', '=', 'o.id'); + }) + + ->whereNull("re.deleted_at"); + + return $items; + } +} \ No newline at end of file diff --git a/src/Traits/Favorite.php b/src/Traits/Favorite.php index fceb213..512d156 100644 --- a/src/Traits/Favorite.php +++ b/src/Traits/Favorite.php @@ -5,7 +5,7 @@ trait Favorite { - public function index($request, $user = null) { + public function _index($request, $user = null) { $items = MarketItemFavorite::select( 'market_item_favorites.id as fav_id', 'it.id', 'it.name', 'it.model', 'it.price', 'it.cost', 'it.image' @@ -21,7 +21,7 @@ public function index($request, $user = null) { return $items; } - public function store($request, $item_id) + public function _store($request, $item_id) { $user = $request->user(); @@ -33,7 +33,7 @@ public function store($request, $item_id) return ['error'=> false, 'id'=>$fav->id]; } - public function destroy($request, $id) + public function _destroy($request, $id) { $user = $request->user(); diff --git a/src/View/Components/MailFooter.php b/src/View/Components/MailFooter.php new file mode 100644 index 0000000..9ba7d13 --- /dev/null +++ b/src/View/Components/MailFooter.php @@ -0,0 +1,29 @@ + false, // 비회원 주문 'route_web' => [ 'prefix' => '', 'as' => 'market.', 'middleware' => ['web'] ], 'route_admin' => [ - 'prefix' => 'market/admin', + 'prefix' => 'admin', + // 'prefix' => 'market/admin', 'as' => 'market.admin.', 'middleware' => ['web', 'admin'] ], @@ -33,7 +35,7 @@ 20 => '교환진행중', 90 => '교환완료' ], - 'return_status' => [ // 30, 60, 80 일경우 모든 주문이 완료 + 'refund_status' => [ // 30, 60, 80 일경우 모든 주문이 완료 0 => '접수신청', // 결제대기 10 => '거절',// 상품준비 20 => '반품진행중', diff --git a/src/database/migrations/2024_09_11_000001_market_all.php b/src/database/migrations/2024_09_11_000001_market_all.php index d65cbb1..fc0c249 100644 --- a/src/database/migrations/2024_09_11_000001_market_all.php +++ b/src/database/migrations/2024_09_11_000001_market_all.php @@ -42,7 +42,6 @@ public function up() }); } - if (!Schema::hasTable('market_buyers')) { Schema::create('market_buyers', function(BluePrint $table) { $table->id(); @@ -62,8 +61,6 @@ public function up() }); } - - if (!Schema::hasTable('market_carts')) { Schema::create('market_carts', function(BluePrint $table) { $table->id(); @@ -79,8 +76,6 @@ public function up() }); } - - if (!Schema::hasTable('market_categories')) { Schema::create('market_categories', function(BluePrint $table) { $table->id(); @@ -99,28 +94,6 @@ public function up() }); } - - - // if (!Schema::hasTable('market_configs')) { - // Schema::create('market_configs', function(BluePrint $table) { - // $table->string('key', '20'); - // $table->text('value'); - // }); - // } - - - - // if (!Schema::hasTable('market_delivery_companies')) { - // Schema::create('market_delivery_companies', function(BluePrint $table) { - // $table->id(); - // $table->string('code', '20')->nullable()->comment('택배사코드'); - // $table->string('name', '20')->nullable()->comment('택배사명'); - // $table->string('url', '100')->nullable()->comment('택배사 url'); - // $table->string('query_url', '100')->nullable()->comment('배송조회url'); - // }); - // } - - if (!Schema::hasTable('market_exchange_returns')) { Schema::create('market_exchange_returns', function(BluePrint $table) { $table->id(); @@ -146,8 +119,6 @@ public function up() }); } - - if (!Schema::hasTable('market_items')) { Schema::create('market_items', function(BluePrint $table) { $table->id(); @@ -156,6 +127,7 @@ public function up() $table->string('name', '50')->nullable()->comment('상품명'); $table->string('brand', '50')->nullable()->comment('브랜드'); $table->string('model', '50')->nullable()->comment('모델'); + $table->string('Ingredients', '50')->nullable()->comment('제품소재'); $table->integer('price')->default(0)->unsigned()->comment('판매가격(sales price)'); $table->integer('cost')->default(0)->unsigned()->comment('원가(cost)'); $table->mediumInteger('t_point')->default(0)->unsigned()->comment('제품별 지급 포인트'); @@ -170,7 +142,6 @@ public function up() }); } - if (!Schema::hasTable('market_item_categories')) { Schema::create('market_item_categories', function(BluePrint $table) { $table->id(); @@ -182,7 +153,6 @@ public function up() }); } - if (!Schema::hasTable('market_item_displays')) { Schema::create('market_item_displays', function(BluePrint $table) { $table->id(); @@ -195,8 +165,6 @@ public function up() }); } - - if (!Schema::hasTable('market_item_favorites')) { Schema::create('market_item_favorites', function(BluePrint $table) { $table->id(); @@ -207,8 +175,6 @@ public function up() }); } - - if (!Schema::hasTable('market_item_images')) { Schema::create('market_item_images', function(BluePrint $table) { $table->id(); @@ -219,8 +185,6 @@ public function up() }); } - - if (!Schema::hasTable('market_item_options')) { Schema::create('market_item_options', function(BluePrint $table) { $table->id(); @@ -234,8 +198,6 @@ public function up() }); } - - if (!Schema::hasTable('market_item_qnas')) { Schema::create('market_item_qnas', function(BluePrint $table) { $table->id(); @@ -250,8 +212,6 @@ public function up() }); } - - if (!Schema::hasTable('market_item_reviews')) { Schema::create('market_item_reviews', function(BluePrint $table) { $table->id(); @@ -266,8 +226,6 @@ public function up() }); } - - if (!Schema::hasTable('market_item_tags')) { Schema::create('market_item_tags', function(BluePrint $table) { $table->bigInteger('item_id')->unsigned()->index(); @@ -295,7 +253,6 @@ public function up() }); } - if (!Schema::hasTable('market_payments')) { Schema::create('market_payments', function(BluePrint $table) { $table->id(); @@ -309,27 +266,12 @@ public function up() $table->bigInteger('amt_point')->default(0)->unsigned()->comment('포인트 결제 금액'); $table->bigInteger('amt_product')->default(0)->unsigned()->comment('총 상품 금액'); $table->bigInteger('amt_delivery')->default(0)->unsigned()->comment('택배비'); + $table->bigInteger('coupon_issue_id')->nullable()->unsigned()->comment('사용한 쿠폰 아이디'); + $table->bigInteger('amt_coupon')->nullable()->unsigned()->comment('쿠폰 사용 금액'); $table->bigInteger('amt_total')->default(0)->unsigned()->comment(' 최종 결제금액(택배비 및 기타 경비를 계산한 후 최종결제금액)'); $table->timestamps(); }); } - - - - // if (!Schema::hasTable('market_points')) { - // Schema::create('market_points', function(BluePrint $table) { - // $table->id(); - // $table->bigInteger('user_id')->index()->unsigned(); - // $table->bigInteger('point')->default(0)->unsigned(); - // $table->bigInteger('cur_sum')->default(0)->unsigned()->comment('users.point + users.hold_point 와 동일한 값이 되어야 함'); - // $table->string('item', '20')->comment('이벤트, 구매포인트'); - // $table->string('sub_item', '20')->nullable()->comment('item의 세부정, buy, event..'); - // $table->bigInteger('rel_item')->nullable()->unsigned()->comment('주로 참조 테이블 아이디'); - // $table->timestamp('created_at')->index(); - // }); - // } - - if (!Schema::hasTable('market_tags')) { Schema::create('market_tags', function(BluePrint $table) { @@ -338,8 +280,6 @@ public function up() }); } - - } diff --git a/src/database/migrations/2024_11_29_000001_create_banner.php b/src/database/migrations/2024_11_29_000001_create_banner.php new file mode 100644 index 0000000..21289b9 --- /dev/null +++ b/src/database/migrations/2024_11_29_000001_create_banner.php @@ -0,0 +1,35 @@ +id(); + $table->string('position', '50')->nullable()->comment('베너위치값'); + $table->string('image')->nullable()->comment('이미지'); + $table->string('title', '50')->nullable()->comment('베너타이틀'); + $table->string('description')->nullable()->comment('베너설명'); + $table->string('url')->nullable()->comment('베너 링크'); + $table->timestamps(); + $table->softDeletes(); + }); + } + } + + + public function down() + { + Schema::dropIfExists('market_banners'); + } +} \ No newline at end of file diff --git a/src/database/migrations/2024_12_05_000001_create_market_detail.php b/src/database/migrations/2024_12_05_000001_create_market_detail.php new file mode 100644 index 0000000..787b65f --- /dev/null +++ b/src/database/migrations/2024_12_05_000001_create_market_detail.php @@ -0,0 +1,34 @@ +id(); + $table->bigInteger('item_id')->unsigned()->index(); + $table->string('title', '20')->nullable()->comment('추가 title'); + $table->string('comment', '50')->nullable()->comment('추가 설명'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + } + + + public function down() + { + Schema::dropIfExists('market_item_details'); + } +} \ No newline at end of file diff --git a/src/database/migrations/2024_12_06_000001_update_mall_config.php b/src/database/migrations/2024_12_06_000001_update_mall_config.php new file mode 100644 index 0000000..86140c4 --- /dev/null +++ b/src/database/migrations/2024_12_06_000001_update_mall_config.php @@ -0,0 +1,34 @@ +updateOrInsert( + ['key' => 'company'],['v' => '{"name":"\uc628\uc2a4\ud1a0\ub9ac\ubab0","businessNumber":"xxx-xx-xxxxx","mailOrderSalesRegistrationNumber":"\uc81cxxxx-\uc11c\uc6b8\uac15\ub0a8-xxxx\ud638","address":"\uc11c\uc6b8\ud2b9\ubcc4\uc2dc \uac15\ub0a8\uad6c \uba4b\uc9c4\ube4c\ub529 1F","representative":"\uae40\uc7ac\ubc8c","tel1":"02-xxxx-xxxx","fax1":"02-yyyy-yyyy"}'] + ); + + + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } +} diff --git a/src/database/migrations/2024_12_20_000001_create_market_coupon.php b/src/database/migrations/2024_12_20_000001_create_market_coupon.php new file mode 100644 index 0000000..b9f10e2 --- /dev/null +++ b/src/database/migrations/2024_12_20_000001_create_market_coupon.php @@ -0,0 +1,63 @@ +id(); + $table->string('title', '50')->comment('쿠폰명'); + $table->string('apply_type', '20')->comment('category, product, or all(카테고리별, 상품별, 전체)'); + $table->bigInteger('item_id')->unsigned()->nullable()->comment('apply_type.product 일 경우 적용 상품코드'); + $table->string('category', '12')->nullable()->comment('apply_type.category 일 경우 적용 카테고리'); + $table->integer('min_price')->default(0)->unsigned()->comment('최소결제 금액'); + $table->string('apply_amount_type', '10')->comment('price | percent'); + $table->integer('price')->nullable()->unsigned()->comment('apply_amount_type.price'); + $table->float('percentage')->nullable()->unsigned()->comment('apply_amount_type.percent'); + $table->integer('percentage_max_price')->nullable()->unsigned()->comment('apply_amount_type.percent 일경우 최대 할인금액'); + $table->timestamp('created_at')->comment('생성일'); + $table->softDeletes(); + }); + } + + if (!Schema::hasTable('market_coupon_issues')) { + Schema::create('market_coupon_issues', function(BluePrint $table) { + $table->id(); + $table->bigInteger('user_id')->unsigned()->comment('주문자아이디'); + $table->bigInteger('coupon_id')->unsigned()->index()->comment('쿠폰 아이디'); + $table->timestamp('created_at')->comment('발급일'); + $table->timestamp('expired_at')->comment('사용종료일(유효기간 만료일)'); + $table->timestamp('used_at')->comment('사용일'); + }); + } + + if (!Schema::hasColumn('market_payments', 'coupon_issue_id')) { + Schema::table('market_payments', function (Blueprint $table) { + $table->bigInteger('coupon_issue_id')->nullable()->unsigned()->comment('사용한 쿠폰 아이디')->after('amt_delivery'); + }); + } + + if (!Schema::hasColumn('market_payments', 'amt_coupon')) { + Schema::table('market_payments', function (Blueprint $table) { + $table->bigInteger('amt_coupon')->nullable()->unsigned()->comment('쿠폰 사용 금액')->after('coupon_issue_id'); + }); + } + + } + + public function down() + { + Schema::dropIfExists('market_coupons'); + Schema::dropIfExists('market_coupon_issues'); + } +} \ No newline at end of file diff --git a/src/helpers.php b/src/helpers.php index 665e69b..ff5f38f 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -11,23 +11,39 @@ function getImageUrl($url) { } } +if (!function_exists('delivery_fee_show')) { + function delivery_fee_show() { + $delivery = config('pondol-market.delivery'); + switch($delivery["type"]) { + case 'none': + return '무료'; + case 'on_delivery': + return '착불'; + case 'apply': + return number_format($delivery["fee"]); + case 'partial': + return number_format($delivery["fee"]).'('. number_format($delivery["min"]). ' 이상 구매시 무료) '; + } + } +} /** * $item * @return [[0] => 옵션 ID, [1] => 옵션명, [2] => 옵션값, [3] => 재고여부] */ -function extractOptions($item) { - if($item->options) { - $options = explode('|', $item->options); - $displayOption = []; - foreach($options as $option) { - array_push($displayOption, explode(':', $option)); - } - return $displayOption; - } +if (!function_exists('extractOptions')) { + function extractOptions($item) { + if($item->options) { + $options = explode('|', $item->options); + $displayOption = []; + foreach($options as $option) { + array_push($displayOption, explode(':', $option)); + } + return $displayOption; + } + } } - if (!function_exists('configSet')) { function configSet($file, $data) { diff --git a/src/resources/lang/en/market.php b/src/resources/lang/en/market.php index 6d3fa7a..8f7f48d 100644 --- a/src/resources/lang/en/market.php +++ b/src/resources/lang/en/market.php @@ -5,8 +5,8 @@ 'card'=>'신용카드', ], 'pay_status' => [ - '0'=>'지불대기', - '10'=>'지불완료', + '0'=>'결제대기', + '10'=>'결제완료', '20'=>'결제취소', ], 'delivery_status' => [ @@ -23,4 +23,16 @@ '79' => '교환완료', '90' => '거래완료'// (배송수취확인)' ], + 'coupon' => [ + 'apply_type' => [ + 'all'=>'전체상품', + 'product'=>'상품별', + 'category'=>'카테고리별' + ], + 'apply_amount_type' => [ + 'price'=>'금액', + 'percentage'=>'할인율', + ] + + ], ]; diff --git a/src/resources/lang/ko/market.php b/src/resources/lang/ko/market.php index 6d3fa7a..8f7f48d 100644 --- a/src/resources/lang/ko/market.php +++ b/src/resources/lang/ko/market.php @@ -5,8 +5,8 @@ 'card'=>'신용카드', ], 'pay_status' => [ - '0'=>'지불대기', - '10'=>'지불완료', + '0'=>'결제대기', + '10'=>'결제완료', '20'=>'결제취소', ], 'delivery_status' => [ @@ -23,4 +23,16 @@ '79' => '교환완료', '90' => '거래완료'// (배송수취확인)' ], + 'coupon' => [ + 'apply_type' => [ + 'all'=>'전체상품', + 'product'=>'상품별', + 'category'=>'카테고리별' + ], + 'apply_amount_type' => [ + 'price'=>'금액', + 'percentage'=>'할인율', + ] + + ], ]; diff --git a/src/resources/market/common.js b/src/resources/market/common.js index 75322ce..27770e1 100644 --- a/src/resources/market/common.js +++ b/src/resources/market/common.js @@ -1,368 +1,138 @@ - -/** - * 콤마삭제 - */ -function removeComma(str){ - var rtnstr=""; - if (str){ - for (var i=0; i 0; i--) { - if(str.substring(i, i - 1) != ",") { - val = str.substring(i, i - 1)+val; - } - } - x = val.length; - for(i = x; i > 0; i--) { - if(j % 3 == 0 && j != 0) { - rtn = val.substring(i, i - 1) + "," + rtn; - }else { - rtn = val.substring(i, i - 1) + rtn; - } - j++; - } - return rtn; -} - - // 숫자면 문자열로 변경 - str = typeof(str) == 'number' ? str.toString() : str; - // comma 를 제거한다. - number = str.replace(/[\,]/g, "") - - // sign +, - 가 존재하면 이 부분은 별도로 빼둔다. - var sign = number.match(/^[\+\-]/); - if(sign) { - number = number.replace(/^[\+\-]/, ""); - } - - // 숫자가 아닌 경우 삭제 - number = number.replace(/[^0-9]/g, ""); - number = setComma(number); - - if(sign != null) - number = sign + number; - - return number; -} - - -// 전화번호에 숫자를 입력 -function add_phone_hyphen(str) -{ - var phone = ''; - - if (!str) { - return; - } - - // 숫자면 문자열로 변경 - str = typeof(str) == 'number' ? str.toString() : str; - // 하이펀 제거한다. - phone = str.replace(/[\-]/g, "") - - // 숫자가 아닌 경우 삭제 - phone = phone.replace(/[^0-9]/g, ""); - - var len = phone.length; - if(len > 3 && len < 7) { - phone = phone.replace(/(\d{3})(\d+)/, '$1-$2'); - } else if(len <= 10) { - phone = phone.replace(/(\d{3})(\d{3})(\d+)/, '$1-$2-$3'); - } else { - phone = phone.replace(/(\d{3})(\d{4})(\d+)/, '$1-$2-$3'); - } - return phone ? phone : ''; -} - -/** - * 유니크한 값만 넣기 - */ -function array_push_unique(arr, item) { - if(arr.indexOf(item) === -1) { - arr.push(item); - return true; - } else { - return false; - } -} - -function removeElement(arr, elementToRemove) { - arr.forEach((item, index) => { - if (item === elementToRemove) { - arr.splice(index, 1); - } - }); - return arr; -} - -/** - * 우편번호 창 - **/ -var search_zip = function(frm_name, frm_zip, frm_addr1, frm_addr2, frm_addr3, frm_jibeon) { - if(typeof daum === 'undefined'){ - alert("다음 우편번호 postcode.v2.js 파일이 로드되지 않았습니다."); - return false; - } - - var zip_case = 0; //0이면 레이어, 1이면 페이지에 끼워 넣기, 2이면 새창 - - var complete_fn = function(data){ - - console.log(data); - // 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분. - - // 각 주소의 노출 규칙에 따라 주소를 조합한다. - // 내려오는 변수가 값이 없는 경우엔 공백('')값을 가지므로, 이를 참고하여 분기 한다. - var fullAddr = ''; // 최종 주소 변수 - var extraAddr = ''; // 조합형 주소 변수 - - // 사용자가 선택한 주소 타입에 따라 해당 주소 값을 가져온다. - if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우 - fullAddr = data.roadAddress; - - } else { // 사용자가 지번 주소를 선택했을 경우(J) - fullAddr = data.jibunAddress; - } - - // 사용자가 선택한 주소가 도로명 타입일때 조합한다. - if(data.userSelectedType === 'R'){ - //법정동명이 있을 경우 추가한다. - if(data.bname !== ''){ - extraAddr += data.bname; - } - // 건물명이 있을 경우 추가한다. - if(data.buildingName !== ''){ - extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName); - } - // 조합형주소의 유무에 따라 양쪽에 괄호를 추가하여 최종 주소를 만든다. - extraAddr = (extraAddr !== '' ? ' ('+ extraAddr +')' : ''); - } - - // 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다. - var of = document[frm_name]; - - of[frm_zip].value = data.zonecode; - - of[frm_addr1].value = fullAddr; - if(frm_addr3) { - of[frm_addr3].value = extraAddr; - } +// /** +// * 우편번호 창 +// **/ +// var search_zip = function(frm_name, frm_zip, frm_addr1, frm_addr2, frm_addr3, frm_jibeon) { +// if(typeof daum === 'undefined'){ +// alert("다음 우편번호 postcode.v2.js 파일이 로드되지 않았습니다."); +// return false; +// } + +// var zip_case = 0; //0이면 레이어, 1이면 페이지에 끼워 넣기, 2이면 새창 + +// var complete_fn = function(data){ + +// // 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분. + +// // 각 주소의 노출 규칙에 따라 주소를 조합한다. +// // 내려오는 변수가 값이 없는 경우엔 공백('')값을 가지므로, 이를 참고하여 분기 한다. +// var fullAddr = ''; // 최종 주소 변수 +// var extraAddr = ''; // 조합형 주소 변수 + +// // 사용자가 선택한 주소 타입에 따라 해당 주소 값을 가져온다. +// if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우 +// fullAddr = data.roadAddress; + +// } else { // 사용자가 지번 주소를 선택했을 경우(J) +// fullAddr = data.jibunAddress; +// } + +// // 사용자가 선택한 주소가 도로명 타입일때 조합한다. +// if(data.userSelectedType === 'R'){ +// //법정동명이 있을 경우 추가한다. +// if(data.bname !== ''){ +// extraAddr += data.bname; +// } +// // 건물명이 있을 경우 추가한다. +// if(data.buildingName !== ''){ +// extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName); +// } +// // 조합형주소의 유무에 따라 양쪽에 괄호를 추가하여 최종 주소를 만든다. +// extraAddr = (extraAddr !== '' ? ' ('+ extraAddr +')' : ''); +// } + +// // 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다. +// var of = document[frm_name]; + +// of[frm_zip].value = data.zonecode; + +// of[frm_addr1].value = fullAddr; +// if(frm_addr3) { +// of[frm_addr3].value = extraAddr; +// } - if(of[frm_jibeon] !== undefined){ - of[frm_jibeon].value = data.userSelectedType; - } - - of[frm_addr2].focus(); - }; - - switch(zip_case) { - case 1 : //iframe을 이용하여 페이지에 끼워 넣기 - var daum_pape_id = 'daum_juso_page'+frm_zip, - element_wrap = document.getElementById(daum_pape_id), - currentScroll = Math.max(document.body.scrollTop, document.documentElement.scrollTop); - if (element_wrap == null) { - element_wrap = document.createElement("div"); - element_wrap.setAttribute("id", daum_pape_id); - element_wrap.style.cssText = 'display:none;border:1px solid;left:0;width:100%;height:300px;margin:5px 0;position:relative;-webkit-overflow-scrolling:touch;'; - element_wrap.innerHTML = '접기 버튼'; - jQuery('form[name="'+frm_name+'"]').find('input[name="'+frm_addr1+'"]').before(element_wrap); - jQuery("#"+daum_pape_id).off("click", ".close_daum_juso").on("click", ".close_daum_juso", function(e){ - e.preventDefault(); - jQuery(this).parent().hide(); - }); - } - - new daum.Postcode({ - oncomplete: function(data) { - complete_fn(data); - // iframe을 넣은 element를 안보이게 한다. - element_wrap.style.display = 'none'; - // 우편번호 찾기 화면이 보이기 이전으로 scroll 위치를 되돌린다. - document.body.scrollTop = currentScroll; - }, - // 우편번호 찾기 화면 크기가 조정되었을때 실행할 코드를 작성하는 부분. - // iframe을 넣은 element의 높이값을 조정한다. - onresize : function(size) { - element_wrap.style.height = size.height + "px"; - }, - width : '100%', - height : '100%' - }).embed(element_wrap); - - // iframe을 넣은 element를 보이게 한다. - element_wrap.style.display = 'block'; - break; - case 2 : //새창으로 띄우기 - new daum.Postcode({ - oncomplete: function(data) { - complete_fn(data); - } - }).open(); - break; - default : //iframe을 이용하여 레이어 띄우기 - var rayer_id = 'daum_juso_rayer'+frm_zip, - element_layer = document.getElementById(rayer_id); - - if (element_layer == null) { - element_layer = document.createElement("div"); - element_layer.setAttribute("id", rayer_id); - element_layer.style.cssText = 'display:none;border:5px solid;position:fixed;width:300px;height:460px;left:50%;margin-left:-155px;top:50%;margin-top:-235px;overflow:hidden;-webkit-overflow-scrolling:touch;z-index:10000'; - element_layer.innerHTML = '닫기 버튼'; - document.body.appendChild(element_layer); - jQuery("#"+rayer_id).off("click", ".close_daum_juso").on("click", ".close_daum_juso", function(e){ - e.preventDefault(); - jQuery(this).parent().hide(); - }); - } - console.log('element_layer>>', element_layer); - new daum.Postcode({ - oncomplete: function(data) { - complete_fn(data); - // iframe을 넣은 element를 안보이게 한다. - element_layer.style.display = 'none'; - }, - width : '100%', - height : '100%' - }).embed(element_layer); - - // iframe을 넣은 element를 보이게 한다. - element_layer.style.display = 'block'; - } // switch(zip_case) { -} - - -function trim(s) -{ - var t = ""; - var from_pos = to_pos = 0; - - for (i=0; i=0; i--) - { - if (s.charAt(i-1) == ' ') - continue; - else - { - to_pos = i; - break; - } - } - - t = s.substring(from_pos, to_pos); - // alert(from_pos + ',' + to_pos + ',' + t+'.'); - return t; -} - -// 쿠키 입력 -function set_cookie(name, value, expirehours, domain) -{ - var today = new Date(); - today.setTime(today.getTime() + (60*60*1000*expirehours)); - document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";"; - if (domain) { - document.cookie += "domain=" + domain + ";"; - } -} - -// 쿠키 얻음 -function get_cookie(name) -{ - var find_sw = false; - var start, end; - var i = 0; - - for (i=0; i<= document.cookie.length; i++) - { - start = i; - end = start + name.length; - - if(document.cookie.substring(start, end) == name) - { - find_sw = true - break - } - } - - if (find_sw == true) - { - start = end + 1; - end = document.cookie.indexOf(";", start); - - if(end < start) - end = document.cookie.length; - - return unescape(document.cookie.substring(start, end)); - } - return ""; -} - -// 쿠키 지움 -function delete_cookie(name) -{ - var today = new Date(); - - today.setTime(today.getTime() - 1); - var value = get_cookie(name); - if(value != "") - document.cookie = name + "=" + value + "; path=/; expires=" + today.toGMTString(); -} - -// 새 창 -function window_open (url, winname, params) { - var defaultOpt = {width: 700, height: 500, scrollbars: 'auto'}; - - params = params || []; - var objs = [defaultOpt, params]; - var newOpts = objs.reduce(function (r, o) { - Object.keys(o).forEach(function (k) { - r[k] = o[k]; - }); - return r; - }, {}); - - newOpts.left = (document.body.offsetWidth / 2) - (200 / 2); - // 만들 팝업창 좌우 크기의 1/2 만큼 보정값으로 빼주었음 - - newOpts.top= (window.screen.height / 2) - (300 / 2); - // 만들 팝업창 상하 크기의 1/2 만큼 보정값으로 빼주었음 - - var opt = 'scrollbars = ' + newOpts.scrollbars + ', width=' + newOpts.width + ', height=' + newOpts.height + ', left=' + newOpts.left + ', top=' + newOpts.top; - window.open(url, winname, opt); -} - +// if(of[frm_jibeon] !== undefined){ +// of[frm_jibeon].value = data.userSelectedType; +// } + +// of[frm_addr2].focus(); +// }; + +// switch(zip_case) { +// case 1 : //iframe을 이용하여 페이지에 끼워 넣기 +// var daum_pape_id = 'daum_juso_page'+frm_zip, +// element_wrap = document.getElementById(daum_pape_id), +// currentScroll = Math.max(document.body.scrollTop, document.documentElement.scrollTop); +// if (element_wrap == null) { +// element_wrap = document.createElement("div"); +// element_wrap.setAttribute("id", daum_pape_id); +// element_wrap.style.cssText = 'display:none;border:1px solid;left:0;width:100%;height:300px;margin:5px 0;position:relative;-webkit-overflow-scrolling:touch;'; +// element_wrap.innerHTML = '접기 버튼'; +// jQuery('form[name="'+frm_name+'"]').find('input[name="'+frm_addr1+'"]').before(element_wrap); +// jQuery("#"+daum_pape_id).off("click", ".close_daum_juso").on("click", ".close_daum_juso", function(e){ +// e.preventDefault(); +// jQuery(this).parent().hide(); +// }); +// } + +// new daum.Postcode({ +// oncomplete: function(data) { +// complete_fn(data); +// // iframe을 넣은 element를 안보이게 한다. +// element_wrap.style.display = 'none'; +// // 우편번호 찾기 화면이 보이기 이전으로 scroll 위치를 되돌린다. +// document.body.scrollTop = currentScroll; +// }, +// // 우편번호 찾기 화면 크기가 조정되었을때 실행할 코드를 작성하는 부분. +// // iframe을 넣은 element의 높이값을 조정한다. +// onresize : function(size) { +// element_wrap.style.height = size.height + "px"; +// }, +// width : '100%', +// height : '100%' +// }).embed(element_wrap); + +// // iframe을 넣은 element를 보이게 한다. +// element_wrap.style.display = 'block'; +// break; +// case 2 : //새창으로 띄우기 +// new daum.Postcode({ +// oncomplete: function(data) { +// complete_fn(data); +// } +// }).open(); +// break; +// default : //iframe을 이용하여 레이어 띄우기 +// var rayer_id = 'daum_juso_rayer'+frm_zip, +// element_layer = document.getElementById(rayer_id); + +// if (element_layer == null) { +// element_layer = document.createElement("div"); +// element_layer.setAttribute("id", rayer_id); +// element_layer.style.cssText = 'display:none;border:5px solid;position:fixed;width:300px;height:460px;left:50%;margin-left:-155px;top:50%;margin-top:-235px;overflow:hidden;-webkit-overflow-scrolling:touch;z-index:10000'; +// element_layer.innerHTML = '닫기 버튼'; +// document.body.appendChild(element_layer); +// jQuery("#"+rayer_id).off("click", ".close_daum_juso").on("click", ".close_daum_juso", function(e){ +// e.preventDefault(); +// jQuery(this).parent().hide(); +// }); +// } +// console.log('element_layer>>', element_layer); +// new daum.Postcode({ +// oncomplete: function(data) { +// complete_fn(data); +// // iframe을 넣은 element를 안보이게 한다. +// element_layer.style.display = 'none'; +// }, +// width : '100%', +// height : '100%' +// }).embed(element_layer); + +// // iframe을 넣은 element를 보이게 한다. +// element_layer.style.display = 'block'; +// } // switch(zip_case) { +// } + +/** delivery-tracking 에서 처리할 예정 */ function delivery_logs(courier, invoicenumber) { if(!invoicenumber) { return alert('물품 대기 중입니다.'); diff --git a/src/resources/market/magnifier.js b/src/resources/market/magnifier.js new file mode 100644 index 0000000..e74092a --- /dev/null +++ b/src/resources/market/magnifier.js @@ -0,0 +1,70 @@ +// 커서 위치를 계산하는 함수를 정의합니다. +function getCursorPos(e, img) { + var imgOffset = img.offset(); + let x = e.pageX - imgOffset.left; + let y = e.pageY - imgOffset.top; + +// console.log('xy:', x, y); + if (e.type === 'touchmove') { + x = e.originalEvent.touches[0].pageX - imgOffset.left; + y = e.originalEvent.touches[0].pageY - imgOffset.top; + } + + x -= window.scrollX; + y -= window.scrollY; + + return { x, y }; +} + + +function magnify() { + $(".thum-box").on('mouseenter', function(e){ + $(".zoom-result").show(); + var img = $("#prd-image"); + var result = $(".zoom-result"); + var lens = $(".zoom-lens"); + + var resultSize = {width: result.width(), height: result.height()}; + var lensSize = {width: lens.width(), height: lens.height()}; + + // 렌즈와 결과 영역의 배경 이미지의 크기 배율을 계산합니다. + var cx = resultSize.width / lensSize.width; + var cy = resultSize.height / lensSize.height; + + result.css({ + "backgroundImage": `url(${img.attr('src')})`, + "backgroundSize": `${img.width() * cx}px ${img.height() * cy}px` + }); + + imageZoom(img, result, lensSize, cx, cy, lens); + }); + + $(".thum-box").on('mouseleave', function(e){ + $(".zoom-result").hide(); + }); +} + +function imageZoom(img, result,lensSize, cx, cy, lens ) { + // 필요한 요소들을 선택 또는 생성합니다. + // 결과 영역에 배경 이미지를 설정합니다. + + + // 마우스 이동 또는 터치 이벤트에 대한 핸들러를 설정합니다. + // lens.add(img).on('mousemove touchmove', function (e) { + lens.add(img).on('mousemove touchmove', function (e) { + e.preventDefault(); + var pos = getCursorPos(e, img); + + // 렌즈가 이미지 범위를 넘어가지 않도록 조절합니다. + var x = pos.x - lensSize.width / 2; + var y = pos.y - lensSize.height / 2; + + // 렌즈와 결과 영역의 위치를 업데이트합니다. + lens.css({ left: x, top: y }); + result.css('backgroundPosition', `-${x * cx}px -${y * cy}px`); + }); +} +$(function(){ + magnify(); +}) + diff --git a/src/resources/views/3rdparty-templates/auth/default-market/register.blade.php b/src/resources/views/3rdparty-templates/auth/default-market/register.blade.php index 977e577..52e84d5 100644 --- a/src/resources/views/3rdparty-templates/auth/default-market/register.blade.php +++ b/src/resources/views/3rdparty-templates/auth/default-market/register.blade.php @@ -97,15 +97,16 @@ if (!email) { return showToaster({title: '알림', message: '이메일을 입력해주세요'}); } + ROUTE.ajaxroute('get', - {route: 'validation.email', segments:[email]}, - function(resp) { - if(resp.error) { - showToaster({title: '알림', message: resp.error}); - } else { - showToaster({title: '알림', message: '사용가능한 이메일입니다.', alert: false}); - } - }) + {route: 'validation.email', segments:[email]}, + function(resp) { + if(resp.error) { + showToaster({title: '알림', message: resp.error}); + } else { + showToaster({title: '알림', message: '사용가능한 이메일입니다.', alert: false}); + } + }) }) $("#check-all").click(function(){ diff --git a/src/resources/views/3rdparty-templates/mail/default-market/register.blade.php b/src/resources/views/3rdparty-templates/mail/default-market/register.blade.php index f08557a..ea3557c 100644 --- a/src/resources/views/3rdparty-templates/mail/default-market/register.blade.php +++ b/src/resources/views/3rdparty-templates/mail/default-market/register.blade.php @@ -24,12 +24,7 @@ email : {{$notifiable->email}}
-
- {{config('pondol-market.company.name')}} / - 사업번호 : {{config('pondol-market.company.businessNumber')}} / - 대표 : {{config('pondol-market.company.representative')}}
- 주소 : {{config('pondol-market.company.address')}} -
+ diff --git a/src/resources/views/admin/cancel-return-exchange/index.blade.php b/src/resources/views/admin/cancel-return-exchange/index.blade.php index 1527629..5e3de35 100644 --- a/src/resources/views/admin/cancel-return-exchange/index.blade.php +++ b/src/resources/views/admin/cancel-return-exchange/index.blade.php @@ -28,14 +28,14 @@ -->
- delivery_status) && in_array('60', request()->delivery_status)) checked @endif> + types) && in_array('refund', request()->types)) checked @endif>
- delivery_status) && in_array('70', request()->delivery_status)) checked @endif> + types) && in_array('exchange', request()->types)) checked @endif>
diff --git a/src/resources/views/admin/config/company.blade.php b/src/resources/views/admin/config/company.blade.php index 4e553dc..0d487d6 100644 --- a/src/resources/views/admin/config/company.blade.php +++ b/src/resources/views/admin/config/company.blade.php @@ -15,48 +15,54 @@
- @csrf - @method('PUT') -
-
- - 쇼핑몰명은 .env 파일의 APP_NAME 에서 설정 하시기 바랍니다. -
-
- - -
-
- - -
+ @csrf + @method('PUT') +
+
+ + 쇼핑몰명은 .env 파일의 APP_NAME 에서 설정 하시기 바랍니다. +
+
+ + +
+
+ + +
- - + +
- - + +
- - + +
- - + +
+
- - + + +
+
+ +
-
+ +
-
+
@section('styles') @@ -67,7 +73,7 @@ @parent @endsection diff --git a/src/resources/views/admin/config/delivery.blade.php b/src/resources/views/admin/config/delivery.blade.php index 01dcf00..f965e19 100644 --- a/src/resources/views/admin/config/delivery.blade.php +++ b/src/resources/views/admin/config/delivery.blade.php @@ -39,7 +39,16 @@
- 배송비 미 적용 + 배송비 무료 +
+ + +
+
+ +
+
+ 배송비 착불
diff --git a/src/resources/views/admin/coupon/create.blade.php b/src/resources/views/admin/coupon/create.blade.php new file mode 100644 index 0000000..e177fe5 --- /dev/null +++ b/src/resources/views/admin/coupon/create.blade.php @@ -0,0 +1,177 @@ +@section('title', '쿠폰등록') + + +
+

쿠폰등록

+ +
+
+
쿠폰 등록 및 수정이 가능합니다.
+
+
+
+ +@if($item->id) +
+ @method('PUT') +@else + +@endif +@csrf +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
쿠폰명
쿠폰 종류 +
+
+ + +
+
+ + +
+
+ + +
+
+
총 구매금액 +
+ +
이상
+
+
적용방식 +
+
+ + +
+
+ + +
+
+
+
+ +
+
+ +
+
+ + @if($item->id) + + @else + + @endif +
+
+ + + + +@include("market::admin.coupon.modal-find-product") + +@section('styles') +@parent +@endsection + +@section('scripts') +@parent + + +@endsection +
\ No newline at end of file diff --git a/src/resources/views/admin/coupon/index.blade.php b/src/resources/views/admin/coupon/index.blade.php new file mode 100644 index 0000000..81a8667 --- /dev/null +++ b/src/resources/views/admin/coupon/index.blade.php @@ -0,0 +1,125 @@ +@section('title', '쿠폰발급') + + +
+

쿠폰발급

+ +
+
+
등록된 쿠폰을 이용하여 고객에게 쿠폰을 발급하실 수 있습니다.
+
+
+
+{{-- +
+
+
+
+ +
+
+ 기간설정 ▶ +
+ + + + + +
+
+
+ +
+
+ +
+
+
+ + + + + + +
+
+ +
+
+ + + +
+
+
+ +
+
+
+
+--}} + +쿠폰등록 + +
+
+ + + + + + + + + + + @forelse ($items as $item) + + + + + + + + + @empty + + + + @endforelse +
쿠폰명쿠폰 종류 최소 구매 금액적용방식
{{$item->title}}@lang('market::market.coupon.apply_type.'.$item->apply_type){{number_format($item->min_price)}}@lang('market::market.coupon.apply_amount_type.'.$item->apply_amount_type) + @if($item->apply_amount_type == 'price') + {{ number_format($item->price)}} 원 할인 + @elseif($item->apply_amount_type == 'percentage') + {{ $item->percentage}}% 할인 (최대 {{ number_format($item->percentage_max_price)}}) + @endif + + + 발급하기 +
+ 검색된 쿠폰이 없습니다. +
+ +
+ +
+ +@section('styles') + @parent +@endsection + +@section('scripts') + @parent +@endsection +
\ No newline at end of file diff --git a/src/resources/views/admin/coupon/issue.blade.php b/src/resources/views/admin/coupon/issue.blade.php new file mode 100644 index 0000000..fefce3d --- /dev/null +++ b/src/resources/views/admin/coupon/issue.blade.php @@ -0,0 +1,191 @@ +@section('title', '쿠폰등록') + + +
+

쿠폰발급

+ +
+
+
선택된 현재 쿠폰에 대하여 고객에게 쿠폰을 발급할 수 있습니다.
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
쿠폰명{{$coupon->title}}
쿠폰 종류@lang('market::market.coupon.apply_type.'.$coupon->apply_type) +
총 구매금액{{number_format($coupon->min_price)}} 이상
적용방식@lang('market::market.coupon.apply_amount_type.'.$coupon->apply_amount_type)
+ @if($coupon->apply_amount_type == 'price') +
+ +
+
+ @elseif($coupon->apply_amount_type == 'percentage') +
+ +
%
+
최대
+ +
미만
+
+ @endif +
+
+ + + + +
+ + +
+
+ 쿠폰 발급 +
+ +
+ @csrf +
+
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ +
+ + ......... +
+
+ +
+ +
+
+ + +
+
+
+ +
+ + + + +
+
+ + + +@section('styles') +@parent +@endsection + +@section('scripts') +@parent + +@endsection +
\ No newline at end of file diff --git a/src/resources/views/admin/coupon/issues.blade.php b/src/resources/views/admin/coupon/issues.blade.php new file mode 100644 index 0000000..ac2ea18 --- /dev/null +++ b/src/resources/views/admin/coupon/issues.blade.php @@ -0,0 +1,132 @@ +@section('title', '쿠폰발급') + + +
+

쿠폰발급

+ +
+
+
등록된 쿠폰을 이용하여 고객에게 쿠폰을 발급하실 수 있습니다.
+
+
+
+ +
+
+
+
+ +
+
+ 기간설정 ▶ +
+ + + + + +
+
+
+ +
+
+ +
+
+
+ + + + + + +
+
+ +
+
+ + + +
+
+
+ +
+
+
+
+ + +
+
+ + + + + + + + + + + + @forelse ($items as $item) + + + + + + + + + + + @empty + + + + @endforelse +
쿠폰명최소 구매 금액할인금액(율)지급 유저지급일사용일사용기한
{{$item->title}}{{number_format($item->min_price)}} + @if($item->apply_amount_type == 'price') + {{ number_format($item->price)}} 원 할인 + @elseif($item->apply_amount_type == 'percentage') + {{ $item->percentage}}% 할인 (최대 {{ number_format($item->percentage_max_price)}}) + @endif + + + {{ $item->name}}({{$item->email}}) + + {{ $item->created_at}} + + {{ $item->used_at}} + + {{ $item->expired_at}} +
+ 검색된 쿠폰이 없습니다. +
+ +
+ +
+ +@section('styles') + @parent +@endsection + +@section('scripts') + @parent +@endsection +
\ No newline at end of file diff --git a/src/resources/views/admin/coupon/modal-find-product.blade.php b/src/resources/views/admin/coupon/modal-find-product.blade.php new file mode 100644 index 0000000..4a0a68e --- /dev/null +++ b/src/resources/views/admin/coupon/modal-find-product.blade.php @@ -0,0 +1,73 @@ + + + +@section('scripts') +@parent + + +@endsection \ No newline at end of file diff --git a/src/resources/views/admin/coupon/sel-category.blade.php b/src/resources/views/admin/coupon/sel-category.blade.php new file mode 100644 index 0000000..2f1beff --- /dev/null +++ b/src/resources/views/admin/coupon/sel-category.blade.php @@ -0,0 +1,147 @@ + +
+
+ +@section('scripts') +@parent + +@endsection \ No newline at end of file diff --git a/src/resources/views/admin/dev/mail.blade.php b/src/resources/views/admin/dev/mail.blade.php index 9853707..4303e45 100644 --- a/src/resources/views/admin/dev/mail.blade.php +++ b/src/resources/views/admin/dev/mail.blade.php @@ -25,24 +25,30 @@ + + -
- +
+
+
+ + +
-
+
-
+
-
+
@@ -57,6 +63,11 @@ @section('styles') @parent + @endsection @section('scripts') @@ -74,6 +85,25 @@ function(resp) { } }) }); + + $("select[name='type']").on('change', function(){ + var val = $(this).val(); + $(".element").hide(); + switch(val) { + case 'notice': //알림 + $(".element.notice").css('display', 'flex'); + break; + case 'order': //주문 + $(".element.order").css('display', 'flex'); + break; + case 'register': //회원가입 + $(".element.register").css('display', 'flex'); + break; + case 'resetpassword': // 패스워드 찾기 + $(".element.resetpassword").css('display', 'flex'); + break; + } + }) }) @endsection diff --git a/src/resources/views/admin/item/create.blade.php b/src/resources/views/admin/item/create.blade.php index 666cf31..6788b28 100644 --- a/src/resources/views/admin/item/create.blade.php +++ b/src/resources/views/admin/item/create.blade.php @@ -28,57 +28,61 @@ - 카테고리 + 카테고리 @include("market::admin.item.sub-category", ['category'=>$categories]) - 상품명 + 상품명 - 상품모델명 + 상품모델명 - 사용하지 않을경우 공백처리 - 시중가 + 시중가 - 판매가 + 판매가 - 지급포인트 + 지급포인트 - 재고수량 + 재고수량 제한없음(-1), 품절(0), 기타 재고수량 입력 - 등록옵션 + 등록옵션 @include("market::admin.item.sub-option", []) - 이미지 + 추가필드 + @include("market::admin.item.sub-spec", []) + + + 이미지 @include("market::admin.item.sub-image", ['images'=>$images]) - 간략설명 + 간략설명 - 자세한설명 + 자세한설명 @include ('editor::default', ['name'=>'description', 'id'=>'description', 'value'=>$item->description, 'attr'=>['class'=>'form-control']]) - 태그 + 태그 @include("market::admin.item.sub-tag") - 표시 옵션 + 표시 옵션
대표이미지
- + @if($item->image) @endif diff --git a/src/resources/views/admin/item/sub-option.blade.php b/src/resources/views/admin/item/sub-option.blade.php index b4e8f18..fec2117 100644 --- a/src/resources/views/admin/item/sub-option.blade.php +++ b/src/resources/views/admin/item/sub-option.blade.php @@ -1,4 +1,4 @@ -
옵션 1
+
옵션
옵션등록법 : 옵션1:추가가격1:재고여부1|옵션2:추가가격1:재고여부2 (예, blue:0:1|red:1000:0) (재고여부 : 0: 품절, 1: 재고있음)
diff --git a/src/resources/views/admin/item/sub-spec.blade.php b/src/resources/views/admin/item/sub-spec.blade.php new file mode 100644 index 0000000..53f62ff --- /dev/null +++ b/src/resources/views/admin/item/sub-spec.blade.php @@ -0,0 +1,51 @@ +
추가필드
+
추가필드 : 상품상세페이지에 단순한 출력용으로만 사용할 경우 +
+
+@section('styles') +@parent + +@endsection +@section('scripts') +@parent + +@endsection \ No newline at end of file diff --git a/src/resources/views/admin/order/index.blade.php b/src/resources/views/admin/order/index.blade.php index 1ac5690..55d9be2 100644 --- a/src/resources/views/admin/order/index.blade.php +++ b/src/resources/views/admin/order/index.blade.php @@ -110,9 +110,9 @@ {{$item->name}} @if($item->count > 1 ) 외 {{($item->count - 1)}}건 @endif
({{$item->o_id}}) - {{ __('market.pay_method.'.$item->method) }} - {{ __('market.pay_status.'.$item->status) }} - {{ __('market.delivery_status.'.$item->delivery_status) }} + {{ __('market::market.pay_method.'.$item->method) }} + {{ __('market::market.pay_status.'.$item->status) }} + {{ __('market::market.delivery_status.'.$item->delivery_status) }} {{$item->user_name}} {{$item->created_at}} 상세보기 diff --git a/src/resources/views/admin/order/view.blade.php b/src/resources/views/admin/order/view.blade.php index 1c34762..f6bfd7e 100644 --- a/src/resources/views/admin/order/view.blade.php +++ b/src/resources/views/admin/order/view.blade.php @@ -152,7 +152,7 @@
-
{{ __('market.pay_method.'.$display->method) }}
+
{{ __('market::market.pay_method.'.$display->method) }}
@if(@$display->method == 'online') diff --git a/src/resources/views/components/app-admin.blade.php b/src/resources/views/components/app-admin.blade.php index 1777099..fc20f1a 100644 --- a/src/resources/views/components/app-admin.blade.php +++ b/src/resources/views/components/app-admin.blade.php @@ -1,7 +1,7 @@ @php $path = isset($path) ? $path : []; @endphp - +
@@ -12,9 +12,7 @@
- - @section('styles') @parent