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\Models\OrderArchive;
|
||||
use Carbon\Carbon;
|
||||
use Flugg\Responder\Http\MakesResponses;
|
||||
use Flugg\Responder\Responder;
|
||||
use Flugg\Responder\Http\MakesResponses;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
use MakesResponses;
|
||||
|
||||
public function convertItemCollectionToHooreycaAPIItems($ItemCollection)
|
||||
{
|
||||
public function convertItemCollectionToHooreycaAPIItems($ItemCollection){
|
||||
unset($ItemCollection->order_archive_id);
|
||||
$ItemCollection->HooreycaVolumen=null;
|
||||
$ItemCollection->HooreycaUnitPrice=null;
|
||||
|
||||
if($ItemCollection->HooreycaMultiplier!==null){
|
||||
$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])){
|
||||
@ -34,7 +35,6 @@ public function convertItemCollectionToHooreycaAPIItems($ItemCollection)
|
||||
//'HooreycaSumPrice'=>
|
||||
|
||||
return $ItemCollection;
|
||||
|
||||
/*
|
||||
Rendelő felületről adatok biztosítása
|
||||
- Cikk kódja
|
||||
@ -52,23 +52,21 @@ public function convertItemCollectionToHooreycaAPIItems($ItemCollection)
|
||||
'hooreycaId'=>$item->hooreycaId, //- Cikk kódja
|
||||
'HooreycaUnit'=>$item->HooreycaUnit,
|
||||
'HooreycaMultiplier'=>$item->HooreycaMultiplier,
|
||||
'productName' => $item->name.'aaaaaaaaaaaa',
|
||||
"productName"=>$item->name.'aaaaaaaaaaaa',
|
||||
'hooreycaId'=>$item->hooreycaId,
|
||||
'productUnit' => $item->productUnit,
|
||||
'sellerUnit' => $item->sellerUnit,
|
||||
'unitMultiplier' => $item->unitMultiplier, // - Egységszorzó (árlista K oszlop)
|
||||
'amountUnit' => $item->amountUnit,
|
||||
'quantity' => $item->quantity, // - Rendelt mennyiség
|
||||
'price' => $item->price, // - Megrendelt cikk nettó értéke
|
||||
"productUnit"=>$item->productUnit,
|
||||
"sellerUnit"=>$item->sellerUnit,
|
||||
"unitMultiplier"=>$item->unitMultiplier, //- Egységszorzó (árlista K oszlop)
|
||||
"amountUnit"=>$item-> amountUnit,
|
||||
"quantity"=>$item->quantity, //- Rendelt mennyiség
|
||||
"price"=>$item->price,//- Megrendelt cikk nettó értéke
|
||||
'HooreycaVolumen'=>$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
|
||||
- szállító kódja supplier.hooreycaId
|
||||
@ -77,16 +75,25 @@ public function convertOrderToHooreycaAPI($order, $key)
|
||||
*/
|
||||
$order->APICallBackId=(string)\Str::orderedUuid();
|
||||
$order->save();
|
||||
try {
|
||||
$order->supplierHooreycaId=$order->supplier->hooreycaId;
|
||||
}catch (\Exception $e){
|
||||
|
||||
}
|
||||
|
||||
$order->supplierName=$order->supplier->name;
|
||||
try {
|
||||
$order->profitCenterHooreycaId=$order->profitCenter->hooreycaId;
|
||||
$order->profitCenterName=$order->profitCenter->name;
|
||||
}catch (\Exception $e){
|
||||
$order->profitCenterHooreycaId=null;
|
||||
}
|
||||
$order->items= $order->itemsAPISpecial->transform([$this,'convertItemCollectionToHooreycaAPIItems']);
|
||||
unset($order->supplier,$order->profitCenter,$order->itemsAPISpecial);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Display a listing of the unprocessed orders.
|
||||
|
||||
@ -109,25 +116,31 @@ public function unProcessed(Request $request, Responder $responder)
|
||||
$updateDate=Carbon::now();
|
||||
$OrderCollection=OrderArchive::with(['supplier'=>function ($query){
|
||||
$query->select('id','name','hooreycaId');
|
||||
//$query->where('hooreycaDataActive',1);
|
||||
},'profitCenter'=>function ($query){
|
||||
$query->select('id','name','hooreycaId');
|
||||
}, 'itemsAPISpecial' => function ($query) {
|
||||
$query->where('hooreycaDataActive',1);
|
||||
},'itemsAPISpecial'
|
||||
|
||||
=>function ($query){
|
||||
//$query->select('id','order_archive_id');
|
||||
$query->select(
|
||||
'order_archive_id',
|
||||
'id',
|
||||
'hooreycaId', //- Cikk kódja
|
||||
'name',
|
||||
"name",
|
||||
'hooreycaId',
|
||||
'HooreycaUnit',
|
||||
'HooreycaMultiplier',
|
||||
'productUnit',
|
||||
'sellerUnit',
|
||||
'unitMultiplier', // - Egységszorzó (árlista K oszlop)
|
||||
'amountUnit',
|
||||
'quantity', // - Rendelt mennyiség
|
||||
'price'
|
||||
"productUnit",
|
||||
"sellerUnit",
|
||||
"unitMultiplier", //- Egységszorzó (árlista K oszlop)
|
||||
"amountUnit",
|
||||
"quantity", //- Rendelt mennyiség
|
||||
"price"
|
||||
);
|
||||
$query->whereNotNull('hooreycaId');
|
||||
$query->where('hooreycaId','<>','');
|
||||
},
|
||||
|
||||
])->select(
|
||||
@ -140,10 +153,20 @@ public function unProcessed(Request $request, Responder $responder)
|
||||
//->whereNulll('APIConfirmed')
|
||||
->whereNotNull('confirmed')
|
||||
->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);
|
||||
|
||||
$OrderCollection->transform([$this,'convertOrderToHooreycaAPI']);
|
||||
|
||||
$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 500 scenario="Request invalid Request Body data" example/APISetProcessingResponseErrorInvalidData.json
|
||||
@responseFile 401 scenario="Request unauthenticated" example/APIUnauthenticated.json
|
||||
|
||||
*/
|
||||
public function setProcessed(Request $request)
|
||||
{
|
||||
@ -226,11 +250,10 @@ public function setProcessed(Request $request)
|
||||
$successData[$APICallBackId]='updated';
|
||||
}else{
|
||||
$successData[$APICallBackId]='invalid Id';
|
||||
}
|
||||
};
|
||||
}
|
||||
$response=responder()->success($successData)->respond(null,$header);
|
||||
Log::channel('api')->info('API response',['responseBody'=>json_decode($response->getContent(), JSON_PRETTY_PRINT)]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@ -246,12 +269,10 @@ public function setProcessed(Request $request)
|
||||
*
|
||||
@responseField data.APIStatus string API status state (up and down).
|
||||
@responseFile 200 scenario="Server status" example/APIServerStatusResponse.json
|
||||
*/
|
||||
public function status()
|
||||
*/ public function status()
|
||||
{
|
||||
$header=parseAPIVersionFromNamespace(__NAMESPACE__);
|
||||
$header['processedTime']=Carbon::now()->format('Y.m.d. H:i:s.u');
|
||||
|
||||
return responder()->success(['APIStatus'=>'up'])->respond(null,$header);
|
||||
}
|
||||
|
||||
@ -268,6 +289,7 @@ public function index()
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
@ -278,9 +300,10 @@ public function store(Request $request)
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @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.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @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.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(int $id)
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user