EV3-386 Verzióváltott teszt - Statisztikák
This commit is contained in:
parent
6a0048df11
commit
9a7610f14f
@ -2,72 +2,71 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
use App\Enums\OrderFlag;
|
use App\Enums\OrderFlag;
|
||||||
use App\Enums\OrderType;
|
use App\Enums\OrderType;
|
||||||
use App\Models\OrderArchive;
|
use App\Models\OrderArchive;
|
||||||
use App\Models\OrderArchivesItem;
|
use App\Models\OrderArchivesItem;
|
||||||
|
use App\Models\PriceList;
|
||||||
use App\Models\ProductGroup;
|
use App\Models\ProductGroup;
|
||||||
use App\Models\ProfitCenter;
|
use App\Models\ProfitCenter;
|
||||||
|
use App\Models\Supplier;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class StatisticsService extends ServiceBase
|
class StatisticsService extends ServiceBase
|
||||||
{
|
{
|
||||||
private array $statisticsParameters = [
|
|
||||||
'suppliers' => [],
|
private array $statisticsParameters=[
|
||||||
'profitCenters' => [],
|
"suppliers"=>[],
|
||||||
'productGroups' => [],
|
"profitCenters"=>[],
|
||||||
'products' => [],
|
"productGroups"=>[],
|
||||||
'producers' => [],
|
"products"=>[],
|
||||||
'hooreycaNames' => [],
|
"producers"=>[],
|
||||||
'dateFrom' => null,
|
"hooreycaNames"=>[],
|
||||||
'dateTo' => null,
|
"dateFrom"=>null,
|
||||||
|
"dateTo"=>null,
|
||||||
];
|
];
|
||||||
|
|
||||||
private array $availableFilters = [
|
private array $availableFilters=[
|
||||||
'OrderFrequency' => ['suppliers', 'profitCenters', 'date', 'dateFrom', 'dateTo'],
|
'OrderFrequency'=>['suppliers','profitCenters','date','dateFrom','dateTo'],
|
||||||
'PriceChange' => ['suppliers', 'date', 'dateFrom', 'dateTo', 'productGroups', 'products', 'hooreycaNames', 'producers'],
|
'PriceChange'=>['suppliers','date','dateFrom','dateTo','productGroups','products','hooreycaNames','producers'],
|
||||||
'ProductAmount' => ['suppliers', 'profitCenters', 'date', 'dateFrom', 'dateTo', 'productGroups', 'products', 'hooreycaNames', 'producers'],
|
'ProductAmount'=>['suppliers','profitCenters','date','dateFrom','dateTo','productGroups','products','hooreycaNames','producers'],
|
||||||
];
|
];
|
||||||
|
|
||||||
private Collection $S;
|
Private Collection $S;
|
||||||
|
|
||||||
public function getAvailableFilters($type = null): array
|
public function getAvailableFilters($type=null):array
|
||||||
{
|
{
|
||||||
if (isset($this->availableFilters[$type])) {
|
if(isset($this->availableFilters[$type])){
|
||||||
return $this->availableFilters[$type];
|
return $this->availableFilters[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->availableFilters;
|
return $this->availableFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatisticsParameters(?string $pointer = null): array
|
public function getStatisticsParameters(?string $pointer=null): array
|
||||||
{
|
{
|
||||||
if ($pointer) {
|
if($pointer){
|
||||||
return $this->statisticsParameters[$pointer];
|
return $this->statisticsParameters[$pointer];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->statisticsParameters;
|
return $this->statisticsParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStatisticsParameters(?string $pointer, $value): StatisticsService
|
public function setStatisticsParameters(?string $pointer, $value): StatisticsService
|
||||||
{
|
{
|
||||||
if ($pointer) {
|
if($pointer){
|
||||||
$this->statisticsParameters[$pointer] = $value;
|
$this->statisticsParameters[$pointer]=$value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
$this->statisticsParameters = $value;
|
$this->statisticsParameters = $value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addStatisticsParameter(string $pointer, array $value): StatisticsService
|
public function addStatisticsParameter(string $pointer, array $value): StatisticsService
|
||||||
{
|
{
|
||||||
if (is_array($this->statisticsParameters[$pointer])) {
|
if(is_array($this->statisticsParameters[$pointer])){
|
||||||
$this->statisticsParameters[$pointer] = array_unique(array_merge($this->statisticsParameters[$pointer], $value));
|
$this->statisticsParameters[$pointer]=array_unique (array_merge ($this->statisticsParameters[$pointer],$value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,159 +76,284 @@ public function __construct()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getProductGroupsWithParentName($productGroupIds): array
|
private function getProductGroupsWithParentName($productGroupIds):array
|
||||||
{
|
{
|
||||||
$ProductGroup = new \App\Models\ProductGroup;
|
$ProductGroup=new \App\Models\ProductGroup();
|
||||||
$productGroupArray = $ProductGroup->allWithPath(3);
|
$productGroupArray=$ProductGroup->allWithPath(3);
|
||||||
$productGroupData = [];
|
$productGroupData=[];
|
||||||
foreach ($productGroupArray as $productGroup) {
|
foreach ($productGroupArray as $productGroup){
|
||||||
if (in_array($productGroup['id'], $productGroupIds)) {
|
if(in_array($productGroup['id'],$productGroupIds)){
|
||||||
$productGroupData[$productGroup['id']] = explode('/', $productGroup['fullPath']);
|
$productGroupData[$productGroup['id']]=explode('/',$productGroup['fullPath']);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $productGroupData;
|
return $productGroupData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseProductGroupFilter(): void
|
private function parseProductGroupFilter():void
|
||||||
{
|
{
|
||||||
$tmp = $this->statisticsParameters['productGroups'];
|
$tmp=$this->statisticsParameters['productGroups'];
|
||||||
if (count($this->statisticsParameters['productGroups']) > 0) {
|
if(count($this->statisticsParameters['productGroups'])>0){
|
||||||
$ProductGroup = new ProductGroup;
|
$ProductGroup=new ProductGroup();
|
||||||
$newGroups = [];
|
$newGroups=[];
|
||||||
foreach ($this->statisticsParameters['productGroups'] as $productGroupId) {
|
foreach ($this->statisticsParameters['productGroups'] as $productGroupId) {
|
||||||
$newGroups = array_unique(array_merge($newGroups,
|
$newGroups=array_unique(array_merge($newGroups,
|
||||||
ProductGroup::find($productGroupId)->descendants()->get()->pluck('id')->toArray()
|
ProductGroup::find($productGroupId)->descendants()->get()->pluck('id')->toArray()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$this->statisticsParameters['productGroups'] = array_unique(array_merge($this->statisticsParameters['productGroups'], $newGroups));
|
$this->statisticsParameters['productGroups']=array_unique(array_merge($this->statisticsParameters['productGroups'],$newGroups));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatisticsPriceChange(): array
|
|
||||||
|
public function getStatisticsPriceChange() :array
|
||||||
{
|
{
|
||||||
$data = [];
|
$data=[];
|
||||||
$Model = OrderArchivesItem::where('status', 'active');
|
/* $ret=[];
|
||||||
|
$ret['data']=[];
|
||||||
|
$ret['data']['changeDate']=['2024-01-01','2024-01-03','2024-04-11'];
|
||||||
|
return $ret;
|
||||||
|
;*/
|
||||||
|
|
||||||
|
/* $Model=OrderArchivesItem::where('status','active');
|
||||||
$Model->limit(1);
|
$Model->limit(1);
|
||||||
$data = $Model->get();
|
$data=$Model->get();*/
|
||||||
|
|
||||||
// dd($Model);
|
$Model=PriceList::where('status','active');
|
||||||
return ['SQL' => getSql($Model), 'data' => $data->toArray()];
|
if($this->statisticsParameters['dateFrom']){
|
||||||
|
$Model->where('available','>=',$this->statisticsParameters['dateFrom']);
|
||||||
|
}
|
||||||
|
if($this->statisticsParameters['dateTo']){
|
||||||
|
$Model->where('available','<=',$this->statisticsParameters['dateTo']);
|
||||||
|
}
|
||||||
|
if(count($this->statisticsParameters['suppliers'])>0){
|
||||||
|
$Model->whereIn('supplier_id',$this->statisticsParameters['suppliers']);
|
||||||
|
}
|
||||||
|
$Model->orderBy('available','asc' );
|
||||||
|
$Model->with('productsWithRelations',function ($query){
|
||||||
|
//return $query->where('product_group_id',37);
|
||||||
|
|
||||||
|
//csoport szúrő, figyelembe venni ha 1, 2 színtű lekérdezni a gyerekeket
|
||||||
|
$this->parseProductGroupFilter();
|
||||||
|
if(count($this->statisticsParameters['productGroups'])>0) {
|
||||||
|
$query->whereIn('product_group_id',$this->statisticsParameters['productGroups']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//termÉk szűrő
|
||||||
|
if(count($this->statisticsParameters['products'])>0){
|
||||||
|
$query->whereIn('name',$this->statisticsParameters['products']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//hooreyca name szürő
|
||||||
|
if(count($this->statisticsParameters['hooreycaNames'])>0){
|
||||||
|
$query->whereIn('buyerProductName',$this->statisticsParameters['hooreycaNames']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//gyártó szürő
|
||||||
|
if(count($this->statisticsParameters['producers'])>0){
|
||||||
|
$query->whereIn('producer_id',$this->statisticsParameters['producers']);
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
dd($Model->getProductRelations());
|
||||||
|
dd($Model->with('productsWithRelations')->get()->toArray());
|
||||||
|
// $priceLists=$Model->with('products')->get();
|
||||||
|
*/
|
||||||
|
//dd($Model->with('productsWithRelations')->get()->toArray());
|
||||||
|
//$Model->with('productsWithRelations')->where()
|
||||||
|
$priceLists=$Model->get();
|
||||||
|
$products=[];
|
||||||
|
$changedProducts=[];
|
||||||
|
$changeDate=[];
|
||||||
|
$needProductGroupIds=[];
|
||||||
|
$supplierIds=[];
|
||||||
|
if(count($priceLists)>0){
|
||||||
|
foreach ($priceLists as $priceList){
|
||||||
|
if(!in_array($priceList->supplier_id,$supplierIds)){
|
||||||
|
$supplierIds[]=$priceList->supplier_id;
|
||||||
|
}
|
||||||
|
foreach ($priceList->productsWithRelations as $product){
|
||||||
|
//dd($product->priceListPrice);
|
||||||
|
if(!isset($products[$product->id])){
|
||||||
|
$producer_name='N/A';
|
||||||
|
if($product->producer){
|
||||||
|
$producer_name=$product->producer->name;
|
||||||
|
}
|
||||||
|
$products[$product->id]=[
|
||||||
|
'id'=>$product->id,
|
||||||
|
'price'=>$product->priceListPrice->price,
|
||||||
|
'name'=>$product->name,
|
||||||
|
//'producer_name'=>$product->producer->name,
|
||||||
|
'producer_name'=>$producer_name,
|
||||||
|
'supplier_id'=>$priceList->supplier_id,
|
||||||
|
'producer_id'=>$product->producer_id,
|
||||||
|
'productGroup_id'=>$product->product_group_id
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
if ($products[$product->id]['price']!=$product->priceListPrice->price){
|
||||||
|
$datePointer=preg_replace('~\D~','',[$priceList['available']])[0];
|
||||||
|
$changedProducts[$product->id]['changes'][$datePointer]=$product->priceListPrice->price;
|
||||||
|
$products[$product->id]['price']=$product->priceListPrice->price;
|
||||||
|
if(!in_array($priceList['available'],$changeDate)){
|
||||||
|
$changeDate[]=$priceList['available'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!in_array($product->product_group_id,$needProductGroupIds)){
|
||||||
|
$needProductGroupIds[]=$product->product_group_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$suppliers=Supplier::select(['id','name'])->whereIn('id',$supplierIds )->get()->pluck('name','id');
|
||||||
|
|
||||||
|
$productGroupData=$this->getProductGroupsWithParentName($needProductGroupIds);
|
||||||
|
|
||||||
|
/* foreach ($data as $k=>$item) {
|
||||||
|
$data[$k]['productGroupData']=$productGroupData[$item->product_group_id];
|
||||||
|
$data[$k]['sum_quantity']=$item['quantity']*$item['unitMultiplier'];
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$data['changedProducts']=[];
|
||||||
|
|
||||||
|
foreach ($changedProducts as $k=>$changedProduct){
|
||||||
|
/* $changedProducts[$k]=array_merge($products[$k],$changedProduct);
|
||||||
|
$changedProducts[$k]['supplier_name']=$suppliers[$changedProducts[$k]['supplier_id']];
|
||||||
|
$changedProducts[$k]['productGroupData']=$productGroupData[$changedProducts[$k]['productGroup_id']];
|
||||||
|
*/
|
||||||
|
|
||||||
|
$tmpChangedProducts=array_merge($products[$k],$changedProduct);
|
||||||
|
$tmpChangedProducts['supplier_name']=$suppliers[$tmpChangedProducts['supplier_id']];
|
||||||
|
$tmpChangedProducts['productGroupData']=$productGroupData[$tmpChangedProducts['productGroup_id']];
|
||||||
|
$data['changedProducts'][]=$tmpChangedProducts;
|
||||||
|
}
|
||||||
|
//dd($data['changedProducts']);
|
||||||
|
|
||||||
|
//$data['changedProducts']=$changedProducts;
|
||||||
|
|
||||||
|
$data['priceLists']=$priceLists;
|
||||||
|
$data['changeDate']=$changeDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//dd($Model);
|
||||||
|
return ['SQL'=>getSql($Model),'data'=>$data];
|
||||||
|
return ['SQL'=>getSql($Model),'data'=>$data->toArray()];
|
||||||
}
|
}
|
||||||
|
public function getStatisticsProductAmount() :array
|
||||||
public function getStatisticsProductAmount(): array
|
|
||||||
{
|
{
|
||||||
$data = [];
|
$data=[];
|
||||||
$Model = OrderArchivesItem::whereHas('orderArchive', function ($query) {
|
$Model=OrderArchivesItem::whereHas('orderArchive',function($query) {
|
||||||
$query->where('orderType', OrderType::daily)
|
$query->where('orderType', OrderType::daily)
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
$query->wherein('orderFlag', [OrderFlag::modifier])
|
$query->wherein('orderFlag',[OrderFlag::modifier])
|
||||||
->orWhere('orderFlag', '=', null);
|
->orWhere('orderFlag', '=', null);
|
||||||
});
|
});
|
||||||
if (count($this->statisticsParameters['suppliers']) > 0) {
|
if (count($this->statisticsParameters['suppliers']) > 0) {
|
||||||
$query->whereIn('supplier_id', $this->statisticsParameters['suppliers']);
|
$query->whereIn('supplier_id', $this->statisticsParameters['suppliers']);
|
||||||
}
|
}
|
||||||
if (count($this->statisticsParameters['profitCenters']) > 0) {
|
if(count($this->statisticsParameters['profitCenters'])>0){
|
||||||
$query->whereIn('profit_center_id', $this->statisticsParameters['profitCenters']);
|
$query->whereIn('profit_center_id',$this->statisticsParameters['profitCenters']);
|
||||||
}
|
}
|
||||||
if ($this->statisticsParameters['dateFrom']) {
|
if($this->statisticsParameters['dateFrom']){
|
||||||
$query->where('deliveryDate', '>=', $this->statisticsParameters['dateFrom']);
|
$query->where('deliveryDate','>=',$this->statisticsParameters['dateFrom']);
|
||||||
}
|
}
|
||||||
if ($this->statisticsParameters['dateTo']) {
|
if($this->statisticsParameters['dateTo']){
|
||||||
$query->where('deliveryDate', '<=', $this->statisticsParameters['dateTo']);
|
$query->where('deliveryDate','<=',$this->statisticsParameters['dateTo']);
|
||||||
}
|
}
|
||||||
// ->where('orderArchive.orderType',OrderType::daily)
|
//->where('orderArchive.orderType',OrderType::daily)
|
||||||
})
|
})
|
||||||
->with('orderArchive:id,profit_center_name');
|
->with('orderArchive:id,profit_center_name')
|
||||||
|
;
|
||||||
|
|
||||||
// csoport szúrő, figyelembe venni ha 1, 2 színtű lekérdezni a gyerekeket
|
//csoport szúrő, figyelembe venni ha 1, 2 színtű lekérdezni a gyerekeket
|
||||||
$this->parseProductGroupFilter();
|
$this->parseProductGroupFilter();
|
||||||
if (count($this->statisticsParameters['productGroups']) > 0) {
|
if(count($this->statisticsParameters['productGroups'])>0) {
|
||||||
$Model->whereIn('product_group_id', $this->statisticsParameters['productGroups']);
|
$Model->whereIn('product_group_id',$this->statisticsParameters['productGroups']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// termÉk szűrő
|
//termÉk szűrő
|
||||||
if (count($this->statisticsParameters['products']) > 0) {
|
if(count($this->statisticsParameters['products'])>0){
|
||||||
$Model->whereIn('name', $this->statisticsParameters['products']);
|
$Model->whereIn('name',$this->statisticsParameters['products']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hooreyca name szürő
|
//hooreyca name szürő
|
||||||
if (count($this->statisticsParameters['hooreycaNames']) > 0) {
|
if(count($this->statisticsParameters['hooreycaNames'])>0){
|
||||||
$Model->whereIn('buyerProductName', $this->statisticsParameters['hooreycaNames']);
|
$Model->whereIn('buyerProductName',$this->statisticsParameters['hooreycaNames']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gyártó szürő
|
//gyártó szürő
|
||||||
if (count($this->statisticsParameters['producers']) > 0) {
|
if(count($this->statisticsParameters['producers'])>0){
|
||||||
$Model->whereIn('producer_id', $this->statisticsParameters['producers']);
|
$Model->whereIn('producer_id',$this->statisticsParameters['producers']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$Model->limit(2000);
|
$Model->limit(12000);
|
||||||
/*
|
/*
|
||||||
$data=$Model->get()->toArray();
|
$data=$Model->get()->toArray();
|
||||||
dd($data);
|
dd($data);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
product_group_id
|
product_group_id
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$data = $Model->get();
|
$data=$Model->get();
|
||||||
$productGroupIds = $data->unique('product_group_id')->pluck('product_group_id')->toArray();
|
$productGroupIds=$data->unique('product_group_id')->pluck('product_group_id')->toArray();
|
||||||
$productGroupData = $this->getProductGroupsWithParentName($productGroupIds);
|
$productGroupData=$this->getProductGroupsWithParentName($productGroupIds);
|
||||||
foreach ($data as $k => $item) {
|
foreach ($data as $k=>$item) {
|
||||||
$data[$k]['productGroupData'] = $productGroupData[$item->product_group_id];
|
$data[$k]['productGroupData']=$productGroupData[$item->product_group_id];
|
||||||
$data[$k]['sum_quantity'] = $item['quantity'] * $item['unitMultiplier'];
|
$data[$k]['sum_quantity']=$item['quantity']*$item['unitMultiplier'];
|
||||||
}
|
}
|
||||||
// $data[0]->xxx='xxx';
|
//$data[0]->xxx='xxx';
|
||||||
// dd($data[0]->toArray());
|
//dd($data[0]->toArray());
|
||||||
|
|
||||||
// ->toArray();
|
|
||||||
|
|
||||||
return ['SQL' => getSql($Model), 'data' => $data->toArray()];
|
//->toArray();
|
||||||
|
|
||||||
|
return ['SQL'=>getSql($Model),'data'=>$data->toArray()];
|
||||||
}
|
}
|
||||||
|
public function getStatisticsOrderFrequency() :array
|
||||||
public function getStatisticsOrderFrequency(): array
|
|
||||||
{
|
{
|
||||||
// return \response()->json([__FILE__,__LINE__,$this->getStatisticsParameters()], 400);
|
//return \response()->json([__FILE__,__LINE__,$this->getStatisticsParameters()], 400);
|
||||||
|
|
||||||
$Model = OrderArchive::where('orderType', OrderType::daily)
|
$Model=OrderArchive::
|
||||||
|
where('orderType',OrderType::daily)
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
$query->wherein('orderFlag', [OrderFlag::modifier])
|
$query->wherein('orderFlag',[OrderFlag::modifier])
|
||||||
->orWhere('orderFlag', '=', null);
|
->orWhere('orderFlag', '=', null);
|
||||||
});
|
});
|
||||||
// wherein('orderFlag',[OrderFlag::modifier])->orWhere();
|
//wherein('orderFlag',[OrderFlag::modifier])->orWhere();
|
||||||
if (count($this->statisticsParameters['profitCenters']) > 0) {
|
if(count($this->statisticsParameters['profitCenters'])>0){
|
||||||
$Model->whereIn('profit_center_id', $this->statisticsParameters['profitCenters']);
|
$Model->whereIn('profit_center_id',$this->statisticsParameters['profitCenters']);
|
||||||
}
|
}
|
||||||
if (count($this->statisticsParameters['suppliers']) > 0) {
|
if(count($this->statisticsParameters['suppliers'])>0){
|
||||||
$Model->whereIn('supplier_id', $this->statisticsParameters['suppliers']);
|
$Model->whereIn('supplier_id',$this->statisticsParameters['suppliers']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->statisticsParameters['dateFrom']) {
|
if($this->statisticsParameters['dateFrom']){
|
||||||
$Model->where('deliveryDate', '>=', $this->statisticsParameters['dateFrom']);
|
$Model->where('deliveryDate','>=',$this->statisticsParameters['dateFrom']);
|
||||||
}
|
}
|
||||||
if ($this->statisticsParameters['dateTo']) {
|
if($this->statisticsParameters['dateTo']){
|
||||||
$Model->where('deliveryDate', '<=', $this->statisticsParameters['dateTo']);
|
$Model->where('deliveryDate','<=',$this->statisticsParameters['dateTo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$Model->select(['profit_center_name', 'supplier_name', DB::raw('MAX(sumPrice) AS max_price, MIN(sumPrice) AS min_price, AVG(sumPrice) as avg_price, SUM(sumPrice) as sum_price, count(DISTINCT(deliveryDate)) as count_transaction'),
|
$Model->select(['profit_center_name','supplier_name'
|
||||||
|
,DB::raw("MAX(sumPrice) AS max_price, MIN(sumPrice) AS min_price, AVG(sumPrice) as avg_price, SUM(sumPrice) as sum_price, count(DISTINCT(deliveryDate)) as count_transaction")
|
||||||
]);
|
]);
|
||||||
// ->with(['profitCenter','supplier']);
|
//->with(['profitCenter','supplier']);
|
||||||
$Model->groupBy('profit_center_name', 'supplier_name');
|
$Model->groupBy('profit_center_name','supplier_name');
|
||||||
$Model->orderBy('profit_center_name')->orderBy('supplier_name');
|
$Model->orderBy('profit_center_name')->orderBy('supplier_name');
|
||||||
|
|
||||||
$data = [];
|
$data=[];
|
||||||
$data = $Model->get()->toArray();
|
$data=$Model->get()->toArray();
|
||||||
|
return ['SQL'=>getSql($Model),'data'=>$data];
|
||||||
return ['SQL' => getSql($Model), 'data' => $data];
|
|
||||||
|
|
||||||
return $Model->toSql();
|
return $Model->toSql();
|
||||||
|
|
||||||
return $Model->get()->toArray();
|
return $Model->get()->toArray();
|
||||||
|
|
||||||
return $ProfitCenter->get()->toArray();
|
return $ProfitCenter->get()->toArray();
|
||||||
|
|
||||||
return $this->getStatisticsParameters(null);
|
return $this->getStatisticsParameters(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user