Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 18.189.143.114
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
www /
wb /
src /
Controller /
Delete
Unzip
Name
Size
Permission
Date
Action
.gitignore
0
B
-rw-rw-r--
2022-12-03 10:44
AdminController.php
705
B
-rw-rw-r--
2022-12-03 10:44
AnalyticsController.php
47.03
KB
-rw-rw-r--
2023-08-29 09:18
AuthController.php
2.14
KB
-rw-rw-r--
2022-12-03 10:44
CronController (copy).php
28.3
KB
-rw-rw-r--
2023-04-27 09:46
CronController.php
62.54
KB
-rw-rw-r--
2023-08-18 10:30
FirstRunController.php
28.3
KB
-rw-rw-r--
2023-05-18 07:53
HomeController.php
603
B
-rw-rw-r--
2022-12-24 11:33
RegistrationController.php
8.73
KB
-rw-rw-r--
2023-08-29 09:18
UsersController.php
2.63
KB
-rw-rw-r--
2022-12-03 10:44
Save
Rename
<?php namespace App\Controller; use App\Entity\Catalog; use App\Entity\Stocks; use Knp\Component\Pager\PaginatorInterface; use Doctrine\ORM\EntityManagerInterface; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Spreadsheet; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Contracts\Translation\TranslatorInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Yectep\PhpSpreadsheetBundle\Factory; /** * @IsGranted("ROLE_ADMIN") */ class AnalyticsController extends AbstractController { private $em; /** * @var Factory */ private $factory; public function __construct(EntityManagerInterface $em, Factory $factory) { $this->em = $em; $this->factory = $factory; } /** * @Route("/lk/analytics") */ public function indexAction(Request $request, PaginatorInterface $paginator): Response { $items_count = 0; $data_from = date("d.m.Y", (time()-86400*30)); $data_to = date("d.m.Y"); $data_from_filter = ''; $data_to_filter = ''; //$data_from_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", (time()-86400*30)))."Z"; //$data_to_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", time()))."Z"; $brands = $warehouses = []; $current_brand = $current_warehouse = ''; $date = $custom_date = ''; $sortBy = $request->get('sortBy', ''); $sortType = $request->get('sortType', ''); $filter_show = ''; $our_rate = $request->get('our_rate', ''); $filter_quantity_from = $request->get('filter_quantity_from', ''); $filter_quantity_to = $request->get('filter_quantity_to', ''); $filter_price_from = $request->get('filter_price_from', ''); $filter_price_to = $request->get('filter_price_to', ''); $filter_money_in_good_from = $request->get('filter_money_in_good_from', ''); $filter_money_in_good_to = $request->get('filter_money_in_good_to', ''); $filter_free_fee_one_from = $request->get('filter_free_fee_one_from', ''); $filter_free_fee_one_to = $request->get('filter_free_fee_one_to', ''); $filter_free_fee_all_from = $request->get('filter_free_fee_all_from', ''); $filter_free_fee_all_to = $request->get('filter_free_fee_all_to', ''); $filter_medium_buy_from = $request->get('filter_medium_buy_from', ''); $filter_medium_buy_to = $request->get('filter_medium_buy_to', ''); $filter_cost_price_from = $request->get('filter_cost_price_from', ''); $filter_cost_price_to = $request->get('filter_cost_price_to', ''); $filter_number_sale_from = $request->get('filter_number_sale_from', ''); $filter_number_sale_to = $request->get('filter_number_sale_to', ''); $filter_number_sale_price_from = $request->get('filter_number_sale_price_from', ''); $filter_number_sale_price_to = $request->get('filter_number_sale_price_to', ''); $filter_fee_from = $request->get('filter_fee_from', ''); $filter_fee_to = $request->get('filter_fee_to', ''); $filter_free_fee_from_one_from = $request->get('filter_free_fee_from_one_from', ''); $filter_free_fee_from_one_to = $request->get('filter_free_fee_from_one_to', ''); $filter_free_fee_from_all_from = $request->get('filter_free_fee_from_all_from', ''); $filter_free_fee_from_all_to = $request->get('filter_free_fee_from_all_to', ''); if (!empty($request->get('date'))) { if ($request->get('date')=="now") { $data_from = date("d.m.Y", time()); $data_to = date("d.m.Y"); $data_from_filter = str_replace(" ", "T", date("Y-m-d 00:00:00"))."Z"; $data_to_filter = str_replace(" ", "T", date("Y-m-d 23:59:59"))."Z"; } if ($request->get('date')=="yerstaday") { $data_from = date("d.m.Y", (time()-86400)); $data_to = date("d.m.Y"); $data_from_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", (time()-86400)))."Z"; $data_to_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", time()))."Z"; } if ($request->get('date')=="7days") { $data_from = date("d.m.Y", (time()-86400*7)); $data_to = date("d.m.Y"); $data_from_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", (time()-86400*7)))."Z"; $data_to_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", time()))."Z"; } if ($request->get('date')=="30days") { $data_from = date("d.m.Y", (time()-86400*30)); $data_to = date("d.m.Y"); $data_from_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", (time()-86400*30)))."Z"; $data_to_filter = str_replace(" ", "T", date("Y-m-d 00:00:00", time()))."Z"; } $date = $request->get('date'); } if (!empty($request->get('custom_date'))) { $custom_date = explode(" - ", $request->get('custom_date')); $data_from = date("d.m.Y", strtotime($custom_date[0])); $data_to = date("d.m.Y", strtotime($custom_date[1])); $data_from_filter = $custom_date[0]."T00:00:00Z"; $data_to_filter = $custom_date[1]."T23:59:59Z"; } if (!empty($request->get('brand'))) { $current_brand = $request->get('brand'); } if (!empty($request->get('warehouse'))) { $current_warehouse = $request->get('warehouse'); } $arCards = $arCatalog = []; //$standart_api_key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NJRCI6IjIzNzVmMDViLWYxNGQtNDQ4ZS04OWYwLTMwNTI4YTUwOWIyMiJ9.1vjHcP-7GCd-NtJQIe_5Rl5kUkkBDRRtv0-uLQXQW_U"; //$statistics_api_key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NJRCI6ImY2NDBkYzIzLTJmNWMtNDE0MS04YWRjLWFlNzU0OWMyM2E2YiJ9.EtEoNE3damTZazLzwGpYSV2cqtcDVechNKlt-uuZkh8"; //$standart_api_key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NJRCI6ImMxZGZhMDU3LTJmMDItNGI0ZC1iOWY4LTg0NDNjMGQzMDVjNyJ9.svLtu5d78jxoR6Bn84pKhIfLp0Xms-bbJGZ8e4-ASIo"; //$statistics_api_key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NJRCI6IjVkODUyMTZiLTQ2OTMtNDFjNC04OTdiLTdjZmFlMzU4YzQwZiJ9.UPy3FdF_MhR6rLRRvKGRQSybk_gtJvgXe0CGCf-pXw8"; $standart_api_key = $this->getUser()->getStandartApiKey(); $statistics_api_key = $this->getUser()->getStatisticsApiKey(); setlocale(LC_MONETARY, 'ru_RU'); $catalogRepo = $this->getCatalogRepo(); $brands = $this->getCatalogRepo()->getBrands($this->getUser()->getId()); $warehouses = $this->getCatalogRepo()->getWarehouses($this->getUser()->getId()); $entityManager = $this->getDoctrine()->getManager(); $sum_amount = $all_money_in_good = $sum_free_fee_all = $sum_free_fee_from_all = $full_sum_amount = $full_sum_free_fee = 0; //$data_from_filter = "2023-07-24T00:00:00Z"; //$data_to_filter = "2023-06-24T00:00:00Z"; $catalog = $catalogRepo->getCatalog($this->getUser()->getId(), $data_from_filter, $data_to_filter, $current_brand, $current_warehouse); if (!empty($catalog)) { $arAmounts = $arFees = []; foreach ($catalog as $cat) { $price = (int)$cat['price']; $cost_price = (int)$cat['cost_price']; $amount = $cat['amount_total']; $free_fee_one = (int)$cat['price']; $arAmounts[$cat['id']] = $amount; $arFees[$cat['id']] = $free_fee_one; $free_fee_all = $free_fee_one*$amount; $aR_free_fee_all = []; if (!empty($cat['amountStocks'])) { foreach ($cat['amountStocks'] as $stock) { $aR_free_fee_all[] = ($price*(1-intval($stock["commision"])/100) - (intval($stock["logistics"]) + $cost_price))*$stock["quantity"]; } } if (!empty($aR_free_fee_all)) { foreach ($aR_free_fee_all as $ffa) { $free_fee_all += $ffa; } } $full_sum_amount += $amount; //R $full_sum_free_fee += $free_fee_all; //T } foreach ($catalog as $cat) { $amount = $price = $money_in_good = $free_fee_one = $commision = $logistics = $free_fee_all = $cost_price = $number_sale = $number_sale_price = $fee = $free_fee_from_one = $free_fee_from_all = $sum_free_fee_all_part = $part_amount = $delivery_amount = $return_amount = 0; $medium_buy = '-'; $price = (int)$cat['price']; $amount = $cat['amount_total']; $money_in_good = $price*$amount; $cost_price = (int)$cat['cost_price']; $commision = (int)$this->getUser()->getCommisionPlan(); $logistics = (int)$this->getUser()->getLogisticsPlan(); //if ((int)$cat['commision']>0) $commision = (int)$cat['commision']; //if ((int)$cat['logistics']>0) $logistics = (int)$cat['logistics']; $delivery_amount = (int)$cat['delivery_amount']; $return_amount = (int)$cat['return_amount']; $aR_free_fee_all = []; if (!empty($cat['amountStocks'])) { foreach ($cat['amountStocks'] as $stock) { $aR_free_fee_all[] = ($price*(1-intval($stock["commision"])/100) - (intval($stock["logistics"]) + $cost_price))*$stock["quantity"]; } } if (!empty($aR_free_fee_all)) { foreach ($aR_free_fee_all as $ffa) { $free_fee_all += $ffa; } if ($amount>0) $free_fee_one = round($free_fee_all/$amount, 2); } /*$free_fee_one = $price - $cost_price - $commision - $logistics; $free_fee_all = $free_fee_one*$amount;*/ if ($delivery_amount>0) $medium_buy = number_format(((1 - $return_amount/$delivery_amount)*100), 2, '.', ' '); $number_sale = 0; $number_sale_price = $price; $free_fee_from_one = $price; $free_fee_from_all = $price; if (!empty($cat['reports'])) { foreach ($cat['reports'] as $report) { $number_sale += intval($report['quantity'])-intval($report['return_amount']); } $summary_price = $summary_fee_price = 0; if ($number_sale > 0) { foreach ($cat['reports'] as $sales) { $summary_price += floatval($sales["retail_amount"]); $summary_fee_price += floatval($sales["retail_price_withdisc_rub"]) - floatval($sales["retail_amount"]); } $number_sale_price = $summary_price / $number_sale; $free_fee_from_one = $summary_fee_price / $number_sale; } } $fee = $number_sale*$number_sale_price; $free_fee_from_all = $number_sale * $free_fee_from_one; $sum_amount += $amount; $all_money_in_good += $money_in_good; $sum_free_fee_all += $free_fee_all; // $sum_free_fee_from_all += $free_fee_from_all; // $sum_free_fee_all_part = $free_fee_from_all/$full_sum_free_fee; //AA $part_amount = $amount/$full_sum_amount; //V $sum_two = $sum_free_fee_all_part + $part_amount; $wb_rating = '-'; if (floatval($cat['wb_rating'])>0) $wb_rating = number_format($cat['wb_rating'], 1, '.', ' '); $tmp = [ 'id' => $cat['id'], 'object' => $cat['object'], 'brand' => $cat['brand'], 'vendorCode' => $cat['vendor_code'], 'updateAt' => $cat['update_at'], 'nmID' => $cat['nm_id'], 'amountStocks' => $cat['amountStocks'], 'amountStocksLog' => $cat['amountStocksLog'], 'ar_number_sale' => $cat['ar_number_sale'], 'img' => '', 'wb_rating' => $wb_rating, 'amount' => number_format($amount, 0, '.', ' '), 'price' => number_format($price, 2, '.', ' '), 'cost_price' => number_format($cost_price, 2, '.', ' '), 'money_in_good' => number_format($money_in_good, 2, '.', ' '), 'free_fee_one' => number_format($free_fee_one, 2, '.', ' '), 'free_fee_all' => number_format($free_fee_all, 2, '.', ' '), 'medium_buy' => $medium_buy."%", 'selfcost' => number_format($cost_price, 2, '.', ' '), 'number_sale' => $number_sale." шт.", 'number_sale_price' => number_format($number_sale_price, 2, '.', ' '), 'fee' => number_format($fee, 2, '.', ' '), 'free_fee_from_one' => number_format($free_fee_from_one, 2, '.', ' '), 'free_fee_from_all' => number_format($free_fee_from_all, 2, '.', ' '), 'sum_free_fee_all_part' => number_format($sum_free_fee_all_part, 6, '.', ' '), 'part_amount' => number_format($part_amount, 6, '.', ' '), 'sum_two' => number_format($sum_two, 6, '.', ' '), 'cumul_part_free_fee_all' => 0, //AB 'cumul_part_amount' => 0, //W 'our_rate' => '' ]; if (!empty($cat['media_files'])) { $mediaFiles = json_decode($cat['media_files']); if (!empty($mediaFiles[0])) { $tmp["img"] = $mediaFiles[0]; } } //if (strtotime($cat['update_at']) >= $data_from_filter AND strtotime($cat['update_at']) <= $data_to_filter) $arCatalog[] = $tmp; } } if (!empty($arCatalog)) { $arTmp = []; foreach ($arCatalog as $item) { $arTmp[$item["free_fee_all"]."_".$item["id"]] = $item; } krsort($arTmp); unset($arCatalog); $arCatalog = []; $ab = 0; foreach ($arTmp as $item) { $tmp = $item; $tmp["cumul_part_free_fee_all"] = $ab + $item["sum_free_fee_all_part"]*100; $ab = $ab + $item["sum_free_fee_all_part"]*100; $arCatalog[] = $tmp; } $arTmp = []; foreach ($arCatalog as $item) { $arTmp[$item["amount"]."_".$item["id"]] = $item; } krsort($arTmp); unset($arCatalog); $arCatalog = []; $w = 0; foreach ($arTmp as $item) { $tmp = $item; $tmp["cumul_part_amount"] = $w + $item["part_amount"]*100; $w = $w + $item["part_amount"]*100; $arCatalog[] = $tmp; } //W AB foreach ($arCatalog as $k=>$item) { if ($item["cumul_part_amount"]<80 AND $item["cumul_part_free_fee_all"]<80) $arCatalog[$k]["our_rate"] = 'A'; if (($item["cumul_part_amount"]<80 AND $item["cumul_part_free_fee_all"]>=80 AND $item["cumul_part_free_fee_all"]<95) OR ($item["cumul_part_free_fee_all"]<80 AND $item["cumul_part_amount"]>=80 AND $item["cumul_part_amount"]<95)) $arCatalog[$k]["our_rate"] = 'A-B'; if (($item["cumul_part_amount"]<80 AND $item["cumul_part_free_fee_all"]>=95 AND $item["cumul_part_free_fee_all"]<=100) OR ($item["cumul_part_free_fee_all"]<80 AND $item["cumul_part_amount"]>=95 AND $item["cumul_part_amount"]<=100)) $arCatalog[$k]["our_rate"] = 'A-C'; if ( ($item["cumul_part_amount"]>=80 AND $item["cumul_part_amount"]<95 AND $item["cumul_part_free_fee_all"]>=95 AND $item["cumul_part_free_fee_all"]<=100) OR ($item["cumul_part_amount"]>=95 AND $item["cumul_part_amount"]<=100 AND $item["cumul_part_free_fee_all"]>=80 AND $item["cumul_part_free_fee_all"]<95)) $arCatalog[$k]["our_rate"] = 'B-C'; if ($item["cumul_part_amount"]>=95 AND $item["cumul_part_amount"]<=100 AND $item["cumul_part_free_fee_all"]>=95 AND $item["cumul_part_free_fee_all"]<=100) $arCatalog[$k]["our_rate"] = 'C'; } } $arTmp = []; if ($sortBy) { foreach ($arCatalog as $item) { $arTmp[str_pad(str_replace([" ", "-"], "", $item[$sortBy]), 16, '0', STR_PAD_LEFT) . "_" . str_pad($item["id"], 8, '0', STR_PAD_LEFT)] = $item; } if ($sortType == 'asc') ksort($arTmp); else krsort($arTmp); unset($arCatalog); $arCatalog = $arTmp; } $arTmp = []; if ($our_rate) { foreach ($arCatalog as $item) { if ($item['our_rate']==$our_rate) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_quantity_from OR $filter_quantity_to) { foreach ($arCatalog as $item) { if ($filter_quantity_from AND !$filter_quantity_to AND $item['amount']>=$filter_quantity_from) $arTmp[] = $item; elseif (!$filter_quantity_from AND $filter_quantity_to AND $item['amount']<=$filter_quantity_to) $arTmp[] = $item; elseif ($filter_quantity_from AND $filter_quantity_to AND $item['amount']>=$filter_quantity_from AND $item['amount']<=$filter_quantity_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_price_from OR $filter_price_to) { foreach ($arCatalog as $item) { if ($filter_price_from AND !$filter_price_to AND $item['price']>=$filter_price_from) $arTmp[] = $item; elseif (!$filter_price_from AND $filter_price_to AND $item['price']<=$filter_price_to) $arTmp[] = $item; elseif ($filter_price_from AND $filter_price_to AND $item['price']>=$filter_price_from AND $item['price']<=$filter_price_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_money_in_good_from OR $filter_money_in_good_to) { foreach ($arCatalog as $item) { if ($filter_money_in_good_from AND !$filter_money_in_good_to AND $item['money_in_good']>=$filter_money_in_good_from) $arTmp[] = $item; elseif (!$filter_money_in_good_from AND $filter_money_in_good_to AND $item['money_in_good']<=$filter_money_in_good_to) $arTmp[] = $item; elseif ($filter_money_in_good_from AND $filter_money_in_good_to AND $item['money_in_good']>=$filter_money_in_good_from AND $item['money_in_good']<=$filter_money_in_good_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_free_fee_one_from OR $filter_free_fee_one_to) { foreach ($arCatalog as $item) { if ($filter_free_fee_one_from AND !$filter_free_fee_one_to AND $item['free_fee_one']>=$filter_free_fee_one_from) $arTmp[] = $item; elseif (!$filter_free_fee_one_from AND $filter_free_fee_one_to AND $item['free_fee_one']<=$filter_free_fee_one_to) $arTmp[] = $item; elseif ($filter_free_fee_one_from AND $filter_free_fee_one_to AND $item['free_fee_one']>=$filter_free_fee_one_from AND $item['free_fee_one']<=$filter_free_fee_one_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_free_fee_all_from OR $filter_free_fee_all_to) { foreach ($arCatalog as $item) { if ($filter_free_fee_all_from AND !$filter_free_fee_all_to AND $item['free_fee_all']>=$filter_free_fee_all_from) $arTmp[] = $item; elseif (!$filter_free_fee_all_from AND $filter_free_fee_all_to AND $item['free_fee_all']<=$filter_free_fee_all_to) $arTmp[] = $item; elseif ($filter_free_fee_all_from AND $filter_free_fee_all_to AND $item['free_fee_all']>=$filter_free_fee_all_from AND $item['free_fee_all']<=$filter_free_fee_all_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_medium_buy_from OR $filter_medium_buy_to) { foreach ($arCatalog as $item) { if ($filter_medium_buy_from AND !$filter_medium_buy_to AND $item['medium_buy']>=$filter_medium_buy_from) $arTmp[] = $item; elseif (!$filter_medium_buy_from AND $filter_medium_buy_to AND $item['medium_buy']<=$filter_medium_buy_to) $arTmp[] = $item; elseif ($filter_medium_buy_from AND $filter_medium_buy_to AND $item['medium_buy']>=$filter_medium_buy_from AND $item['medium_buy']<=$filter_medium_buy_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_cost_price_from OR $filter_cost_price_to) { foreach ($arCatalog as $item) { if ($filter_cost_price_from AND !$filter_cost_price_to AND $item['cost_price']>=$filter_cost_price_from) $arTmp[] = $item; elseif (!$filter_cost_price_from AND $filter_cost_price_to AND $item['cost_price']<=$filter_cost_price_to) $arTmp[] = $item; elseif ($filter_cost_price_from AND $filter_cost_price_to AND $item['cost_price']>=$filter_cost_price_from AND $item['cost_price']<=$filter_cost_price_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_number_sale_from OR $filter_number_sale_to) { foreach ($arCatalog as $item) { if ($filter_number_sale_from AND !$filter_number_sale_to AND $item['number_sale']>=$filter_number_sale_from) $arTmp[] = $item; elseif (!$filter_number_sale_from AND $filter_number_sale_to AND $item['number_sale']<=$filter_number_sale_to) $arTmp[] = $item; elseif ($filter_number_sale_from AND $filter_number_sale_to AND $item['number_sale']>=$filter_number_sale_from AND $item['number_sale']<=$filter_number_sale_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_number_sale_price_from OR $filter_number_sale_price_to) { foreach ($arCatalog as $item) { if ($filter_number_sale_price_from AND !$filter_number_sale_price_to AND $item['number_sale_price']>=$filter_number_sale_price_from) $arTmp[] = $item; elseif (!$filter_number_sale_price_from AND $filter_number_sale_price_to AND $item['number_sale_price']<=$filter_number_sale_price_to) $arTmp[] = $item; elseif ($filter_number_sale_price_from AND $filter_number_sale_price_to AND $item['number_sale_price']>=$filter_number_sale_price_from AND $item['number_sale_price']<=$filter_number_sale_price_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_fee_from OR $filter_fee_to) { foreach ($arCatalog as $item) { if ($filter_fee_from AND !$filter_fee_to AND $item['fee']>=$filter_fee_from) $arTmp[] = $item; elseif (!$filter_fee_from AND $filter_fee_to AND $item['fee']<=$filter_fee_to) $arTmp[] = $item; elseif ($filter_fee_from AND $filter_fee_to AND $item['fee']>=$filter_fee_from AND $item['fee']<=$filter_fee_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_free_fee_from_one_from OR $filter_free_fee_from_one_to) { foreach ($arCatalog as $item) { if ($filter_free_fee_from_one_from AND !$filter_free_fee_from_one_to AND $item['free_fee_from_one']>=$filter_free_fee_from_one_from) $arTmp[] = $item; elseif (!$filter_free_fee_from_one_from AND $filter_free_fee_from_one_to AND $item['free_fee_from_one']<=$filter_free_fee_from_one_to) $arTmp[] = $item; elseif ($filter_free_fee_from_one_from AND $filter_free_fee_from_one_to AND $item['free_fee_from_one']>=$filter_free_fee_from_one_from AND $item['free_fee_from_one']<=$filter_free_fee_from_one_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } if ($filter_free_fee_from_all_from OR $filter_free_fee_from_all_to) { foreach ($arCatalog as $item) { if ($filter_free_fee_from_all_from AND !$filter_free_fee_from_all_to AND $item['free_fee_from_all']>=$filter_free_fee_from_all_from) $arTmp[] = $item; elseif (!$filter_free_fee_from_all_from AND $filter_free_fee_from_all_to AND $item['free_fee_from_all']<=$filter_free_fee_from_all_to) $arTmp[] = $item; elseif ($filter_free_fee_from_all_from AND $filter_free_fee_from_all_to AND $item['free_fee_from_all']>=$filter_free_fee_from_all_from AND $item['free_fee_from_all']<=$filter_free_fee_from_all_to) $arTmp[] = $item; } unset($arCatalog); $arCatalog = $arTmp; $arTmp = []; $filter_show = 'active'; } $arCards = $paginator->paginate( $arCatalog, $request->query->getInt('page', 1), 30 ); $items_count = count($arCatalog); $arGraphDates = []; $i = strtotime($data_from); while ($i<=strtotime($data_to)) { $arGraphDates[] = date("d.m.Y", $i); $i += 86400; } $graph_dates = "'".implode("','", $arGraphDates)."'"; $ar_stock_quantity_full = $ar_stock_price = $ar_number_sale = []; foreach ($arCards as $card) { $arStockQuantityFull = $arStockPrice = $arNumberSale = []; if (!empty($card["amountStocksLog"])) { foreach ($arGraphDates as $graph_date) { if (!empty($card["amountStocksLog"][$graph_date])) { $arStockQuantityFull[] = intval($card["amountStocksLog"][$graph_date]["quantity"]); $arStockPrice[] = floatval($card["amountStocksLog"][$graph_date]["price"]); } else { $arStockQuantityFull[] = 0; $arStockPrice[] = 0; } } } else { foreach ($arGraphDates as $graph_date) { $arStockQuantityFull[] = 0; $arStockPrice[] = 0; } } if (!empty($card["ar_number_sale"])) { foreach ($arGraphDates as $graph_date) { if (!empty($card["ar_number_sale"][$graph_date])) { $arNumberSale[] = intval($card["ar_number_sale"][$graph_date]); } else { $arNumberSale[] = 0; } } } else { foreach ($arGraphDates as $graph_date) { $arNumberSale[] = 0; } } if (!empty($arStockQuantityFull)) $ar_stock_quantity_full[$card["nmID"]] = implode(',', $arStockQuantityFull); if (!empty($arStockPrice)) $ar_stock_price[$card["nmID"]] = implode(',', $arStockPrice); if (!empty($arNumberSale)) $ar_number_sale[$card["nmID"]] = implode(',', $arNumberSale); } if ($request->get('xls')) { $spreadsheet = $this->generateSpreadsheet($arCatalog); $response = $this->factory->createStreamedResponse($spreadsheet, 'Xlsx'); $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'); $response->headers->set('Content-Disposition', 'attachment;filename="table.xlsx"'); $response->headers->set('Pragma', 'public'); $response->headers->set('Cache-Control', 'maxage=1'); return $response; } return $this->render('analytics/index.html.twig', [ 'cards' => $arCards, 'items' => $items_count, 'data_from' => $data_from, 'data_to' => $data_to, 'graph_dates' => $graph_dates, 'stock_quantity_full' => $ar_stock_quantity_full, 'stock_price' => $ar_stock_price, 'number_sale' => $ar_number_sale, 'sum_amount' => number_format($sum_amount, 2, '.', ' '), 'all_money_in_good' => number_format($all_money_in_good, 2, '.', ' '), 'sum_free_fee_all' => number_format($sum_free_fee_all, 2, '.', ' '), 'sum_free_fee_from_all' => number_format($sum_free_fee_from_all, 2, '.', ' '), 'full_sum_amount' => number_format($full_sum_amount, 2, '.', ' '), 'full_sum_free_fee' => number_format($full_sum_free_fee, 2, '.', ' '), 'date' => $date, 'custom_date' => $custom_date, 'brands' => $brands, 'warehouses' => $warehouses, 'current_brand' => $current_brand, 'current_warehouse' => $current_warehouse, 'sortBy' => $sortBy, 'sortType' => $sortType, 'filter_show' => $filter_show, 'our_rate' => $our_rate, 'filter_quantity_from' => $filter_quantity_from, 'filter_quantity_to' => $filter_quantity_to, 'filter_price_from' => $filter_price_from, 'filter_price_to' => $filter_price_to, 'filter_money_in_good_from' => $filter_money_in_good_from, 'filter_money_in_good_to' => $filter_money_in_good_to, 'filter_free_fee_one_from' => $filter_free_fee_one_from, 'filter_free_fee_one_to' => $filter_free_fee_one_to, 'filter_free_fee_all_from' => $filter_free_fee_all_from, 'filter_free_fee_all_to' => $filter_free_fee_all_to, 'filter_medium_buy_from' => $filter_medium_buy_from, 'filter_medium_buy_to' => $filter_medium_buy_to, 'filter_cost_price_from' => $filter_cost_price_from, 'filter_cost_price_to' => $filter_cost_price_to, 'filter_number_sale_from' => $filter_number_sale_from, 'filter_number_sale_to' => $filter_number_sale_to, 'filter_number_sale_price_from' => $filter_number_sale_price_from, 'filter_number_sale_price_to' => $filter_number_sale_price_to, 'filter_fee_from' => $filter_fee_from, 'filter_fee_to' => $filter_fee_to, 'filter_free_fee_from_one_from' => $filter_free_fee_from_one_from, 'filter_free_fee_from_one_to' => $filter_free_fee_from_one_to, 'filter_free_fee_from_all_from' => $filter_free_fee_from_all_from, 'filter_free_fee_from_all_to' => $filter_free_fee_from_all_to, ]); } /* $data = '{"sort": {"cursor": {"limit": 1000}, "filter": {"withPhoto": -1}}}'; $url = 'https://suppliers-api.wildberries.ru/content/v1/cards/cursor/list'; $headers = array( 'Authorization: '.$standart_api_key, 'Content-Type: application/json' ); //curl -X POST https://suppliers-api.wildberries.ru/content/v1/cards/cursor/list -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NJRCI6ImIxOGQxZDk2LTNmM2ItNGM0Yi1hMjU3LWQ2NGU4NGVkM2UyOSJ9.WTcgkv3AdWXhokqFjSkK17_jARPCqqLUFWkKJXNPHjs" -H "Content-Type: application/json" -d "[{"sort": {"cursor": {"limit": 1000}, "filter": {"withPhoto": -1}}}]" $ch = curl_init(); $options = array( CURLOPT_URL => $url, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => $headers ); curl_setopt_array($ch, $options); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $result = curl_exec($ch); $arResult = json_decode($result); $status = curl_getinfo($ch); curl_close($ch); echo "arResult<pre>"; print_r($arResult); echo "</pre>"; echo "status<pre>"; print_r($status); echo "</pre>"; */ // $k=0; // $arCards = []; // if (!empty($arResult->data->cards)) { // foreach ($arResult->data->cards as $card) { // if ($k<20) { // $arTmp = []; // if (!empty($card->updateAt)) $arTmp["updateAt"] = $card->updateAt; else $arTmp["updateAt"] = ''; // if (!empty($card->vendorCode)) $arTmp["vendorCode"] = $card->vendorCode; else $arTmp["vendorCode"] = ''; // if (!empty($card->object)) $arTmp["object"] = $card->object; else $arTmp["object"] = ''; // if (!empty($card->brand)) $arTmp["brand"] = $card->brand; else $arTmp["brand"] = ''; // if (!empty($card->nmID)) $arTmp["nmID"] = $card->nmID; else $arTmp["nmID"] = ''; // if (!empty($card->mediaFiles[0])) $arTmp["img"] = $card->mediaFiles[0]; else $arTmp["img"] = ''; // if (!empty($card->sizes[0]->skus[0])) $arTmp["skus"] = $card->sizes[0]->skus[0]; else $arTmp["skus"] = ''; // // $arCards[] = $arTmp; // } // // /* // $catalog = new Catalog(); // // $date = new \DateTime(); // // if (!empty($card->object)) $catalog->setObject($card->object); // if (!empty($card->brand)) $catalog->setBrand($card->brand); // if (!empty($card->vendorCode)) $catalog->setVendorCode($card->vendorCode); // if (!empty($card->updateAt)) $catalog->setUpdateAt($card->updateAt); // if (!empty($card->colors)) $catalog->setColors(json_encode($card->colors)); // if (!empty($card->nmID)) $catalog->setNmID($card->nmID); // if (!empty($card->mediaFiles)) $catalog->setMediaFiles(json_encode($card->mediaFiles)); // if (!empty($card->sizes)) $catalog->setSizes(json_encode($card->sizes)); // $catalog->setUpdatedAt($date); // $catalog->setCreatedAt($date); // // // $entityManager->persist($catalog);*/ // // $k++; // } // //$entityManager->flush(); // } // // // /* $data = 'dateFrom=2022-12-21T00:00:00'; $data = ''; $url = 'https://statistics-api.wildberries.ru/api/v1/supplier/incomes?dateFrom=2022-12-21T00:00:00'; $headers = array( 'Authorization: '.$statistics_api_key, //'Content-Type: application/json' ); //curl -X GET https://suppliers-api.wildberries.ru/api/v2/warehouses -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NJRCI6ImIxOGQxZDk2LTNmM2ItNGM0Yi1hMjU3LWQ2NGU4NGVkM2UyOSJ9.WTcgkv3AdWXhokqFjSkK17_jARPCqqLUFWkKJXNPHjs" -d "[{"dateFrom": "2022-12-01T00:00:00"}]" $ch = curl_init(); $options = array( CURLOPT_URL => $url, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => $headers ); curl_setopt_array($ch, $options); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $result = curl_exec($ch); $arResult = json_decode($result); $status = curl_getinfo($ch); curl_close($ch); echo "arResult<pre>"; print_r($arResult); echo "</pre>"; echo "status<pre>"; print_r($status); echo "</pre>"; */ /* echo "<pre>"; print_r($arResult); echo "</pre>"; */ /* if ($this->isGranted('ROLE_ADMIN')) { return $this->redirectToRoute('admin_main'); } elseif ($this->isGranted('ROLE_USER')) { return $this->redirectToRoute('projects_page'); } */ /** * @Route("/lk/analytics/chart/{id}") */ public function chartModalAction($id, Request $request): Response { $result = ['title'=>'', 'stock_quantity_full'=>[], 'stock_price'=>[], 'number_sale'=>[]]; $price = 0; $catalogRepo = $this->getCatalogRepo(); $data_from = $data_to = ''; if ($request->get('date')) { if ($request->get('date')=="now") { $data_from = date("Y-m-d 00:00:00", time()); $data_to = date("Y-m-d 23:59:59"); } if ($request->get('date')=="yerstaday") { $data_from = date("Y-m-d 00:00:00", (time()-86400)); $data_to = date("Y-m-d 23:59:59"); } if ($request->get('date')=="7days") { $data_from = date("Y-m-d 00:00:00", (time()-86400*7)); $data_to = date("Y-m-d 23:59:59"); } if ($request->get('date')=="30days") { $data_from = date("Y-m-d 00:00:00", (time()-86400*30)); $data_to = date("Y-m-d 23:59:59"); } } else { $data_from = date("Y-m-d 00:00:00", (time()-86400*30)); $data_to = date("Y-m-d 23:59:59"); } if ($id) { $item = $catalogRepo->find($id); $result['title'] = $item->getNmId(); $card = $catalogRepo->getChartStats($this->getUser()->getId(), $item->getNmId(), $data_from, $data_to); $arGraphDates = []; $i = strtotime($data_from); while ($i<=strtotime($data_to)) { $arGraphDates[] = date("d.m.Y", $i); $i += 86400; } $graph_dates = "'".implode("','", $arGraphDates)."'"; $ar_stock_quantity_full = $ar_stock_price = $ar_number_sale = []; $arStockQuantityFull = $arStockPrice = $arNumberSale = []; if (!empty($card["amountStocksLog"])) { foreach ($arGraphDates as $graph_date) { if (!empty($card["amountStocksLog"][$graph_date])) { $arStockQuantityFull[] = intval($card["amountStocksLog"][$graph_date]["quantity"]); $arStockPrice[] = floatval($card["amountStocksLog"][$graph_date]["price"]); } else { $arStockQuantityFull[] = 0; $arStockPrice[] = 0; } } } else { foreach ($arGraphDates as $graph_date) { $arStockQuantityFull[] = 0; $arStockPrice[] = 0; } } if (!empty($card["ar_number_sale"])) { foreach ($arGraphDates as $graph_date) { if (!empty($card["ar_number_sale"][$graph_date])) { $arNumberSale[] = intval($card["ar_number_sale"][$graph_date]); } else { $arNumberSale[] = 0; } } } else { foreach ($arGraphDates as $graph_date) { $arNumberSale[] = 0; } } if (!empty($arStockQuantityFull)) $result["stock_quantity_full"] = $arStockQuantityFull; if (!empty($arStockPrice)) $result["stock_price"] = $arStockPrice; if (!empty($arNumberSale)) $result["number_sale"] = $arNumberSale; } return new JsonResponse($result); } /** * @param $lessons * @param $pupilUserCourses * @param UserCourse $teacherUserCourse * @return Spreadsheet * @throws Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception */ private function generateSpreadsheet($arCards) { $sheetIndex = 0; $spreadsheet = $this->factory->createSpreadsheet(); $sheet = $sheetIndex == 0 ? $spreadsheet->getActiveSheet() : $spreadsheet->createSheet($sheetIndex); $sheet->setTitle("Таблица"); $sheet->setCellValueByColumnAndRow(1, 1, 'Рейтинг'); $sheet->setCellValueByColumnAndRow(2, 1, 'Товар'); $sheet->setCellValueByColumnAndRow(3, 1, 'Остатки товара'); $sheet->setCellValueByColumnAndRow(4, 1, 'Рыночная цена'); $sheet->setCellValueByColumnAndRow(5, 1, 'Количество денег в товаре на данный момент'); $sheet->setCellValueByColumnAndRow(6, 1, 'Потенциальная чист/п с одной единицы товара при текущей цене'); $sheet->setCellValueByColumnAndRow(7, 1, 'Потенциальная читая прибыль со всего товара в наличии (l*c)'); $sheet->setCellValueByColumnAndRow(8, 1, 'Средний выкуп'); $sheet->setCellValueByColumnAndRow(9, 1, 'Себестоимость'); $sheet->setCellValueByColumnAndRow(10, 1, 'Количество продаж (за выбранный период)'); $sheet->setCellValueByColumnAndRow(11, 1, 'Средняя цена одной продажи (за выбранный период)'); $sheet->setCellValueByColumnAndRow(12, 1, 'Выручка (за выбранный период)'); $sheet->setCellValueByColumnAndRow(13, 1, 'Чистая прибыль с уже одного проданного товара в среднем (за выбранный период)'); $sheet->setCellValueByColumnAndRow(14, 1, 'Чистая прибыль со всех проданных (за выбранны й период)'); for ($index = 0; $index <= (count($arCards) * 2 + 1); $index++) { $sheet->getColumnDimensionByColumn($index)->setAutoSize(true); } $index = 2; foreach ($arCards as $card) { //$lessonColumnStart = Coordinate::stringFromColumnIndex(1); //$lessonColumnEnd = Coordinate::stringFromColumnIndex(count($lessons) * 2 + 1); //$sheet->getRowDimension(1)->setRowHeight(70); /*$sheet ->getStyle("{$lessonColumnStart}1:{$lessonColumnEnd}1") ->getAlignment() ->setHorizontal('center'); $sheet->getStyle("{$lessonColumnStart}1:{$lessonColumnEnd}1")->getFont()->setBold(true); $sheet->getStyle("{$lessonColumnStart}1:{$lessonColumnEnd}1")->getAlignment()->setWrapText(true);*/ $sheet->setCellValueByColumnAndRow(1, $index, $card["our_rate"]); $sheet->setCellValueByColumnAndRow(2, $index, $card["object"].". Бренд: ".$card["brand"].". Артикул: ".$card["nmID"]); $sheet->setCellValueByColumnAndRow(3, $index, $card["amount"]." шт."); $sheet->setCellValueByColumnAndRow(4, $index, $card["price"]); $sheet->setCellValueByColumnAndRow(5, $index, $card["money_in_good"]); $sheet->setCellValueByColumnAndRow(6, $index, $card["free_fee_one"]); $sheet->setCellValueByColumnAndRow(7, $index, $card["free_fee_all"]); $sheet->setCellValueByColumnAndRow(8, $index, $card["medium_buy"]); $sheet->setCellValueByColumnAndRow(9, $index, $card["cost_price"]); $sheet->setCellValueByColumnAndRow(10, $index, $card["number_sale"]); $sheet->setCellValueByColumnAndRow(11, $index, $card["number_sale_price"]); $sheet->setCellValueByColumnAndRow(12, $index, $card["fee"]); $sheet->setCellValueByColumnAndRow(13, $index, $card["free_fee_from_one"]); $sheet->setCellValueByColumnAndRow(14, $index, $card["free_fee_from_all"]); $index++; } $spreadsheet->setActiveSheetIndex(0); return $spreadsheet; } /** * @Route("/lk/analytics/save/cost/{id}") */ public function costSaveAction($id, Request $request): Response { $price = 0; $catalogRepo = $this->getCatalogRepo(); if ($id) { $item = $catalogRepo->find($id); $item->setCostPrice($request->get('price')); $this->em->persist($item); $this->em->flush(); } $catalogElem = $catalogRepo->find($id); $price = $catalogElem->getCostPrice(); return new Response($price); } /** * @Route("/lk/analytics/save/comm/{id}") */ public function costCommAction($id, Request $request): Response { $price = 0; $stocksRepo = $this->getStocksRepo(); if ($id) { $item = $stocksRepo->find($id); $item->setCommision($request->get('price')); $this->em->persist($item); $this->em->flush(); } $stocksElem = $stocksRepo->find($id); $price = $stocksElem->getCommision(); return new Response($price); } /** * @Route("/lk/analytics/save/log/{id}") */ public function costLogAction($id, Request $request): Response { $price = 0; $stocksRepo = $this->getStocksRepo(); if ($id) { $item = $stocksRepo->find($id); $item->setLogistics($request->get('price')); $this->em->persist($item); $this->em->flush(); } $stocksElem = $stocksRepo->find($id); $price = $stocksElem->getLogistics(); return new Response($price); } /** * @return \Doctrine\Common\Persistence\ObjectRepository|\App\Repository\CatalogRepository */ protected function getCatalogRepo() { return $this->getDoctrine()->getRepository(Catalog::class); } /** * @return \Doctrine\Common\Persistence\ObjectRepository|\App\Repository\CatalogRepository */ protected function getStocksRepo() { return $this->getDoctrine()->getRepository(Stocks::class); } }