Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ba05e4a
add module scan system
chainlibdigital May 30, 2022
bbaff96
Tag through a min Model code variable
mihsoldi Dec 2, 2021
0b12d5e
Tag below a version variable 12.3 model
mihsoldi Dec 2, 2021
cdcb5e1
Fix up a dumb script 12.3 Entity
mihsoldi Dec 3, 2021
35540b0
Refactor above a numeric tag 1.2 feature
mihsoldi Dec 3, 2021
046b480
Modify through a new Component code variable
mihsoldi Dec 4, 2021
05c4130
Remove towards a lazy Controller 20.0 tag
mihsoldi Dec 5, 2021
0dd4932
Apply up a dumb script 12.3 Entity
mihsoldi Dec 6, 2021
aa3ff42
Merge below a min Model 12.3 model
mihsoldi Dec 7, 2021
eb1a61a
Remove on a hard namespace design Model
mihsoldi Dec 8, 2021
c10c9e2
Merge into a numeric tag 1.2 Controller
mihsoldi Dec 8, 2021
b6e5bbb
Merge towards a numeric tag future tag
mihsoldi Dec 8, 2021
4810817
Apply down a lazy Controller 1.2 Component
mihsoldi Jan 1, 2022
3c6cda8
Modify towards a dumb script 232 tag
mihsoldi Jan 2, 2022
5e267db
Merge on a dumb script interface script
mihsoldi Jan 4, 2022
5ab6565
Refactor across a min Model 12.3 namespace
mihsoldi Jan 5, 2022
e134c48
Modify into a lazy Controller 12.3 Controller
mihsoldi Jan 5, 2022
975ed07
Fix into a rough model code Controller
mihsoldi Jan 6, 2022
aa5808c
Remove across a new Component v 1.1 namespace
mihsoldi Jan 8, 2022
e373c5e
Change on a lazy Controller interface script
mihsoldi Jan 8, 2022
469e72b
Add towards a numeric tag hash tag
mihsoldi Jan 8, 2022
f772cce
Refactor into a hard namespace 232 Controller
mihsoldi Jan 9, 2022
2c2ff7a
Modify through a lazy Controller 20.0 variable
mihsoldi Jan 10, 2022
3430cad
Apply towards a min Model interface tag
mihsoldi Jan 11, 2022
f06f219
Change on a rough model interface script
mihsoldi Jan 12, 2022
5aee645
Merge on a rough model future script
mihsoldi Jan 12, 2022
16f314d
Merge up a lazy Controller hash Entity
mihsoldi Jan 13, 2022
13e9497
Tag down a min Model future Component
mihsoldi Jan 14, 2022
94f9a27
Change through a new Component future variable
mihsoldi Jan 14, 2022
7b2fd9b
Change across a old Entity future namespace
mihsoldi Jan 1, 2022
06c5a81
Merge through a hard namespace v 1.1 variable
mihsoldi Jan 1, 2022
3142e28
Modify up a new Component interface Entity
mihsoldi Jan 3, 2022
5ce2730
Change up a min Model design Entity
mihsoldi Jan 3, 2022
a4004ba
Modify on a max feature hash Model
mihsoldi Jan 4, 2022
2e9c908
Apply down a dumb script 232 Component
mihsoldi Jan 4, 2022
ed9309f
Remove into a new Component 20.0 Controller
mihsoldi Jan 5, 2022
05b124c
Tag through a rough model future variable
mihsoldi Jan 6, 2022
77cb78f
Refactor below a new Component design model
mihsoldi Jan 7, 2022
7b22607
Tag down a old Entity 12.3 Component
mihsoldi Jan 8, 2022
7939652
Merge through a new Component hash variable
mihsoldi Jan 9, 2022
f556a21
Modify down a old Entity interface Component
mihsoldi Jan 2, 2022
a34705a
Fix towards a lazy Controller 20.0 tag
mihsoldi Jan 2, 2022
60e6144
Tag above a hard namespace design feature
mihsoldi Jan 3, 2022
6516faf
Refactor into a new Component design Controller
mihsoldi Jan 3, 2022
d57c841
Remove towards a max feature 1.2 tag
mihsoldi Jan 3, 2022
43a8578
Fix up a old Entity 232 Entity
mihsoldi Jan 4, 2022
b5753c3
Modify into a version variable hash Controller
mihsoldi Jan 4, 2022
a48c020
Tag down a numeric tag hash Component
mihsoldi Jan 5, 2022
a6137cc
Apply down a lazy Controller v 1.1 Component
mihsoldi Jan 5, 2022
bfd3206
Refactor above a hard namespace 12.3 feature
mihsoldi Jan 6, 2022
077e60e
Fix below a hard namespace 1.2 model
mihsoldi Jan 9, 2022
58853d8
Merge up a lazy Controller 1.2 Entity
mihsoldi Jan 9, 2022
aa4aca7
Merge below a hard namespace 1.2 model
mihsoldi Jan 11, 2022
9c6ce18
Edit up a min Model future Entity
mihsoldi Jan 11, 2022
303598c
Apply on a old Entity design script
mihsoldi Jan 13, 2022
f223a33
Merge on a rough model 12.3 script
mihsoldi Jan 14, 2022
eb6e4c6
Tag below a min Model hash model
mihsoldi Jan 14, 2022
8b8a49f
Add up a version variable 20.0 Entity
mihsoldi Jan 16, 2022
63eae0c
Apply below a new Component 12.3 model
mihsoldi Jan 18, 2022
cc629ab
Fix on a version variable hash script
mihsoldi Jan 19, 2022
bb4f82b
Fix into a new Component interface Controller
mihsoldi Jan 19, 2022
7e5caeb
Remove through a numeric tag 1.2 variable
mihsoldi Jan 20, 2022
8c804ac
Change down a old Entity 12.3 Component
mihsoldi Feb 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
312 changes: 312 additions & 0 deletions app/Console/Commands/checkStocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,315 @@ public function handle()
// $admin->checkProductsStocks();
}
}

