mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 707c48ab12 | |||
| 6d006ba60b | |||
| 1be405ca93 | |||
| 353bf0ffbd | |||
| df3024186b |
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface KeyValueInterface
|
||||
{
|
||||
|
||||
public function attributes(): morphMany;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class KeyValuePairObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $key;
|
||||
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
|
||||
/**
|
||||
* KeyValuePairObject constructor.
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct(string $key, string $value)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\KeyValueInterface;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Models\KeyValuePair;
|
||||
|
||||
class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param KeyValueInterface $kv
|
||||
* @param KeyValuePairObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
|
||||
public function execute(KeyValueInterface $kv, KeyValuePairObject $object) {
|
||||
$model = new KeyValuePair();
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($kv->attributes(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,17 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -43,6 +46,11 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -51,8 +59,9 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
* @param CreatesKeyValuePair $createsKeyValuePair
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor, CreatesKeyValuePair $createsKeyValuePair)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
@@ -60,12 +69,16 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$isTermsAgreed = $request->input('is_terms_agree');
|
||||
if(!$isTermsAgreed){
|
||||
throw new RequestValidationException('You must read and agree to our terms and conditions to proceed');
|
||||
}
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
@@ -91,8 +104,15 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
|
||||
}
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
"TERMS_AND_CONDITIONS",
|
||||
$isTermsAgreed
|
||||
);
|
||||
$this->createsKeyValuePair->execute($order, $keyValuePairObject);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->newLeadTaskToPerfexCRMProcessor->execute($company);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class CreateOrderProcessor
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Address $address
|
||||
* @param int|null $orderNumber
|
||||
* @return Addressable
|
||||
* @return Order
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
|
||||
class KeyValuePair extends AbstractModel
|
||||
{
|
||||
protected $table = 'key_value_pairs';
|
||||
|
||||
public function owner(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Addressable;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\General\Interfaces\KeyValueInterface;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\General\Interfaces\Notifiable;
|
||||
@@ -19,7 +20,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
||||
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable, KeyValueInterface
|
||||
{
|
||||
use SoftDeletes;
|
||||
use HasRelationships;
|
||||
@@ -169,4 +170,9 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [PackingList::class], ['owner_id', 'owner_id'], ['id', 'id']);
|
||||
}
|
||||
|
||||
public function attributes(): MorphMany
|
||||
{
|
||||
return $this->morphMany(KeyValuePair::class, 'owner');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateKeyValuePairsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('key_value_pairs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_type'); //'user', 'order', 'transaction'
|
||||
$table->unsignedBigInteger('owner_id');
|
||||
$table->string('key');
|
||||
$table->string('value');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['owner_type', 'owner_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('key_value_pairs');
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -116,9 +116,10 @@
|
||||
},
|
||||
sumAmount () {
|
||||
var new_object = this.selectedInvoice;
|
||||
return Object.keys(new_object).reduce(function(total, key) {
|
||||
return total + Math.round(new_object[key].amount * 100) / 100;
|
||||
var total = Object.keys(new_object).reduce(function(total, key) {
|
||||
return total + new_object[key].amount;
|
||||
}, 0).toFixed(2);
|
||||
return Math.round(total * 100) / 100;
|
||||
},
|
||||
selectedIds () {
|
||||
return this.selectedInvoice.map(s=>s.id);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<div class="col-auto hide" v-if="$store.getters.isSuperAdmin">
|
||||
<button type="button" class="btn b-rad-none btn-danger fs-11 requestModal" data-type="deletePackingList"><i class="fa fa-times text-white fs-12"></i></button>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deletePackingList">
|
||||
<delete-packinglist-form-component :data="data"></delete-packinglist-form-component>
|
||||
<delete-packinglist-form-component :data="data" :section="section"></delete-packinglist-form-component>
|
||||
</modal-component>
|
||||
<button type="button" class="btn b-rad-none btn-primary fs-11 requestModal" data-type="claimPackingList">Claim</button>
|
||||
</div>
|
||||
@@ -51,7 +51,7 @@
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" data-dismiss="modal" @click="submit(route('api.packing_list.delete', item.id), 'delete', 'unclaimedPackingListSection', true, true)">Confirm</div>
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" data-dismiss="modal" @click="submit(route('api.packing_list.delete', item.id), 'delete', section, true, true)">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -78,6 +78,12 @@
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
mixins: [componentHandler]
|
||||
mixins: [componentHandler],
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
section: 'unclaimedPackingListSection',
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="col">
|
||||
<div class="row m-b-20 text-info">
|
||||
<div class="col text-center">
|
||||
<h5 class="m-b-0">We currently support two major cities in china.</h5>
|
||||
<h5 class="m-b-0">We currently support three major cities in china.</h5>
|
||||
<h3 class="m-t-0">Which warehouse is more suitable for you?</h3>
|
||||
</div>
|
||||
</div>
|
||||
@@ -128,12 +128,19 @@
|
||||
</div>
|
||||
<div class="row justify-content-center animate__animated animate__fadeInUpBig animate__delay-1 animate__fast">
|
||||
<div class="col col-md-8 no-padding">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto p-r-5">
|
||||
<input type="checkbox" id="agree" v-model="isChecked">
|
||||
<label for="agree">I have read and understand the terms and agree to the <a href="https://www.cief-malaysia.com/shipping-terms-and-conditions/" target="_blank">Terms & Conditions</a>.</label>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-auto p-r-5">
|
||||
<button type="button" class="btn btn-lg btn-default b-rad-none" @click="step--">back</button>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<button type="button" class="btn btn-lg btn-block btn-primary b-rad-none" @click="createOrder()" v-if="parameters.address_id">Create Order</button>
|
||||
<button type="button" class="btn btn-lg btn-block btn-primary b-rad-none" :disabled="!isChecked" @click="createOrder()" v-if="parameters.address_id">Create Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -191,12 +198,15 @@
|
||||
warehouse_id: '',
|
||||
address_id: '',
|
||||
company_id: this.company.id,
|
||||
}
|
||||
is_terms_agree: false
|
||||
},
|
||||
isChecked: false
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
createOrder(){
|
||||
this.step++;
|
||||
this.parameters.is_terms_agree = this.isChecked;
|
||||
this.submit((this.route('api.order.create')), 'post', 'orderListSection', false, false)
|
||||
},
|
||||
cancelOrder(){
|
||||
|
||||
+2
-1
@@ -564,7 +564,8 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina
|
||||
Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect');
|
||||
|
||||
Route::get('/order/{id}', function ($id) {
|
||||
return view('pages.orders.profile', ['id' => $id]);
|
||||
// return view('pages.orders.profile', ['id' => $id]);
|
||||
return redirect()->route('order.show', ['order_number' => $id]);
|
||||
})->name('order.details');
|
||||
|
||||
Route::get('/payment-and-billing', function () {
|
||||
|
||||
Reference in New Issue
Block a user