MOD EV3-444 Hibás számítás Hooreyca adatok, restore old e2e API controller
This commit is contained in:
parent
974d9b5da1
commit
1be584b080
@ -5,24 +5,25 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\OrderArchive;
|
use App\Models\OrderArchive;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Flugg\Responder\Http\MakesResponses;
|
|
||||||
use Flugg\Responder\Responder;
|
use Flugg\Responder\Responder;
|
||||||
|
use Flugg\Responder\Http\MakesResponses;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class OrderController extends Controller
|
class OrderController extends Controller
|
||||||
{
|
{
|
||||||
use MakesResponses;
|
use MakesResponses;
|
||||||
|
|
||||||
public function convertItemCollectionToHooreycaAPIItems($ItemCollection)
|
public function convertItemCollectionToHooreycaAPIItems($ItemCollection){
|
||||||
{
|
|
||||||
unset($ItemCollection->order_archive_id);
|
unset($ItemCollection->order_archive_id);
|
||||||
$ItemCollection->HooreycaVolumen=null;
|
$ItemCollection->HooreycaVolumen=null;
|
||||||
$ItemCollection->HooreycaUnitPrice=null;
|
$ItemCollection->HooreycaUnitPrice=null;
|
||||||
|
|
||||||
if($ItemCollection->HooreycaMultiplier!==null){
|
if($ItemCollection->HooreycaMultiplier!==null){
|
||||||
$ItemCollection->HooreycaVolumen=$ItemCollection->quantity*$ItemCollection->HooreycaMultiplier;
|
$ItemCollection->HooreycaVolumen=$ItemCollection->quantity*$ItemCollection->HooreycaMultiplier;
|
||||||
$ItemCollection->HooreycaUnitPrice = ($ItemCollection->quantity * $ItemCollection->price) / $ItemCollection->HooreycaVolumen;
|
$ItemCollection->HooreycaUnitPrice=($ItemCollection->quantity*$ItemCollection->unitMultiplier*$ItemCollection->price)/$ItemCollection->HooreycaVolumen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if(!in_array($ItemCollection->id,[91045,91046,91047,91042,91043,91044])){
|
/* if(!in_array($ItemCollection->id,[91045,91046,91047,91042,91043,91044])){
|
||||||
@ -34,7 +35,6 @@ public function convertItemCollectionToHooreycaAPIItems($ItemCollection)
|
|||||||
//'HooreycaSumPrice'=>
|
//'HooreycaSumPrice'=>
|
||||||
|
|
||||||
return $ItemCollection;
|
return $ItemCollection;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Rendelő felületről adatok biztosítása
|
Rendelő felületről adatok biztosítása
|
||||||
- Cikk kódja
|
- Cikk kódja
|
||||||
@ -52,23 +52,21 @@ public function convertItemCollectionToHooreycaAPIItems($ItemCollection)
|
|||||||
'hooreycaId'=>$item->hooreycaId, //- Cikk kódja
|
'hooreycaId'=>$item->hooreycaId, //- Cikk kódja
|
||||||
'HooreycaUnit'=>$item->HooreycaUnit,
|
'HooreycaUnit'=>$item->HooreycaUnit,
|
||||||
'HooreycaMultiplier'=>$item->HooreycaMultiplier,
|
'HooreycaMultiplier'=>$item->HooreycaMultiplier,
|
||||||
'productName' => $item->name.'aaaaaaaaaaaa',
|
"productName"=>$item->name.'aaaaaaaaaaaa',
|
||||||
'hooreycaId'=>$item->hooreycaId,
|
'hooreycaId'=>$item->hooreycaId,
|
||||||
'productUnit' => $item->productUnit,
|
"productUnit"=>$item->productUnit,
|
||||||
'sellerUnit' => $item->sellerUnit,
|
"sellerUnit"=>$item->sellerUnit,
|
||||||
'unitMultiplier' => $item->unitMultiplier, // - Egységszorzó (árlista K oszlop)
|
"unitMultiplier"=>$item->unitMultiplier, //- Egységszorzó (árlista K oszlop)
|
||||||
'amountUnit' => $item->amountUnit,
|
"amountUnit"=>$item-> amountUnit,
|
||||||
'quantity' => $item->quantity, // - Rendelt mennyiség
|
"quantity"=>$item->quantity, //- Rendelt mennyiség
|
||||||
'price' => $item->price, // - Megrendelt cikk nettó értéke
|
"price"=>$item->price,//- Megrendelt cikk nettó értéke
|
||||||
'HooreycaVolumen'=>$item->quantity*$item->HooreycaMultiplier,
|
'HooreycaVolumen'=>$item->quantity*$item->HooreycaMultiplier,
|
||||||
'HooreycaSumPrice'=>($item->quantity*$item->price)/($item->quantity*$item->HooreycaMultiplier),
|
'HooreycaSumPrice'=>($item->quantity*$item->price)/($item->quantity*$item->HooreycaMultiplier),
|
||||||
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public function convertOrderToHooreycaAPI($order,$key){
|
||||||
public function convertOrderToHooreycaAPI($order, $key)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
Rendelő felületről adatok biztosítása
|
Rendelő felületről adatok biztosítása
|
||||||
- szállító kódja supplier.hooreycaId
|
- szállító kódja supplier.hooreycaId
|
||||||
@ -77,16 +75,25 @@ public function convertOrderToHooreycaAPI($order, $key)
|
|||||||
*/
|
*/
|
||||||
$order->APICallBackId=(string)\Str::orderedUuid();
|
$order->APICallBackId=(string)\Str::orderedUuid();
|
||||||
$order->save();
|
$order->save();
|
||||||
|
try {
|
||||||
$order->supplierHooreycaId=$order->supplier->hooreycaId;
|
$order->supplierHooreycaId=$order->supplier->hooreycaId;
|
||||||
|
}catch (\Exception $e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$order->supplierName=$order->supplier->name;
|
$order->supplierName=$order->supplier->name;
|
||||||
|
try {
|
||||||
$order->profitCenterHooreycaId=$order->profitCenter->hooreycaId;
|
$order->profitCenterHooreycaId=$order->profitCenter->hooreycaId;
|
||||||
$order->profitCenterName=$order->profitCenter->name;
|
$order->profitCenterName=$order->profitCenter->name;
|
||||||
|
}catch (\Exception $e){
|
||||||
|
$order->profitCenterHooreycaId=null;
|
||||||
|
}
|
||||||
$order->items= $order->itemsAPISpecial->transform([$this,'convertItemCollectionToHooreycaAPIItems']);
|
$order->items= $order->itemsAPISpecial->transform([$this,'convertItemCollectionToHooreycaAPIItems']);
|
||||||
unset($order->supplier,$order->profitCenter,$order->itemsAPISpecial);
|
unset($order->supplier,$order->profitCenter,$order->itemsAPISpecial);
|
||||||
|
|
||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Display a listing of the unprocessed orders.
|
Display a listing of the unprocessed orders.
|
||||||
|
|
||||||
@ -109,25 +116,31 @@ public function unProcessed(Request $request, Responder $responder)
|
|||||||
$updateDate=Carbon::now();
|
$updateDate=Carbon::now();
|
||||||
$OrderCollection=OrderArchive::with(['supplier'=>function ($query){
|
$OrderCollection=OrderArchive::with(['supplier'=>function ($query){
|
||||||
$query->select('id','name','hooreycaId');
|
$query->select('id','name','hooreycaId');
|
||||||
|
//$query->where('hooreycaDataActive',1);
|
||||||
},'profitCenter'=>function ($query){
|
},'profitCenter'=>function ($query){
|
||||||
$query->select('id','name','hooreycaId');
|
$query->select('id','name','hooreycaId');
|
||||||
}, 'itemsAPISpecial' => function ($query) {
|
$query->where('hooreycaDataActive',1);
|
||||||
|
},'itemsAPISpecial'
|
||||||
|
|
||||||
|
=>function ($query){
|
||||||
//$query->select('id','order_archive_id');
|
//$query->select('id','order_archive_id');
|
||||||
$query->select(
|
$query->select(
|
||||||
'order_archive_id',
|
'order_archive_id',
|
||||||
'id',
|
'id',
|
||||||
'hooreycaId', //- Cikk kódja
|
'hooreycaId', //- Cikk kódja
|
||||||
'name',
|
"name",
|
||||||
'hooreycaId',
|
'hooreycaId',
|
||||||
'HooreycaUnit',
|
'HooreycaUnit',
|
||||||
'HooreycaMultiplier',
|
'HooreycaMultiplier',
|
||||||
'productUnit',
|
"productUnit",
|
||||||
'sellerUnit',
|
"sellerUnit",
|
||||||
'unitMultiplier', // - Egységszorzó (árlista K oszlop)
|
"unitMultiplier", //- Egységszorzó (árlista K oszlop)
|
||||||
'amountUnit',
|
"amountUnit",
|
||||||
'quantity', // - Rendelt mennyiség
|
"quantity", //- Rendelt mennyiség
|
||||||
'price'
|
"price"
|
||||||
);
|
);
|
||||||
|
$query->whereNotNull('hooreycaId');
|
||||||
|
$query->where('hooreycaId','<>','');
|
||||||
},
|
},
|
||||||
|
|
||||||
])->select(
|
])->select(
|
||||||
@ -140,10 +153,20 @@ public function unProcessed(Request $request, Responder $responder)
|
|||||||
//->whereNulll('APIConfirmed')
|
//->whereNulll('APIConfirmed')
|
||||||
->whereNotNull('confirmed')
|
->whereNotNull('confirmed')
|
||||||
->whereNull('APIConfirmed')
|
->whereNull('APIConfirmed')
|
||||||
->orderBy('id', 'desc')->paginate(3);
|
->orderBy('id','desc')->paginate(3)
|
||||||
|
;
|
||||||
|
|
||||||
|
$filteredProfitCentersOrder=$OrderCollection->filter(function ($v) {
|
||||||
|
return $v->profitCenter!=null;
|
||||||
|
});
|
||||||
|
$OrderCollection->setCollection($filteredProfitCentersOrder);
|
||||||
|
|
||||||
|
/* where condition not working on paginated eloquent collection
|
||||||
|
dd($OrderCollection->toArray());
|
||||||
|
$OrderCollection=$OrderCollection->whereNotNull('profit_center');
|
||||||
|
|
||||||
|
*/
|
||||||
$ret[]=get_debug_type($OrderCollection);
|
$ret[]=get_debug_type($OrderCollection);
|
||||||
|
|
||||||
$OrderCollection->transform([$this,'convertOrderToHooreycaAPI']);
|
$OrderCollection->transform([$this,'convertOrderToHooreycaAPI']);
|
||||||
|
|
||||||
$updateId=$OrderCollection->pluck('id');
|
$updateId=$OrderCollection->pluck('id');
|
||||||
@ -195,6 +218,7 @@ public function unProcessed(Request $request, Responder $responder)
|
|||||||
@responseFile 200 scenario="Has unprocessed orders" example/APISetProcessingResponse.json
|
@responseFile 200 scenario="Has unprocessed orders" example/APISetProcessingResponse.json
|
||||||
@responseFile 500 scenario="Request invalid Request Body data" example/APISetProcessingResponseErrorInvalidData.json
|
@responseFile 500 scenario="Request invalid Request Body data" example/APISetProcessingResponseErrorInvalidData.json
|
||||||
@responseFile 401 scenario="Request unauthenticated" example/APIUnauthenticated.json
|
@responseFile 401 scenario="Request unauthenticated" example/APIUnauthenticated.json
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public function setProcessed(Request $request)
|
public function setProcessed(Request $request)
|
||||||
{
|
{
|
||||||
@ -226,11 +250,10 @@ public function setProcessed(Request $request)
|
|||||||
$successData[$APICallBackId]='updated';
|
$successData[$APICallBackId]='updated';
|
||||||
}else{
|
}else{
|
||||||
$successData[$APICallBackId]='invalid Id';
|
$successData[$APICallBackId]='invalid Id';
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
$response=responder()->success($successData)->respond(null,$header);
|
$response=responder()->success($successData)->respond(null,$header);
|
||||||
Log::channel('api')->info('API response',['responseBody'=>json_decode($response->getContent(), JSON_PRETTY_PRINT)]);
|
Log::channel('api')->info('API response',['responseBody'=>json_decode($response->getContent(), JSON_PRETTY_PRINT)]);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,12 +269,10 @@ public function setProcessed(Request $request)
|
|||||||
*
|
*
|
||||||
@responseField data.APIStatus string API status state (up and down).
|
@responseField data.APIStatus string API status state (up and down).
|
||||||
@responseFile 200 scenario="Server status" example/APIServerStatusResponse.json
|
@responseFile 200 scenario="Server status" example/APIServerStatusResponse.json
|
||||||
*/
|
*/ public function status()
|
||||||
public function status()
|
|
||||||
{
|
{
|
||||||
$header=parseAPIVersionFromNamespace(__NAMESPACE__);
|
$header=parseAPIVersionFromNamespace(__NAMESPACE__);
|
||||||
$header['processedTime']=Carbon::now()->format('Y.m.d. H:i:s.u');
|
$header['processedTime']=Carbon::now()->format('Y.m.d. H:i:s.u');
|
||||||
|
|
||||||
return responder()->success(['APIStatus'=>'up'])->respond(null,$header);
|
return responder()->success(['APIStatus'=>'up'])->respond(null,$header);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +289,7 @@ public function index()
|
|||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
@ -278,9 +300,10 @@ public function store(Request $request)
|
|||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function show(int $id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
@ -288,9 +311,11 @@ public function show(int $id)
|
|||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, int $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
@ -298,9 +323,10 @@ public function update(Request $request, int $id)
|
|||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function destroy(int $id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user