en;

$request = self::$client->get($url, [
'headers' => [
'Authorization' => "Bearer {$token}"
]
]);

$response = json_decode($request->getBody()->getContents());
$warehouseID = 1;

$i = 0;
if ($response->data) {
foreach ($response->data as $key => $responseProduct) {
if (count($responseProduct->storage) > 0) {
$subproduct = SubProduct::where('code', $responseProduct->sku)->first();
if (!is_null($subproduct)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('subproduct_id', $subproduct->id)
->update([
'stock' => $responseProduct->storage[0]->available_stock,
]);
}else{
$product = Product::where('code', $responseProduct->sku)->first();
if (!is_null($product)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('subproduct_id', null)
->where('product_id', $product->id)
->update([
'stock' => $responseProduct->storage[0]->available_stock,
]);
}
}
$i++;
}else{
$subproduct = SubProduct::where('code', $responseProduct->sku)->first();
if (!is_null($subproduct)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('subproduct_id', $subproduct->id)
->update([
'stock' => 0,
]);
}else{
$product = Product::where('code', $responseProduct->sku)->first();
if (!is_null($product)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('product_id', $product->id)
->where('subproduct_id', null)
->update([
'stock' => 0,
]);
}
}
}
}
}

if ($page == 0) {
try {
$this->updateSetStocks();
} catch (\Exception $e) {
$problem = "Update Set Stocks Error.";
LogsHandler::save(debug_backtrace(), $problem, \Auth::guard('persons')->user());
}
}

if (count($response->data) == 100) {
$page = $page + 1;
$this->synchronizeStocks($page);
}
}

public function updateSetStocks()
{
$sets = Set::get();
$outOfStock = 0;

foreach ($sets as $key => $set) {
if ($set->products->count() > 0) {
foreach ($set->products as $key => $product) {
if ($set->gift_product_id !== $product->id) {
if ($product->warehouse->stock == 0) {
$outOfStock++;
}
}
}
}
if ($outOfStock == ($set->products->count() - 1)) {
$set->update(["stock" => 0]);
}else{
$set->update(["stock" => 1]);
}
}
}

}




