diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php index 4371d5a..90e9adf 100644 --- a/app/Http/Controllers/SettingController.php +++ b/app/Http/Controllers/SettingController.php @@ -23,7 +23,6 @@ class SettingController extends Controller { $request->validate([ 'OPEN_WEBSITE_NAME' => 'required|string', - 'VOUCHER_STOCK_NOTIFICATION' => 'required|numeric', 'AFFILATE_ENABLED' => 'required|in:0,1', 'AFFILATE_POIN_AMOUNT' => 'required|numeric', 'MIDTRANS_SERVER_KEY' => 'required|string', diff --git a/app/Models/CashDepositLocation.php b/app/Models/CashDepositLocation.php new file mode 100644 index 0000000..0463d91 --- /dev/null +++ b/app/Models/CashDepositLocation.php @@ -0,0 +1,11 @@ +batch_id == '') { - $voucher->batch_id = Str::ulid(); - } - if ($voucher->price == '') { - $price = $voucher->display_price; - if ($voucher->discount > 0) { - $price = $voucher->display_price - round($voucher->display_price * ($voucher->discount / 100), 2); - } - - $voucher->price = $price; - } - }); - - static::updating(function (Voucher $voucher) { - $price = $voucher->display_price; - if ($voucher->discount > 0) { - $price = $voucher->display_price - round($voucher->display_price * ($voucher->discount / 100), 2); - } - - $voucher->price = $price; - }); - } - - public function displayQuota(): Attribute - { - return Attribute::make(get: function () { - return round($this->quota / (1024 * 1024 * 1024), 2) . ' GB'; - }); - } - - public function displayExpired(): Attribute - { - return Attribute::make(get: function () { - return $this->expired . ' ' . $this->expired_unit; - }); - } - - public function validatePrice(): Attribute - { - return Attribute::make(get: function () { - if (auth('customer')->check()) { - if ($this->prices()->count() > 0) { - $price = $this->prices()->where('customer_level_id', auth()->user()->customer_level_id)->value('price'); - - return $price; - } - } - - return $this->price; - }); - } - - public function validateDisplayPrice(): Attribute - { - return Attribute::make(get: function () { - if (auth('customer')->check()) { - if ($this->prices()->count() > 0) { - $price = $this->prices()->where('customer_level_id', auth()->user()->customer_level_id)->value('display_price'); - - return $price; - } - } - - return $this->display_price; - }); - } - - public function location() - { - return $this->belongsTo(Location::class)->withTrashed(); - } - - public function prices() - { - return $this->hasMany(VoucherPrice::class); - } - public function shuffle_unsold() { $voucher = Voucher::where([ diff --git a/app/Models/VoucherPrice.php b/app/Models/VoucherPrice.php deleted file mode 100644 index bf00819..0000000 --- a/app/Models/VoucherPrice.php +++ /dev/null @@ -1,18 +0,0 @@ -belongsTo(CustomerLevel::class, 'customer_level_id'); - } -} diff --git a/database/migrations/2023_05_24_130522_create_vouchers_table.php b/database/migrations/2023_05_24_130522_create_vouchers_table.php index 0b840be..bf5072c 100644 --- a/database/migrations/2023_05_24_130522_create_vouchers_table.php +++ b/database/migrations/2023_05_24_130522_create_vouchers_table.php @@ -16,20 +16,13 @@ return new class extends Migration $table->string('name')->nullable(); $table->string('description')->nullable(); - $table->ulid('location_id')->nullable(); + $table->ulid('location_profile_id')->nullable(); $table->string('username')->nullable(); $table->string('password')->nullable(); - $table->decimal('price_poin', 20, 2)->default(0); - $table->decimal('price', 20, 2)->default(0); - $table->decimal('discount', 20, 0)->default(0); - $table->decimal('display_price', 20, 2)->default(0); $table->string('quota')->nullable(); $table->string('profile')->nullable(); $table->text('comment')->nullable(); - $table->string('expired')->nullable(); - $table->string('expired_unit')->nullable(); $table->smallInteger('is_sold')->default(0); - $table->ulid('batch_id')->nullable(); $table->text('additional_json')->nullable(); $table->timestamps(); diff --git a/database/migrations/2023_05_24_130552_create_customers_table.php b/database/migrations/2023_05_24_130552_create_customers_table.php index f1e14d1..ef954f3 100644 --- a/database/migrations/2023_05_24_130552_create_customers_table.php +++ b/database/migrations/2023_05_24_130552_create_customers_table.php @@ -30,6 +30,7 @@ return new class extends Migration $table->string('identity_image')->nullable(); $table->ulid('customer_level_id')->nullable(); $table->text('google_oauth_response')->nullable(); + $table->timestamp('poin_expired_at')->nullable(); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2023_05_24_182840_create_accounts_table.php b/database/migrations/2023_05_24_182840_create_accounts_table.php index 373c682..c4292eb 100644 --- a/database/migrations/2023_05_24_182840_create_accounts_table.php +++ b/database/migrations/2023_05_24_182840_create_accounts_table.php @@ -18,6 +18,8 @@ return new class extends Migration $table->string('bank_name')->nullable(); $table->string('holder_name')->nullable(); $table->string('account_number')->nullable(); + $table->string('logo')->nullable(); + $table->decimal('admin_fee', 20, 2)->nullable(); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2023_06_16_071000_create_location_profiles_table.php b/database/migrations/2023_06_16_071000_create_location_profiles_table.php new file mode 100644 index 0000000..d84fe7f --- /dev/null +++ b/database/migrations/2023_06_16_071000_create_location_profiles_table.php @@ -0,0 +1,47 @@ +ulid('id')->primary(); + + $table->ulid('location_id')->nullable(); + $table->string('name')->nullable(); + $table->string('quota')->nullable(); + $table->string('display_note')->nullable(); + $table->string('expired')->nullable(); + $table->string('expired_unit')->nullable(); + $table->string('description')->nullable(); + $table->integer('min_stock')->default(0); + + $table->decimal('price', 20, 2)->default(0); + $table->decimal('display_price', 20, 2)->default(0); + $table->decimal('discount', 20, 0)->default(0); + $table->decimal('price_poin', 20, 2)->default(0); + $table->decimal('bonus_poin', 20, 2)->default(0); + + $table->timestamps(); + $table->softDeletes(); + $table->ulid('created_by')->nullable(); + $table->ulid('updated_by')->nullable(); + $table->ulid('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('location_profiles'); + } +}; diff --git a/database/migrations/2023_05_24_130523_create_voucher_prices_table.php b/database/migrations/2023_06_16_071008_create_location_profile_prices_table.php similarity index 68% rename from database/migrations/2023_05_24_130523_create_voucher_prices_table.php rename to database/migrations/2023_06_16_071008_create_location_profile_prices_table.php index 2316553..515d05d 100644 --- a/database/migrations/2023_05_24_130523_create_voucher_prices_table.php +++ b/database/migrations/2023_06_16_071008_create_location_profile_prices_table.php @@ -11,13 +11,16 @@ return new class extends Migration */ public function up(): void { - Schema::create('voucher_prices', function (Blueprint $table) { + Schema::create('location_profile_prices', function (Blueprint $table) { $table->ulid('id')->primary(); + $table->ulid('location_profile_id')->nullable(); $table->ulid('customer_level_id')->nullable(); - $table->ulid('voucher_id')->nullable(); $table->decimal('price', 20, 2)->default(0); $table->decimal('display_price', 20, 2)->default(0); + $table->decimal('discount', 20, 0)->default(0); + $table->decimal('price_poin', 20, 2)->default(0); + $table->decimal('bonus_poin', 20, 2)->default(0); $table->timestamps(); $table->softDeletes(); @@ -32,6 +35,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('voucher_prices'); + Schema::dropIfExists('location_profile_prices'); } }; diff --git a/database/migrations/2023_06_16_071025_create_customer_location_favorites_table.php b/database/migrations/2023_06_16_071025_create_customer_location_favorites_table.php new file mode 100644 index 0000000..fb057cc --- /dev/null +++ b/database/migrations/2023_06_16_071025_create_customer_location_favorites_table.php @@ -0,0 +1,35 @@ +ulid('id')->primary(); + + $table->ulid('location_id')->nullable(); + $table->ulid('customer_id')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + $table->ulid('created_by')->nullable(); + $table->ulid('updated_by')->nullable(); + $table->ulid('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('customer_location_favorites'); + } +}; diff --git a/database/migrations/2023_06_16_071037_create_customer_carts_table.php b/database/migrations/2023_06_16_071037_create_customer_carts_table.php new file mode 100644 index 0000000..d258009 --- /dev/null +++ b/database/migrations/2023_06_16_071037_create_customer_carts_table.php @@ -0,0 +1,40 @@ +ulid('id')->primary(); + + $table->ulid('customer_id')->nullable(); + $table->ulid('sale_id')->nullable(); + $table->string('entity_type')->nullable(); + $table->ulid('entity_id')->nullable(); + $table->decimal('price', 20, 2)->default(0); + $table->integer('quantity')->default(0); + $table->text('additional_info_json')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + $table->ulid('created_by')->nullable(); + $table->ulid('updated_by')->nullable(); + $table->ulid('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('customer_carts'); + } +}; diff --git a/database/migrations/2023_06_16_071723_create_cash_deposit_locations_table.php b/database/migrations/2023_06_16_071723_create_cash_deposit_locations_table.php new file mode 100644 index 0000000..6c7fb3c --- /dev/null +++ b/database/migrations/2023_06_16_071723_create_cash_deposit_locations_table.php @@ -0,0 +1,42 @@ +ulid('id')->primary(); + + $table->string('name')->nullable(); + $table->text('address')->nullable(); + $table->string('phone')->nullable(); + $table->string('gmap_url', 1000)->nullable(); + $table->string('image')->nullable(); + $table->text('description')->nullable(); + $table->string('open_hour')->nullable(); + $table->string('close_hour')->nullable(); + $table->smallInteger('is_active')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + $table->ulid('created_by')->nullable(); + $table->ulid('updated_by')->nullable(); + $table->ulid('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('cash_deposit_locations'); + } +}; diff --git a/database/seeders/InstallationSeed.php b/database/seeders/InstallationSeed.php index 8f4b9dd..7b3e4e6 100644 --- a/database/seeders/InstallationSeed.php +++ b/database/seeders/InstallationSeed.php @@ -24,14 +24,23 @@ class InstallationSeed extends Seeder ['key' => 'AFFILATE_ENABLED', 'value' => '0', 'type' => 'checkbox'], ['key' => 'AFFILATE_POIN_AMOUNT', 'value' => '0', 'type' => 'text'], + ['key' => 'AFFILATE_DOWNLINE_POIN_AMOUNT', 'value' => '0', 'type' => 'text'], ['key' => 'MIDTRANS_SERVER_KEY', 'value' => 'SB-Mid-server-UA0LQbY4aALV0CfLLX1v7xs8', 'type' => 'text'], ['key' => 'MIDTRANS_CLIENT_KEY', 'value' => 'SB-Mid-client-xqqkspzoZOM10iUG', 'type' => 'text'], ['key' => 'MIDTRANS_MERCHANT_ID', 'value' => 'G561244367', 'type' => 'text'], ['key' => 'MIDTRANS_LOGO', 'value' => 'sample/midtrans_logo.png', 'type' => 'image'], ['key' => 'MIDTRANS_ENABLED', 'value' => '0', 'type' => 'text'], + ['key' => 'MIDTRANS_ADMIN_FEE', 'value' => '2500', 'type' => 'text'], - ['key' => 'VOUCHER_STOCK_NOTIFICATION', 'value' => '10', 'type' => 'text'], + // ['key' => 'VOUCHER_STOCK_NOTIFICATION', 'value' => '10', 'type' => 'text'], + + ['key' => 'ENABLE_CASH_DEPOSIT', 'value' => '0', 'type' => 'text'], + ['key' => 'ENABLE_MANUAL_TRANSFER', 'value' => '0', 'type' => 'text'], + ['key' => 'MAX_MANUAL_TRANSFER_TIMEOUT', 'value' => '2', 'type' => 'text'], //dalam jam + ['key' => 'MANUAL_TRANSFER_OPEN_HOUR', 'value' => '06:00', 'type' => 'text'], + ['key' => 'MANUAL_TRANSFER_CLOSE_HOUR', 'value' => '23:00', 'type' => 'text'], + ['key' => 'MAX_POINT_EXPIRED', 'value' => '90', 'type' => 'text'], //dalam hari ]; foreach ($settings as $setting) { diff --git a/resources/js/Customer/Components/FormLocation.jsx b/resources/js/Customer/Components/FormLocation.jsx new file mode 100644 index 0000000..8df9d99 --- /dev/null +++ b/resources/js/Customer/Components/FormLocation.jsx @@ -0,0 +1,51 @@ +import React from 'react' +import { isEmpty } from 'lodash' +import { HiFilter } from 'react-icons/hi' + +export default function FormLocation({ + type, + name, + onChange, + value, + label, + autoComplete, + autoFocus, + placeholder, + disabled, + readOnly, + onKeyDownCapture, + max, + min, +}) { + return ( + <> + +