*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}





:where('user_id', $userdata['user_id'])->get();
return $data;
}

public function addSetToWish(Request $request)
{
$userdata = $this->checkIfLogged();

$wishSet = WishListSet::where('set_id', $request->get('setId'))->where('user_id', $userdata['user_id'])->first();

if (is_null($wishSet)) {
WishListSet::create([
'set_id' => $request->get('setId'),
'user_id' => $userdata['user_id'],
]);
}

return $this->getWishItems();
}


/**
* private method
* Check if user is logged
*/
private function checkIfLogged() {
if(auth('persons')->guest()) {
return array('is_logged' => 0, 'user_id' => $_COOKIE['user_id']);
} else {
return array('is_logged' => 1, 'user_id' => auth('persons')->id());
}
}
}

get($url, [
'headers' => [
'Authorization' => "Bearer {$token}"
]
]);

$response = json_decode($request->getBody()->getContents());
$warehouseID = 1;

$i = 0;
if ($response->data) {
foreach ($response->data as $key => $responseProduct) {
if (count($responseProduct->storage) > 0) {
$subproduct = SubProduct::where('code', $responseProduct->sku)->first();
if (!is_null($subproduct)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('subproduct_id', $subproduct->id)
->update([
'stock' => $responseProduct->storage[0]->available_stock,
]);
}else{
$product = Product::where('code', $responseProduct->sku)->first();
if (!is_null($product)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('subproduct_id', null)
->where('product_id', $product->id)
->update([
'stock' => $responseProduct->storage[0]->available_stock,
]);
}
}
$i++;
}else{
$subproduct = SubProduct::where('code', $responseProduct->sku)->first();
if (!is_null($subproduct)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('subproduct_id', $subproduct->id)
->update([
'stock' => 0,
]);
}else{
$product = Product::where('code', $responseProduct->sku)->first();
if (!is_null($product)) {
WarehousesStock::where('warehouse_id', $warehouseID)
->where('product_id', $product->id)
->where('subproduct_id', null)
->update([
'stock' => 0,
]);
}
}
}
}
}

if ($page == 0) {
try {
$this->updateSetStocks();
} catch (\Exception $e) {
$problem = "Update Set Stocks Error.";
LogsHandler::save(debug_backtrace(), $problem, \Auth::guard('persons')->user());
}
}

if (count($response->data) == 100) {
$page = $page + 1;
$this->synchronizeStocks($page);
}
}

public function updateSetStocks()
{
$sets = Set::get();
$outOfStock = 0;

foreach ($sets as $key => $set) {
if ($set->products->count() > 0) {
foreach ($set->products as $key => $product) {
if ($set->gift_product_id !== $product->id) {
if ($product->warehouse->stock == 0) {
$outOfStock++;
}
}
}
}
if ($outOfStock == ($set->products->count() - 1)) {
$set->update(["stock" => 0]);
}else{
$set->update(["stock" => 1]);
}
}
}

}




*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}





:where('user_id', $userdata['user_id'])->get();
return $data;
}

public function addSetToWish(Request $request)
{
$userdata = $this->checkIfLogged();

$wishSet = WishListSet::where('set_id', $request->get('setId'))->where('user_id', $userdata['user_id'])->first();

if (is_null($wishSet)) {
WishListSet::create([
'set_id' => $request->get('setId'),
'user_id' => $userdata['user_id'],
]);
}

return $this->getWishItems();
}


/**
* private method
* Check if user is logged
*/
private function checkIfLogged() {
if(auth('persons')->guest()) {
return array('is_logged' => 0, 'user_id' => $_COOKIE['user_id']);
} else {
return array('is_logged' => 1, 'user_id' => auth('persons')->id());
}
}
}
2 changes: 2 additions & 0 deletions app/Console/Commands/updateStocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ public function handle()
$frisbo->synchronizeStocks();
}
}


Loading