app/Customize/Twig/Extension/ServiceExtension.php line 1166

Open in your IDE?
  1. <?php
  2. /**
  3.  * @version EC=CUBE4
  4.  * @copyright 株式会社 翔 kakeru.co.jp
  5.  * @author
  6.  * 2021年11月29日作成
  7.  *
  8.  * app\Customize\Twig\Extension\ServiceExtension.php
  9.  *
  10.  * TWIGからサービスの呼び出し
  11.  *
  12.  *
  13.  *
  14.  *                             C= C= C= ┌(;・_・)┘トコトコ
  15.  ******************************************************/
  16. namespace Customize\Twig\Extension;
  17. use Customize\Entity\CacheTrait;
  18. use Customize\Service\FavoriteService;
  19. use Customize\Service\GoodsPriceService;
  20. use Customize\Service\Google\ReCaptchaService;
  21. use Customize\Service\InventoryMatrixService;
  22. use Customize\Service\OrderService;
  23. use Customize\Service\Payment\PaymentService;
  24. use Customize\Service\SampleService;
  25. use DOMNamedNodeMap;
  26. use DOMNode;
  27. use Eccube\Entity\CartItem;
  28. use Eccube\Entity\OrderItem;
  29. use Eccube\Repository\ClassCategoryRepository;
  30. use Eccube\Repository\ProductRepository;
  31. use Lm\Engine\EC\Entity\GoodsWithRelated;
  32. use Lm\Engine\EC\Entity\Item\Item;
  33. use Lm\Engine\EC\Entity\OrderHeaderExtended;
  34. use Lm\Engine\InventoryMatrix\InventoryMatrix;
  35. use Lm\Engine\Zaiko\Yoyaku;
  36. use Lm\Entity\Goods;
  37. use Lm\Entity\OrderHeader;
  38. use Lm\Service\Cache\CacheService;
  39. use Lm\Util\Date;
  40. use Detection\MobileDetect as MobileDetector;
  41. use Symfony\Component\DependencyInjection\ContainerInterface;
  42. use Symfony\Component\DomCrawler\Crawler;
  43. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  44. use Symfony\Component\HttpFoundation\RequestStack;
  45. use Twig\Extension\AbstractExtension;
  46. use Twig\TwigFunction;
  47. use Twig\TwigFilter;
  48. use Twig\Environment as Twig;
  49. use Customize\Service\LmHelper;
  50. use Customize\Service\CustomerService;
  51. use Customize\Service\CommonService;
  52. use Eccube\Repository\ProductClassRepository;
  53. use Eccube\Repository\OrderRepository;
  54. use Eccube\Repository\Master\PrefRepository;
  55. use Eccube\Repository\Master\JobRepository;
  56. use Lm\Service\Db\SqlService;
  57. use Lm\Engine\NoukiKeisan\NoukiKeisan as NoukiEngine;
  58. use Customize\Service\CatalogService;
  59. use Customize\Service\CartService;
  60. use Customize\Service\GoodsService;
  61. use Customize\Service\MetaTagService;
  62. use Customize\Service\EstimateCharacterizer;
  63. use Eccube\Repository\Master\OrderItemTypeRepository;
  64. use Customize\Converter\OrderConverter;
  65. use Customize\Service\OrderHelper;
  66. use Customize\Service\AutoLoadService;
  67. use Customize\Service\MobileDetector as LmMobileDetector;
  68. use Lm\Engine\SokujitsuHassou\SokujitsuHassou;
  69. use Twig\TwigTest;
  70. use Customize\Converter\ProductConverter;
  71. class ServiceExtension extends AbstractExtension
  72. {
  73.     use CacheTrait;
  74.     const Cache1 'EstimateProductClassIds';
  75.     const MetatagTwig 'Common/MetaTags.twig';
  76.     const BreadCrumTwig 'Common/BreadCrumb.twig';
  77.     const EstimateTwig 'Common/Estimate.twig';
  78.     const ExclusionTwig 'Cart/Parts/Exclusion.twig';
  79.     const CartAddLineTwig 'Cart/Parts/Responsive/AddLine.twig';
  80.     const ShoppingEstimate 'Shopping/Parts/Estimate.twig';
  81.     const MobileShoppingEstimate 'Common/MobileEstimate.twig';
  82.     const MailEstimate 'Mail/Parts/Estimate.twig';
  83.     const JWeek = ['日''月''火''水''木''金''土'];
  84.     /**
  85.      * @var Container
  86.      */
  87.     protected $Container;
  88.     protected $Session;
  89.     protected $RequestStack;
  90.     protected $LmHelper;
  91.     protected $CustomerService;
  92.     protected $CommonService;
  93.     protected $PrefRepository;
  94.     protected $JobRepository;
  95.     protected $Router;
  96.     protected $Request;
  97.     protected $CatalogService;
  98.     protected $CartService;
  99.     protected $CatalogValue;
  100.     protected $GoodsService;
  101.     protected $Twig;
  102.     /**
  103.      * @var ProductRepository
  104.      */
  105.     private $ProductRepository;
  106.     protected $ProductClassRepository;
  107.     protected $Bank;
  108.     protected $CacheService;
  109.     protected $MetaTagService;
  110.     protected $EstimateCharacterizer;
  111.     protected $OrderItemTypeRepository;
  112.     protected $PaymentDetails = [];
  113.     protected $EstimateOptions = [];
  114.     protected $OrderConverter;
  115.     protected $OrderRepository;
  116.     protected $EstimateType;
  117.     protected $AutoLoadService;
  118.     protected $CartSortFlg;
  119.     /**
  120.      * @var MobileDetector
  121.      */
  122.     private $mobileDetector;
  123.     /**
  124.      * @var LmMobileDetector
  125.      */
  126.     private $LmMobileDetector;
  127.     /**
  128.      * @var FavoriteService
  129.      */
  130.     private $FavoriteService;
  131.     /**
  132.      * @var SampleService
  133.      */
  134.     private $SampleService;
  135.     /**
  136.      * @var OrderService
  137.      */
  138.     private $OrderService;
  139.     private $paymentService;
  140.     private $reCaptchaService;
  141.     private $productConverter;
  142.     public function __construct(ContainerInterface      $Container,
  143.                                 SessionInterface        $Session,
  144.                                 RequestStack            $RequestStack,
  145.                                 LmHelper                $LmHelper,
  146.                                 CustomerService         $CustomerService,
  147.                                 CommonService           $CommonService,
  148.                                 PrefRepository          $PrefRepository,
  149.                                 JobRepository           $JobRepository,
  150.                                 CatalogService          $CatalogService,
  151.                                 CartService             $CartService,
  152.                                 GoodsService            $GoodsService,
  153.                                 Twig                    $Twig,
  154.                                 ProductRepository       $productRepository,
  155.                                 ProductClassRepository  $ProductClassRepository,
  156.                                 ClassCategoryRepository $ClassCategoryRepository,
  157.                                 CacheService            $CacheService,
  158.                                 MetaTagService          $MetaTagService,
  159.                                 EstimateCharacterizer   $EstimateCharacterizer,
  160.                                 OrderItemTypeRepository $OrderItemTypeRepository,
  161.                                 OrderService            $orderService,
  162.                                 OrderConverter          $OrderConverter,
  163.                                 OrderRepository         $OrderRepository,
  164.                                 GoodsPriceService       $GoodsPriceService,
  165.                                 AutoLoadService         $AutoLoadService,
  166.                                 MobileDetector          $mobileDetector,
  167.                                 LmMobileDetector        $LmMobileDetector,
  168.                                 FavoriteService         $FavoriteService,
  169.                                 SampleService           $SampleService,
  170.                                 PaymentService          $paymentService,
  171.                                 InventoryMatrixService  $inventoryMatrixService,
  172.                                 ReCaptchaService        $reCaptchaService,
  173.                                 ProductConverter        $productConverter
  174.     )
  175.     {
  176.         $this->Container $Container;
  177.         $this->Session $Session;
  178.         $this->RequestStack $RequestStack;
  179.         $this->LmHelper $LmHelper;
  180.         $this->CustomerService $CustomerService;
  181.         $this->CommonService $CommonService;
  182.         $this->PrefRepository $PrefRepository;
  183.         $this->JobRepository $JobRepository;
  184.         $this->Router $Container->get('router');
  185.         $this->Request $RequestStack->getCurrentRequest();
  186.         $this->CatalogService $CatalogService;
  187.         $this->CartService $CartService;
  188.         $this->GoodsService $GoodsService;
  189.         $this->Twig $Twig;
  190.         $this->ProductRepository $productRepository;
  191.         $this->ProductClassRepository $ProductClassRepository;
  192.         $this->ClassCategoryRepository $ClassCategoryRepository;
  193.         $this->CacheService $CacheService;
  194.         $this->MetaTagService $MetaTagService;
  195.         $this->EstimateCharacterizer $EstimateCharacterizer;
  196.         $this->OrderItemTypeRepository $OrderItemTypeRepository;
  197.         $this->OrderService $orderService;
  198.         $this->OrderConverter $OrderConverter;
  199.         $this->OrderRepository $OrderRepository;
  200.         $this->GoodsPriceService $GoodsPriceService;
  201.         $this->AutoLoadService $AutoLoadService;
  202.         $this->mobileDetector $mobileDetector;
  203.         $this->LmMobileDetector $LmMobileDetector;
  204.         $this->FavoriteService $FavoriteService;
  205.         $this->SampleService $SampleService;
  206.         $this->paymentService $paymentService;
  207.         $this->inventoryMatrixService $inventoryMatrixService;
  208.         $this->reCaptchaService $reCaptchaService;
  209.         $this->productConverter $productConverter;
  210.     }
  211.     public function getFunctions()
  212.     {
  213.         return [
  214.             new TwigFunction('Service', function ($Service) {
  215.                 return new $Service($this->Container$this->RequestStack);
  216.             }, ['pre_escape' => 'html''is_safe' => ['html']]),
  217.             new TwigFunction('LmCssList', [$this'GetLmCssList']),
  218.             new TwigFunction('LmCartType', [$this'GetLmCartType']),
  219.             new TwigFunction('FristLogin', [$this'GetFirstLogin']),
  220.             new TwigFunction('AmazonLogin', [$this'GetAmazonLogin']),
  221.             new TwigFunction('GetPrefs', [$this'GetPrefs']),
  222.             new TwigFunction('GetLmCuatomer', [$this'GetLmCuatomer']),
  223.             new TwigFunction('GetJob', [$this'GetJob']),
  224.             new TwigFunction('GetPrivacy3', [$this'GetPrivacy3']),
  225.             new TwigFunction('OlToken', [$this'GetOlToken']),
  226.             new TwigFunction('RequestLmOrderOption', [$this->CommonService'RequestLmOrderOption']),
  227.             new TwigFunction('Survey', [$this->CommonService'SetSurvey']),
  228.             new TwigFunction('SurveyData', [$this->CommonService'SetSurveyData']),
  229.             new TwigFunction('RequestUri', [$this'GetRequestUri']),
  230.             new TwigFunction('CouponData', [$this'GetCouponData']),
  231.             new TwigFunction('InitiarizeLmOrederOption', [$this'SetInitiarizeLmOrederOption']),
  232.             new TwigFunction('DiscountName', [$this'SetDiscountName']),
  233.             new TwigFunction('SetReceipt', [$this'SetReceipt']),
  234.             new TwigFunction('Receipt', [$this'GetReceipt']),
  235.             new TwigFunction('LmOptionName', [$this'GetLmOptionName']),
  236.             new TwigFunction('CatalogLimit', [$this->CatalogService'GetLimit']),
  237.             new TwigFunction('CatalogLimitMessage', [$this'CatalogLimitMessage']),
  238.             new TwigFunction('CatalogValidation', [$this->CatalogService'CatalogValidation']),
  239.             new TwigFunction('CatalogChecked', [$this'GetCatalogChecked']),
  240.             new TwigFunction('ShoppingTitle', [$this'SetShoppingTitle']),
  241.             new TwigFunction('ShoppingConfirmBtn', [$this'ShoppingConfirmBtn']),
  242.             new TwigFunction('GetCatalogViews', [$this'GetCatalogViews']),
  243.             new TwigFunction('GetSampleCatalogs', [$this->CatalogService'GetSampleCatalogs']),
  244.             new TwigFunction('CartSumImage', [$this'GetCartSumImage']),
  245.             new TwigFunction('GoodsMainImage', [$this'GetGoodsMainImage']),
  246.             new TwigFunction('CartItemPullDown', [$this'GetCartItemPullDown']),
  247.             new TwigFunction('LoadStockLabel', [$this'getStockLabel']),
  248.             new TwigFunction('CartItemSizePullDown', [$this'GetCartItemSizePullDown']),
  249.             new TwigFunction('CartItemColorPullDown', [$this'GetCartItemColorPullDown']),
  250.             new TwigFunction('lm_tax', [$this'GetLmTax']),
  251.             new TwigFunction('Caet_item_stock', [$this'GetCartItmeStock']),
  252.             new TwigFunction('CartItemSameDayShippingFlg', [$this'GetCartItemSameDayShippingFlg']),
  253.             new TwigFunction('CartItemStockNumber', [$this'GetCartItemStockNumber']),
  254.             new TwigFunction('GetConfig', [$this'GetConfig']),
  255.             new TwigFunction('GetCartNextBtnText', [$this'GetCartNextBtnText']),
  256.             new TwigFunction('GetCartBackBtnText', [$this'GetCartBackBtnText']),
  257.             new TwigFunction('GetShoppingNextBtnText', [$this'GetShoppingNextBtnText']),
  258.             new TwigFunction('GetShoppingBackBtnText', [$this'GetShoppingBackBtnText']),
  259.             new TwigFunction('GetLmOrderOption', [$this'GetLmOrderOption']),
  260.             new TwigFunction('Bank', [$this'GetBank']),
  261.             new TwigFunction('JunctionMode', [$this->CommonService'GetJunctionMode']),
  262.             new TwigFunction('CartHybridBtn', [$this'SetCartHybridBtn']),
  263.             new TwigFunction('CartHybridBtnByCartItem', [$this'ShowCartHybridBtnByCartItem']),
  264.             new TwigFunction('ShowOrderItem', [$this'SetShowOrderItem']),
  265.             new TwigFunction('ExclusionControl', [$this'SetExclusionControl']),
  266.             new TwigFunction('SetMetaTags', [$this'SetMetaTags']),
  267.             new TwigFunction('HeaderH1', [$this'SetHeaderH1']),
  268.             new TwigFunction('SetBreadCrumb', [$this'SetBreadCrumb']),
  269.             new TwigFunction('EstimateCharaCart', [$this'SetEstimateCharaCart']),
  270.             new TwigFunction('ItemType', [$this'GetItemType']),
  271.             new TwigFunction('isSliderEnabled', [$this'isSliderEnabled']),
  272.             new TwigFunction('PaymentDetails', [$this'GetPaymentDetails']),
  273.             new TwigFunction('SetEstimateOptions', [$this'SetEstimateOptions']),
  274.             new TwigFunction('GetEstimateOption', [$this'GetEstimateOption']),
  275.             new TwigFunction('ShowEstimateOptions', [$this'ShowEstimateOptions']),
  276.             new TwigFunction('ShowEstimateMobileOptions', [$this'ShowEstimateMobileOptions']),
  277.             new TwigFunction('ShowEstimateOptionsMail', [$this'ShowEstimateOptionsMail']),
  278.             new TwigFunction('ZeusCardDatas', [$this'GetZeusCardDatas']),
  279.             new TwigFunction('ZeusCardError', [$this'GetZeusCardError']),
  280.             new TwigFunction('EstimateType', [$this'GetEstimateType']),
  281.             new TwigFunction('GetCustomerBangou', [$this'GetCustomerBangou']),
  282.             new TwigFunction('NariKawariSession', [$this->AutoLoadService'GetNariKawariSession']),
  283.             new TwigFunction('NariKawariFormData', [$this->AutoLoadService'GetNariKawariFormData']),
  284.             new TwigFunction('GetCatalogNoukiSchedule', [$this'getCatalogNoukiSchedule']),
  285.             new TwigFunction('CartSortFlg', [$this'GetCartSortFlg']),
  286.             new TwigFunction('CartAddLine', [$this'GetCartAddLine']),
  287.             new TwigFunction('PageType', [$this'getPageType']),
  288.             new TwigFunction('isMobile', [$this'isMobile']),
  289.             new TwigFunction('wannaSeePc', [$this'wannaSeePc']),
  290.             new TwigFunction('CartBackBtn', [$this'GetCartBackBtn']),
  291.             new TwigFunction('WithGetParams', [$this'WithGetParams']),
  292.             new TwigFunction('PageWithGetParams', [$this'PageWithGetParams']),
  293.             new TwigFunction('ShowSendScheduleDate', [$this'showSendScheduleDate']),
  294.             new TwigFunction('ShowSendScheduleMessage', [$this'showSendScheduleMessage']),
  295.             new TwigFunction('GetCategoryImageUrlById', [$this'getCategoryImageUrlById']),
  296.             new TwigFunction('EigyoubiCalendar', [$this->CommonService'EigyoubiCalendar']),
  297.             new TwigFunction('GetOrderPaymentId', [$this'getOrderPaymentId']),
  298.             new TwigFunction('GetShippingAddr03', [$this->CustomerService'getShippingAddr03']),
  299.             new TwigFunction('GetLandMarkCustomerInfo', [$this->CustomerService'GetLandMarkCustomerId']),
  300.             new TwigFunction('CalculateTotalQuantityForOrder', [$this->CommonService'calculateTotalQuantityForOrder']),
  301.             new TwigFunction('getMessageForPayment', [$this->paymentService'getMessage']),
  302.             new TwigFunction('GetFavoriteFlashMessage', [$this->FavoriteService'getFavoriteFlashMessage']),
  303.             new TwigFunction('GetFavoriteFlashGoods', [$this->FavoriteService'getFavoriteFlashGoods']),
  304.             new TwigFunction('FileUploadNotice', [$this'showFileSizeUpload']),
  305.             new TwigFunction('GetSampleLimitError', [$this->SampleService'getSampleLimitError']),
  306.             new TwigFunction('formatDataToJson', [$this'formatDataToJson']),
  307.             new TwigFunction('getCurrentBreadcrumb', [$this'getCurrentBreadcrumb']),
  308.             new TwigFunction('getCartSessionName', [$this'getCartSessionName']),
  309.             new TwigFunction('groupItemsHasSameProductId', [$this'groupItemsHasSameProductId']),
  310.             new TwigFunction('getColorRGBCode', [$this'getColorRGBCode']),
  311.             new TwigFunction('formatDate', [$this'formatDate']),
  312.             new TwigFunction('formatMonthAndDay', [$this'formatMonthAndDay']),
  313.             new TwigFunction('formatStockArrivalDate', [$this'formatStockArrivalDate']),
  314.             new TwigFunction('getToTraceParent', function () {
  315.                 return $this->RequestStack->getCurrentRequest()->attributes->get('toTraceParent');
  316.             }),
  317.             new TwigFunction('getTrackId', function () {
  318.                 return $this->RequestStack->getCurrentRequest()->attributes->get('toTrackId');
  319.             }),
  320.             new TwigFunction('getInventoryMatrix', [$this'getInventoryMatrixData']),
  321.             new TwigFunction('shouldProcessReCaptcha', [$this->reCaptchaService'shouldProcessReCaptcha']),
  322.             new TwigFunction('showYoyakuFlag', [$this'showYoyakuFlag']),
  323.             new TwigFunction('showSokujitsuHassouBannerIfSo', [$this'showSokujitsuHassouBannerIfSo']),
  324.         ];
  325.     }
  326.     /**
  327.      * Get inventory matrix via cache
  328.      *
  329.      * @param GoodsWithRelated $goods
  330.      * @param $color
  331.      * @param $size
  332.      * @return mixed|null
  333.      * @throws \Psr\Cache\InvalidArgumentException
  334.      */
  335.     public function getInventoryMatrixData(GoodsWithRelated $goods, &$color null, &$size null)
  336.     {
  337.         $cacheKey $this->LmHelper->getCacheKey("getInventoryMatrixData", [$goods$color$size]);
  338.         $id $goods->getGoodsId();
  339.         $stock $this->GoodsService->getGoodsStock($id1); // value of stock is not should cache
  340.         return $this->getCacheByKey($cacheKey, function () use ($goods$color$size$stock$id) {
  341.             // JAN情報(=product_class id)
  342.             list($jan$janColor) = $this->productConverter->getGoodsJanById($id);
  343.             // 色情報
  344.             $color $this->GoodsService->getGoodsColorSelectSql($id);
  345.             // サイズ情報
  346.             $size $this->GoodsService->getGoodsSizeListById($id);
  347.             // 商品即日情報
  348.             $sokujitsu $this->GoodsService->getGoodsSameDayShipping($id1);
  349.             // 商品在庫情報
  350.             // 商品予約情報
  351.             $yoyaku $this->GoodsService->getGoodsReservation($id1);
  352.             // 商品入荷予定日情報
  353.             $yoteibi $this->GoodsService->getGoodsStockDate($id1);
  354.             // カートマトリックス用のデータ生成
  355.             $matrixData = [];
  356.             $matrixData_cnt = [];
  357.             $line 0;
  358.             $sizeMax = ($this->LmMobileDetector->isMobile() ? 999 8);
  359.             $max 0;
  360.             foreach ($color as $v1) {
  361.                 $line++;
  362.                 $line2 0;
  363.                 $no 1;
  364.                 foreach ($size as $v2) {
  365.                     if ($line2 % ($sizeMax) === 0) {
  366.                         $no++;
  367.                     } else {
  368.                         $max $line2 % ($sizeMax);
  369.                     }
  370.                     $tmpYoteibi NULL;
  371.                     if (!empty($yoteibi[$v1["gcl_id"]][$v2["gp_id"]]) and $sokujitsu[$v1["gcl_id"]][$v2["gp_id"]] <= SokujitsuHassou::FLG_NONE) {
  372.                         $tmpYoteibi date("n月j日"strtotime($yoteibi[$v1["gcl_id"]][$v2["gp_id"]]));
  373.                     }
  374.                     $matrixData_cnt[$no] = $max;
  375.                     $matrixData[$no][$line][$line2] = [
  376.                         'line' => $line,
  377.                         'product_id' => $jan[$v1["gcl_id"]][$v2["gp_id"]],
  378.                         'shiire_color' => $janColor[$v1["gcl_id"]][$v2["gp_id"]],
  379.                         'color' => $v1,
  380.                         'size' => $v2,
  381.                         'stock' => $stock[$v1["gcl_id"]][$v2["gp_id"]],
  382.                         'yoyaku' => $yoyaku[$v1["gcl_id"]][$v2["gp_id"]],
  383.                         'yoteibi' => $tmpYoteibi,
  384.                         'sokujitsu' => $sokujitsu[$v1["gcl_id"]][$v2["gp_id"]],
  385.                     ];
  386.                     $line2++;
  387.                 }
  388.             }
  389.             return $matrixData;
  390.         });
  391.     }
  392.     public function getFilters()
  393.     {
  394.         return [
  395.             new TwigFilter('Base', [$this'BaseInfo']),
  396.             new TwigFilter('LmPrice', [$this'GetLmPrice']),
  397.             new TwigFilter('FormatPrice', [$this'FormatPrice']),
  398.             new TwigFilter('phone', [$this'SetPhone']),
  399.             new TwigFilter('post', [$this'SetPost']),
  400.             new TwigFilter('jweek', [$this'SetJWeek']),
  401.             new TwigFilter('AjaxPrice', [$this->GoodsPriceService'embedGoodsPrice']),
  402.             new TwigFilter('OrderId', [$this->LmHelper'convertOrderToOrderId']),
  403.             new TwigFilter('InventoryMatrix', [$this'showInventoryMatrix']),
  404.             new TwigFilter('LmWebTeika', [$this'filterLmWebTeika']),
  405.             new TwigFilter('LmWebPrice', [$this'filterLmWebPrice']),
  406.         ];
  407.     }
  408.     public function getTests()
  409.     {
  410.         return [
  411.             new TwigTest('numeric''is_numeric'),
  412.         ];
  413.     }
  414.     /**
  415.      * Master Job をゲットする
  416.      *
  417.      * @return obj Job
  418.      */
  419.     public function GetPrefs()
  420.     {
  421.         return $this->PrefRepository->finsBy([], ['sort_no' => 'asc']);
  422.     }
  423.     public function GetJob()
  424.     {
  425.         return $this->JobRepository->findBy([], ['sort_no' => 'asc']);
  426.     }
  427.     /**
  428.      * TWIG に LMカートタイプを返す
  429.      *   cart_type:
  430.      * 1 -- 購入(加工なし)
  431.      * 2 -- 購入(加工あり(加工なしとの混在含む))
  432.      * 3 -- 貸出サンプル
  433.      * 4 -- カタログ請求
  434.      */
  435.     public function GetLmCartType()
  436.     {
  437.         return $this->LmHelper->getCartType();
  438.     }
  439.     /**
  440.      * 初回ログイン
  441.      *
  442.      */
  443.     public function GetFirstLogin()
  444.     {
  445.         $Flg $this->CustomerService->GetFirstLoginFlg();
  446.         $this->CustomerService->SetFirstLoginFlg(null);
  447.         return $Flg;
  448.     }
  449.     public function GetLmCuatomer($Eail)
  450.     {
  451.         if (!$Lmcustomer $this->CustomerService->GetLandMarkCustomerEmail($Eail)) {
  452.             $Columns $this->CommonService->GetYaml('LmCustomer.yaml');
  453.             foreach ($Columns as $Column) {
  454.                 switch ($Column) {
  455.                     case 'address03':
  456.                         $Lmcustomer['customer_address3'] = '';
  457.                         break;
  458.                     case 'fax_number':
  459.                         $Lmcustomer['customer_fax'] = '';
  460.                         break;
  461.                     default:
  462.                         $Lmcustomer[$Column] = '';
  463.                         break;
  464.                 }
  465.             }
  466.         };
  467.         return $Lmcustomer;
  468.     }
  469.     /**
  470.      * アマゾンログイン
  471.      *
  472.      */
  473.     public function GetAmazonLogin()
  474.     {
  475.         return $this->CustomerService->GetAmazonLoginFlg();
  476.     }
  477.     /**
  478.      *  LMプライバシーポリシーの取得
  479.      *
  480.      * @return string admin_privacy3
  481.      */
  482.     public function GetPrivacy3()
  483.     {
  484.         $Sql = new SqlService;
  485.         $Data $Sql->Table('admin_table')
  486.             ->Find();
  487.         return $Data['admin_privacy3'] ?? '';
  488.     }
  489.     /**
  490.      * オリジナルトークンを返す
  491.      * @param string $Cd
  492.      * @param string $name 'token'
  493.      *
  494.      * @return string $Token
  495.      */
  496.     public function GetOlToken($Cd$Name 'token')
  497.     {
  498.         return $this->CommonService->ResetToken($Cd$Name);
  499.     }
  500.     /**
  501.      * クーポンの値引き時 リダイレクト先URIを返す
  502.      *
  503.      */
  504.     public function GetRequestUri()
  505.     {
  506.         return $this->Request->server->get('REQUEST_URI');
  507.     }
  508.     /**
  509.      * クーポンのData
  510.      *
  511.      */
  512.     public function GetCouponData()
  513.     {
  514.         return $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Coupon);
  515.     }
  516.     /**
  517.      * 領収書
  518.      *
  519.      */
  520.     public function SetReceipt($CompanyName$Name$Write)
  521.     {
  522.         $Receipt $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Receipt);
  523.         $Re $Receipt;
  524.         $Re['flg'] = [''''];
  525.         if (!$Receipt) {
  526.             $Re['name'] = $CompanyName $CompanyName $Name;
  527.             $Re['flg'][0] = 'checked="checked"';
  528.             $Re['write'] = $Write;
  529.             $Re['comment'] = '';
  530.         } else {
  531.             $Re['flg'][$Receipt['flg']] = 'checked="checked"';
  532.         }
  533.         return $Re;
  534.     }
  535.     public function GetReceipt()
  536.     {
  537.         if (!$Receipt $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Receipt)) {
  538.             return false;
  539.         }
  540.         return $Receipt['flg'] == false $Receipt;
  541.     }
  542.     public function GetLmOptionName($Name null)
  543.     {
  544.         switch ($Name) {
  545.             case 'catalog':
  546.                 $Re CommonService::Lm_Option_Catalog;
  547.                 break;
  548.             case 'receipt';
  549.             default:
  550.                 $Re CommonService::Lm_Option_Receipt;
  551.                 break;
  552.         }
  553.         return $Re;
  554.     }
  555.     /**
  556.      * LMOrderPption 初期化
  557.      *
  558.      */
  559.     public function SetInitiarizeLmOrederOption($OrderId)
  560.     {
  561.         $this->CommonService->SetInitiarizeLmOrederOption($OrderId);
  562.     }
  563.     public function SetShoppingTitle($Message$Num)
  564.     {
  565.         $Message trans($Message);
  566.         if (is_null($Num)) {
  567.             return $Message;
  568.         }
  569.         return $this->LmHelper->getCartType() <= CartService::CartTypeEstimate $Num '.' $Message $Message;
  570.     }
  571.     /**
  572.      * 確認気年のボタン
  573.      *
  574.      * @return string
  575.      */
  576.     public function ShoppingConfirmBtn()
  577.     {
  578.         $Message 'front.shopping.checkout';
  579.         switch ($this->LmHelper->getCartType()) {
  580.             case CartService::CartTypeCatalog:
  581.                 $Message 'front.Shopping_Button04';
  582.                 break;
  583.             case CartService::CartTypeNormal:
  584.             default:
  585.                 break;
  586.         }
  587.         return $Message;
  588.     }
  589.     public function GetCatalogChecked($Id$Name null)
  590.     {
  591.         $Checked = ['''checked="checked"'];
  592.         if ('Open' == $Name) {
  593.             $OpenCtalog $this->CommonService->GetLmOrderOption('OpenCatalog');
  594.             if (is_null($OpenCtalog) && $Id == 0) {
  595.                 return $Checked[1];
  596.             }
  597.             return $Id == $OpenCtalog $Checked[1] : $Checked[0];
  598.         }
  599.         if (!$this->CatalogValue) {
  600.             if ($Value $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Catalog)) {
  601.                 $this->CatalogValue array_flip($Value);
  602.             }
  603.         }
  604.         if (isset($this->CatalogValue[$Id])) {
  605.             return $Checked[1];
  606.         }
  607.         return $Checked[0];
  608.     }
  609.     public function GetLmOrderOption($name)
  610.     {
  611.         return $this->CommonService->GetLmOrderOption($name);
  612.     }
  613.     /**
  614.      * LMOrderPption クーポン
  615.      * ショッピング 表示
  616.      *
  617.      * @return string $name
  618.      */
  619.     public function SetDiscountName()
  620.     {
  621.         return $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Coupon) ? 'クーポン' trans('common.discount');
  622.     }
  623.     /**
  624.      * カタログの札数メッセージ
  625.      *
  626.      * @param int num
  627.      *
  628.      * @return string メッセージ
  629.      */
  630.     public function CatalogLimitMessage($Num)
  631.     {
  632.         return str_replace('@@'$Numtrans('front.cart_catalog.message09'));
  633.     }
  634.     public function CatalogValidation()
  635.     {
  636.         if (CartService::CartTypeCatalog != $this->CartService->getCartType()) {
  637.             return false;
  638.         }
  639.         return $this->CatalogService->CatalogValidation();
  640.     }
  641.     public function GetCatalogViews()
  642.     {
  643.         return $this->CatalogService->GetView();
  644.     }
  645.     /**
  646.      * カートにて サムネイルのURLを生成する
  647.      *
  648.      */
  649.     public function GetCartSumImage($ProductId)
  650.     {
  651.         $Dir substr($ProductId, -1);
  652.         return "/goods.img/{$Dir}/{$ProductId}/main_sum.jpg";
  653.     }
  654.     /**
  655.      * カートにて サムネイルのURLを生成する
  656.      *
  657.      */
  658.     public function GetGoodsMainImage($ProductId)
  659.     {
  660.         $Dir substr($ProductId, -1);
  661.         return "/goods.img/{$Dir}/{$ProductId}/main.jpg";
  662.     }
  663.     /**
  664.      * LMの価格に対して 税込価格を返す
  665.      *
  666.      */
  667.     public function GetLmTax($ProductClassId)
  668.     {
  669.         $ProductClass $this->ProductClassRepository->find($ProductClassId);
  670.         return $ProductClass->getPrice02IncTax();
  671.     }
  672.     /**
  673.      * LM在庫数を返す
  674.      *
  675.      * 0 ・・・ 在庫なし
  676.      * 1以上 ・・・ 在庫あり
  677.      * # null ・・・ 99(入荷予定)
  678.      * #  *   ・・・ 999
  679.      *`@param int ClassId
  680.      *
  681.      * @return string 在庫数
  682.      */
  683.     public function GetCartItmeStock($ProductClass)
  684.     {
  685.         $ClassId $ProductClass->getId();
  686.         $Stock $this->GoodsService->getValidationStock($ClassId);
  687.         $Re '';
  688.         switch (true) {
  689.             case is_null($Stock):
  690.                 $Re trans('front.cart_item.title10');
  691.                 break;
  692.             case $Stock == 0:
  693.                 $Re trans('front.cart_item.title11');;
  694.                 break;
  695.             default:
  696.                 $Text $this->CommonService->GetConfig('ESTIMATE_TEXT');
  697.                 $Re $Text['Text23'] . number_format($Stock) . $Text['Text04'];
  698.                 break;
  699.         }
  700.         return $Re;
  701.     }
  702.     public function GetCartItemSameDayShippingFlg($ProductClass$quantity null)
  703.     {
  704.         $result $this->GoodsService->getGoodsSameDayShipping($ProductClass->getProduct()->getId(), 0$ProductClass->getId(), nullnull$quantity);
  705.         return $result;
  706.     }
  707.     public function GetCartItemStockNumber($productClass$sameShippingFlg)
  708.     {
  709.         $stock $this->GoodsService->getGoodsStock(nullfalse$productClass->getId());
  710.         if ($sameShippingFlg SokujitsuHassou::FLG_NONE) {
  711.             return $stock['stock_sokujitsu'];
  712.         } else {
  713.             return $stock['stock_total'];
  714.         }
  715.     }
  716.     public function GetCartNextBtnText()
  717.     {
  718.         switch ($this->GetLmCartType()) {
  719.             case CartService::CartTypeSample:
  720.                 return 'サンプル申込の手続きへ';
  721.             case CartService::CartTypeNormal:
  722.             case CartService::CartTypeEstimate:
  723.             default:
  724.                 return '次へ(レジへ進む)';
  725.         }
  726.     }
  727.     public function GetCartBackBtnText()
  728.     {
  729.         switch ($this->GetLmCartType()) {
  730.             case CartService::CartTypeSample:
  731.                 return '他にもサンプル申込商品を選ぶ';
  732.             case CartService::CartTypeNormal:
  733.             case CartService::CartTypeEstimate:
  734.             default:
  735.                 return '買い物を続ける';
  736.         }
  737.     }
  738.     public function GetShoppingNextBtnText()
  739.     {
  740.         switch ($this->GetLmCartType()) {
  741.             case CartService::CartTypeSample:
  742.                 return '同意して次へ';
  743.             case CartService::CartTypeCatalog:
  744.                 return '送信する';
  745.             case CartService::CartTypeNormal:
  746.             case CartService::CartTypeEstimate:
  747.             default:
  748.                 return '確認画面に進む';
  749.         }
  750.     }
  751.     public function GetShoppingBackBtnText()
  752.     {
  753.         switch ($this->GetLmCartType()) {
  754.             case CartService::CartTypeCatalog:
  755.                 return '入力画面に戻る';
  756.             case CartService::CartTypeNormal:
  757.             case CartService::CartTypeEstimate:
  758.             case CartService::CartTypeSample:
  759.             default:
  760.                 return 'カートに戻る';
  761.         }
  762.     }
  763.     public function GetConfig($key)
  764.     {
  765.         return $this->LmHelper->getConfig($key);
  766.     }
  767.     public function getColorRGBCode($productId)
  768.     {
  769.         $colors = [];
  770.         $goodColors $this->GoodsService->getGoodsColorSelectSql($productId);
  771.         if (is_array($goodColors) && count($goodColors) > 0) {
  772.             foreach ($goodColors as $goodColor) {
  773.                 if (!$goodColor['color_name']) {
  774.                     continue;
  775.                 }
  776.                 $id $this->LmHelper->convGclIdToClassCategory1Id($goodColor['gcl_id']);
  777.                 $colors[$id] = $goodColor['color_rgb'];
  778.             }
  779.         }
  780.         return $colors;
  781.     }
  782.     public function GetCartItemColorPullDown($ItemId$ProductId$classCategory1Id$EstimateId$EmptyOptionAsFirst false$isAjaxCart false$classCategory2Id null)
  783.     {
  784.         //
  785.         $Type 'color';
  786.         //
  787.         $Data = [];
  788.         $Value null;
  789.         $Id 0;
  790.         //
  791.         $kbn 1;
  792.         if ($classCategory1Id) {
  793.             $ClassCategory1 $this->ClassCategoryRepository->find($classCategory1Id);
  794.             $Value $ClassCategory1->getId();
  795.             $ClassName $ClassCategory1->getClassName();
  796.             $kbn $ClassName->getId();
  797.         }
  798.         foreach ($this->GoodsService->getGoodsColorSelectSql($ProductId) as $Val) {
  799.             if (!$Val['color_name']) {
  800.                 continue;
  801.             }
  802.             $Id $this->LmHelper->convGclIdToClassCategory1Id($Val['gcl_id']);
  803.             $Selected = !$EmptyOptionAsFirst && $Value == $Id 'selected="selected"' '';
  804.             $Rgb 'data-rgb=#' $Val['color_rgb'];
  805.             $disabled '';
  806.             if($isAjaxCart && $classCategory2Id){
  807.                 $estId =  $classCategory2Id;
  808.                 $estId $this->LmHelper->convClassCategory2IdToGpIdRe($estId);
  809.                 try {
  810.                     $result = (new SqlService())
  811.                         ->Select('*')
  812.                         ->Table('jancode_table')
  813.                         ->Set('jan_color'$Val['gcl_id'])
  814.                         ->Set('jan_price'$estId)
  815.                         ->Find();
  816.                     if($result){
  817.                         if((is_null($result['jan_stock']) || $result['jan_stock'] > )){
  818.                             $disabled '';
  819.                         }else if((isset($result['jan_stock3']) && $result['jan_stock3'] > )){
  820.                             $disabled '';
  821.                         }else if((isset($result['jan_stock4']) && $result['jan_stock4'] > )){
  822.                             $disabled '';
  823.                         }else{
  824.                             $disabled 'disabled';
  825.                         }
  826.                     }else {
  827.                         $disabled '';
  828.                     }
  829.                 } catch (\Throwable $th) {
  830.                     $disabled '';
  831.                 }
  832.             }
  833.             $name = ($disabled == 'disabled') ? $Val['color_name'] . ' - 在庫切れ' $Val['color_name'];
  834.             $Data[$Id] = [
  835.                 'name' => $name,
  836.                 'Selected' => $Selected,
  837.                 'disabled' => $disabled,
  838.                 'Data' => $Rgb
  839.             ];
  840.         };
  841.         //
  842.         return $this->GetCartItemPullDown($ItemId$ProductId$Type$Data$Value$EstimateId$EmptyOptionAsFirst);
  843.     }
  844.     public function GetCartItemSizePullDown($ItemId$ProductId$classCategory2Id$classCategory1Id$EstimateId$EmptyOptionAsFirst false)
  845.     {
  846.         //
  847.         $Type 'size';
  848.         //
  849.         $Data = [];
  850.         $Value null;
  851.         $Id 0;
  852.         //
  853.         $kbn 2;
  854.         if ($classCategory2Id) {
  855.             $ClassCategory2 $this->ClassCategoryRepository->find($classCategory2Id);
  856.             $Value $ClassCategory2->getId();
  857.             $ClassName $ClassCategory2->getClassName();
  858.             $kbn $ClassName->getId();
  859.         }
  860.         if ($classCategory1Id) {
  861.             //
  862.             $ClassCategory1 $this->ClassCategoryRepository->find($classCategory1Id);
  863.             $sizeList $this->GoodsService->getGoodsSizeListWithStockInfoByClassCategory1($ClassCategory1);
  864.         } else {
  865.             $sizeList $this->GoodsService->getGoodsSizeListById($ProductId);
  866.         }
  867.         foreach ($sizeList as $Val) {
  868.             if (!$Val['size_name']) {
  869.                 continue;
  870.             }
  871.             $Id $this->LmHelper->convGpIdToClassCategory2Id($Val['gp_id']);
  872.             $Selected = !$EmptyOptionAsFirst && $Value == $Id 'selected="selected"' '';
  873.             $disabled = (isset($Val['disabled']) && $Val['disabled'] === 1) ? 'disabled' '';
  874.             $Data[$Id] = [
  875.                 'name' => $Val['size_name'],
  876.                 'Selected' => $Selected,
  877.                 'disabled' => $disabled,
  878.                 'Data' => ''
  879.             ];
  880.         };
  881.         //
  882.         return $this->GetCartItemPullDown($ItemId$ProductId$Type$Data$Value$EstimateId$EmptyOptionAsFirst);
  883.     }
  884.     public function GetCartItemPullDown($ItemId$ProductId$Type$ItemDatas$Value$EstimateId$EmptyOptionAsFirst false)
  885.     {
  886.         //
  887.         $Re = [
  888.             'ItemId' => $ItemId,
  889.             'ProductId' => $ProductId,
  890.             'Type' => $Type,
  891.             'ItemDatas' => $ItemDatas,
  892.             'Value' => $Value,
  893.             'EstimateId' => $EstimateId,
  894.             'EmptyOptionAsFirst' => $EmptyOptionAsFirst
  895.         ];
  896.         //
  897.         return $this->Twig->render('Cart/Parts/PullDown.twig'$Re);
  898.     }
  899.     public function getStockLabel($ProductId$ClassCategory1Id$ClassCategory2Id)
  900.     {
  901.         //
  902.         $context = [
  903.             'ProductClass' => $this->ProductClassRepository->findOneBy([
  904.                 'Product' => $ProductId,
  905.                 'ClassCategory1' => $ClassCategory1Id,
  906.                 'ClassCategory2' => $ClassCategory2Id,
  907.             ]),
  908.         ];
  909.         //
  910.         return $this->Twig->render('Cart/Parts/StockLabel.twig'$context);
  911.     }
  912.     public function GetBank($Name$Bancode '')
  913.     {
  914.         if (!$this->Bank) {
  915.             $Banks $this->CommonService->GetYaml('Bank.yaml');
  916.             if ($Bancode) {
  917.                 $this->Bank $Banks[1];
  918.                 $this->Bank['account'] = $Bancode;
  919.             } else {
  920.                 $this->Bank $Banks[0];
  921.             }
  922.         }
  923.         return $this->Bank[$Name];
  924.     }
  925.     /**
  926.      * ハイブリッドボタンの設置
  927.      * 1 サンプルは出力しない
  928.      * 2 加工できない商品は出力しない
  929.      * 3 分割対応  2022/10/20
  930.      */
  931.     public function SetCartHybridBtn($ProductId$EstimateId$ItemId$btnName null)
  932.     {
  933.         #1
  934.         if ($this->CartService->getCartType() >= CartService::CartTypeSample) {
  935.             return;
  936.         }
  937.         #2
  938.         if (!$Type GoodsService::getEnableEstimateTypeById($ProductId)) {
  939.             return;
  940.         }
  941.         #3
  942.         if (CartService::CartTypeEstimate == $this->CartService->GetCartType() &&
  943.             $this->CommonService->GetConfig('BunkaruFlg') == false) {
  944.             $this->EstimateType $this->EstimateType ?? $this->CartService->GetEstimateType();
  945.         }
  946.         if (is_numeric($ItemId)) {
  947.             $Itemids $ItemId;
  948.         } else {
  949.             $Ids = [];
  950.             foreach ($ItemId as $Item) {
  951.                 if ($Item->getEstimateId() != $EstimateId) {
  952.                     continue;
  953.                 }
  954.                 $productItemId $Item->getProductClass()->getProduct()->getId();
  955.                 if (!GoodsService::getEnableEstimateTypeById($productItemId)) {
  956.                     continue;
  957.                 }
  958.                 $Ids[] = $Item->getId();
  959.             }
  960.             $Itemids implode(','$Ids);
  961.         }
  962.         $Re = [
  963.             'ItemIds' => $Itemids,
  964.             'Name' => $btnName ?? trans('front.cart_item_button04_' $Type),
  965.             'EstimateId' => $EstimateId,
  966.             'Type' => $ProductId,
  967.         ];
  968.         return $this->Twig->render('Cart/Parts/CartHybridBtn.twig'$Re);
  969.     }
  970.     /**
  971.      * @param CartItem $CartItem
  972.      * @return string
  973.      */
  974.     public function ShowCartHybridBtnByCartItem(CartItem $CartItem)
  975.     {
  976.         //
  977.         $ProductId $CartItem->getProductClass()->getProduct()->getId();
  978.         $EstimateId $CartItem->getEstimateId();
  979.         // TODO: 旧・セット品番への対応
  980.         // // $ItemId = array_filter(is_array($CartItems = $CartItem->getCart()->getCartItems()) ? $CartItems : $CartItems->toArray(), function ($CartItem) {
  981.         // //     /**
  982.         // //      * @var CartItem $CartItem
  983.         // //      */
  984.         // //     return !$this->CartService->isProductNoOptions($CartItem->getProductClass()->getProduct()->getId());
  985.         // // });
  986.         $ItemId $CartItem->getCart()->getCartItems();
  987.         $btnName $CartItem->isSusoage() ? '裾上げ内容の変更' '加工内容の変更';
  988.         //
  989.         return $this->SetCartHybridBtn($ProductId$EstimateId$ItemId$btnName);
  990.     }
  991.     public function SetShowOrderItem($Order$Type)
  992.     {
  993.         $Item null;
  994.         foreach ($Order->getOrderItems() as $OrderItem) {
  995.             $OrderItemType $OrderItem->getOrderItemType();
  996.             if ($Type == $OrderItemType->getId()) {
  997.                 $Item $OrderItem;
  998.             }
  999.         };
  1000.         if (!$Item) {
  1001.             return '';
  1002.         }
  1003.         $Re = [
  1004.             'Item' => $Item,
  1005.             'Type' => $Item->getOrderItemType(),
  1006.         ];
  1007.         return $this->Twig->render('Shopping/Parts/OrderItem.twig'$Re);
  1008.     }
  1009.     /**
  1010.      * カート排他制御
  1011.      *
  1012.      */
  1013.     public function SetExclusionControl()
  1014.     {
  1015.         $Type '';
  1016.         if (!$Type $this->Session->get(CartService::Session_ExclusionControlFlg)) {
  1017.             return;
  1018.         };
  1019.         #2022/10/22 リピート注文特殊処理 Cartエラーで返せない
  1020.         switch ($Type) {
  1021.             case CartService::RepeatError01:
  1022.                 $Messages[] = trans('front.Cart.Repeat_message01');
  1023.                 break;
  1024.             case CartService::RepeatError02:
  1025.                 $Messages[] = trans('front.ExclusionControl.message04');
  1026.                 break;
  1027.             case CartService::RepeatError03:
  1028.                 $Messages[] = trans('front.ExclusionControl.message05');
  1029.                 break;
  1030.             default:
  1031.                 for ($i 1$i <= 2$i++) {
  1032.                     $Messages[] = $this->CommonService->SetExclusionControl($Type$i);
  1033.                 }
  1034.                 break;
  1035.         }
  1036.         $this->Session->set(CartService::Session_ExclusionControlFlgnull);
  1037.         return $this->Twig->render(self::ExclusionTwig,
  1038.             [
  1039.                 'Messages' => $Messages,
  1040.             ]);
  1041.     }
  1042.     public function SetMetaTags($Datas)
  1043.     {
  1044.         $Key array_key_first($Datas);
  1045.         $Data $Datas[$Key] ?? null;
  1046.         switch (true) {
  1047.             case $Key === 'item':
  1048.                 $this->MetaTagService->SetItem($Datas[$Key]);
  1049.                 $Image $this->LmHelper->getGoodsImageUrl($Data['goods_id'], 'main.jpg');
  1050.                 $this->MetaTagService->SetOpgs(4$Image);
  1051.                 break;
  1052.             case $Key === 'SubCategory':
  1053.             case $Key === 'Category':
  1054.                 $this->MetaTagService->SetCategory($Datas[$Key]);
  1055.                 $this->MetaTagService->SetOpgs();
  1056.                 break;
  1057.             case $Key === 'message':
  1058.                 $this->MetaTagService->SetMessage($Datas[$Key]);
  1059.                 $this->MetaTagService->SetOpgs();
  1060.                 break;
  1061.             case $Key === 'review':
  1062.                 $this->MetaTagService->SetReview($Datas[$Key]);
  1063.                 $this->MetaTagService->SetOpgs(4);
  1064.                 break;
  1065.             case $Key === 0:
  1066.                 $this->MetaTagService->SetMetaTags($Data); //
  1067.                 break;
  1068.             default:
  1069.                 $this->MetaTagService->SetMetaPages(); //
  1070.                 break;
  1071.         }
  1072.         return $this->Twig->render(self::MetatagTwig, [
  1073.             'Title' => $this->MetaTagService->GetTitle(),
  1074.             'MetaTags' => $this->MetaTagService->GetMetaTags(),
  1075.             'Opgs' => $this->MetaTagService->GetOpgs(),
  1076.             'UrlName' => $this->Request->get('_route'),
  1077.         ]);
  1078.     }
  1079.     public function SetHeaderH1()
  1080.     {
  1081.         return $this->MetaTagService->GetHeaderH1();
  1082.     }
  1083.     /**
  1084.      * パンクズを一括管理する
  1085.      * @param $BreadCrumbs  string | array none 非表示
  1086.      * 1 第一因子を TOPページとする 固定
  1087.      * 2 BreadCrumbsのKEYを1にすると 最後に ページ名を追加します
  1088.      * 3 配列の内容は、KEYが href' 'label' になります
  1089.      */
  1090.     public function SetBreadCrumb($BreadCrumbs)
  1091.     {
  1092.         $Type $BreadCrumbs[0] ?? null;
  1093.         if (!is_array($Type) && $Type == 'none') {
  1094.             return;
  1095.         }
  1096.         $this->getBreadCrumb('homepage');
  1097.         $Re[] = $this->getBreadCrumb('homepage');
  1098.         #第一因子 (0)
  1099.         $UrlName $this->Request->get('_route');
  1100.         if (count($BreadCrumbs) > 0) {
  1101.             foreach ($BreadCrumbs as $Key => $BreadCrumb) {
  1102.                 $BC['label'] = $BreadCrumb['label'] ?? '';
  1103.                 $BC['href'] = $BreadCrumb['href'] ?? '';
  1104.                 switch (array_key_first($BreadCrumbs)) {
  1105.                     case 1:
  1106.                         $Re[] = $BC;
  1107.                         $Re[] = $this->getBreadCrumb($UrlName);
  1108.                         break;
  1109.                     default:
  1110.                         $Re[] = $BC;
  1111.                 }
  1112.             }
  1113.         } else {
  1114.             $Re[] = $this->getBreadCrumb($UrlName);
  1115.         }
  1116.         return $this->Twig->render(self::BreadCrumTwig, [
  1117.             'BreadCrumbs' => $Re,
  1118.         ]);
  1119.     }
  1120.     protected function getBreadCrumb($UrlName)
  1121.     {
  1122.         $Name $this->CommonService->GetPagename($UrlName);
  1123.         switch ($UrlName) {
  1124.             case 'cart':
  1125.                 if ($this->LmHelper->getCartType() == 4) {
  1126.                     $MetaTags $this->CommonService->GetYaml(CommonService::MetaTagData);
  1127.                     $Name $MetaTags['catalog']['PageName'];
  1128.                 }
  1129.                 break;
  1130.             case 'shopping_login':
  1131.                 $Name "ログイン";
  1132.                 break;
  1133.             default:
  1134.                 break;
  1135.         }
  1136.         try {
  1137.             return [
  1138.                 'href' => $this->Router->generate($UrlName) ?? '',
  1139.                 'label' => $this->LmHelper->display_text($Name)
  1140.             ];
  1141.         } catch (\Throwable $e) {
  1142.             return $this->getBreadCrumb('homepage');
  1143.         } catch (\Exception $e) {
  1144.             return $this->getBreadCrumb('homepage');
  1145.         }
  1146.     }
  1147.     public function getCurrentBreadcrumb()
  1148.     {
  1149.         $Re[] = $this->getBreadCrumb('homepage');
  1150.         $UrlName $this->Request->get('_route');
  1151.         $Re[] = $this->getBreadCrumb($UrlName);
  1152.         return $Re;
  1153.     }
  1154.     /**
  1155.      * 見積もりシミュレーション文字化
  1156.      *
  1157.      */
  1158.     public function SetEstimateCharaCart($CartKey$EstimateId$Options$isDisplayOnSp false)
  1159.     {
  1160.         if (!$Option $Options[$CartKey][$EstimateId] ?? null) {
  1161.             return;
  1162.         }
  1163.         if ($isDisplayOnSp) {
  1164.             return $this->Twig->render('Common/EstimateMobile.twig', [
  1165.                 'Prints' => $Option['print'] ?? [],
  1166.                 'Susoage' => $Option['susoage'] ?? '',
  1167.                 'Lot' => $Option['lot'] ?? null,
  1168.             ]);
  1169.         }
  1170.         return $this->Twig->render(self::EstimateTwig, [
  1171.             'Prints' => $Option['print'] ?? [],
  1172.             'Susoage' => $Option['susoage'] ?? '',
  1173.             'Lot' => $Option['lot'] ?? null,
  1174.         ]);
  1175.     }
  1176.     public function GetItemType($Id$Flg null)
  1177.     {
  1178.         $ItemType $this->OrderItemTypeRepository->find($Id);
  1179.         return $ItemType->getName();
  1180.     }
  1181.     public function GetPaymentDetails($Param$Items)
  1182.     {
  1183.         foreach ($Items as $Item) {
  1184.             $Type $Item->getOrderItemTypeId();
  1185.             if ($Type == $Param) {
  1186.                 return $Item->getPrice();
  1187.             }
  1188.         }
  1189.         return null;
  1190.     }
  1191.     /**
  1192.      * @param OrderItem[] $Items
  1193.      * @return void
  1194.      */
  1195.     public function SetEstimateOptions($Items)
  1196.     {
  1197.         $this->EstimateOptions = [];
  1198.         $EstimetIds = [];
  1199.         $Options = [];
  1200.         $I null;
  1201.         $Num 1;
  1202.         $ItemCount 0;
  1203.         foreach ($Items as $Item) {
  1204.             $ProductClass $Item->getProductClass();
  1205.             $Product $ProductClass->getProduct();
  1206.             $EstimetIds[$Product->getId()][$Item->getEstimateId()] = $Item->getId();
  1207.             $Options[$Item->getId()] = $Item->getOptions();
  1208.             $L $Product->getId() . '-' $Item->getEstimateId();
  1209.             if ($I != $L) {
  1210.                 $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['h'] = $Item->getId();
  1211.                 $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['n'] = $Num;
  1212.                 $Num++;
  1213.                 $ItemCount 0;
  1214.             }
  1215.             $I $L;
  1216.             $ItemCount++;
  1217.             $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['f'] = $Item->getId();
  1218.             $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['ItemCount'] = $ItemCount;
  1219.         }
  1220.         foreach ($EstimetIds as $ProductId) {
  1221.             foreach ($ProductId as $Id) {
  1222.                 $this->EstimateOptions[$Id] = $Options[$Id];
  1223.             }
  1224.         }
  1225.     }
  1226.     public function GetEstimateOption($Id$Page 'Shopping')
  1227.     {
  1228.         if (!$Options $this->EstimateOptions[$Id] ?? null) {
  1229.             return;
  1230.         }
  1231.         $this->EstimateCharacterizer->EstimateCharacterIzation($Options, [], $Page);
  1232.         $EstimateOption $this->EstimateCharacterizer->GetCharacters();
  1233.         return [
  1234.             'print' => $EstimateOption['print'] ?? [],
  1235.             'susoage' => $EstimateOption['susoage'] ?? '',
  1236.             'lot' => $EstimateOption['lot'] ?? null,
  1237.         ];
  1238.     }
  1239.     public function ShowEstimateOptions($Id)
  1240.     {
  1241.         if (!$OpipnData $this->EstimateOptions[$Id] ?? null) {
  1242.             return;
  1243.         }
  1244.         $this->EstimateCharacterizer->EstimateCharacterIzation($OpipnData, [], 'Shopping');
  1245.         $Option $this->EstimateCharacterizer->GetCharacters();
  1246.         return $this->Twig->render(self::ShoppingEstimate, [
  1247.             'Prints' => $Option['print'] ?? [],
  1248.             'Susoage' => $Option['susoage'] ?? '',
  1249.             'Lot' => $Option['lot'] ?? null,
  1250.         ]);
  1251.     }
  1252.     public function ShowEstimateMobileOptions($item)
  1253.     {
  1254.         if (!$optionData $this->EstimateOptions[$item->getId()] ?? null) {
  1255.             return;
  1256.         }
  1257.         $this->EstimateCharacterizer->EstimateCharacterIzation($optionData, [], 'Shopping');
  1258.         $Option $this->EstimateCharacterizer->GetCharacters();
  1259.         return $this->Twig->render(self::MobileShoppingEstimate, [
  1260.             'orderItem' => $item,
  1261.             'Prints' => $Option['print'] ?? [],
  1262.             'Susoage' => $Option['susoage'] ?? '',
  1263.             'Lot' => $Option['lot'] ?? null,
  1264.             'ProductClass' => $item->getProductClass(),
  1265.         ]);
  1266.     }
  1267.     public function ShowEstimateOptionsMail($Id$SubTotal)
  1268.     {
  1269.         if (!isset($this->EstimateOptions[$Id])) {
  1270.             return;
  1271.         }
  1272.         if (!$OptionData $this->EstimateOptions[$Id]) {
  1273.             '注文別合計:' number_format($SubTotal) . '円';
  1274.         }
  1275.         $this->EstimateCharacterizer->EstimateCharacterIzation($OptionData, [], 'Shopping');
  1276.         $Option $this->EstimateCharacterizer->GetCharacters();
  1277.         return $this->Twig->render(self::MailEstimate, [
  1278.             'Prints' => $Option['print'] ?? [],
  1279.             'Susoage' => $Option['susoage'] ?? '',
  1280.             'Lot' => $Option['lot'] ?? null,
  1281.             'kakouhi' => $Option['total'] ?? 0,
  1282.             'OptionSubTotal' => ($Option['total'] ?? 0) + ($Option['lot']['total'] ?? 0) + ($Option['product_total'] ?? 0),
  1283.         ]);
  1284.     }
  1285.     public function GetCartSortFlg($Item$Flg 'h')
  1286.     {
  1287.         $ProductClass $Item->getProductClass();
  1288.         $Product $ProductClass->getProduct();
  1289.         $ProductId $Product->getId();
  1290.         $EstimateId $Item->getEstimateId();
  1291.         $ItemId $Item->getId();
  1292.         switch ($Flg) {
  1293.             case 'f' :
  1294.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg] == $ItemId true false;
  1295.                 break;
  1296.             case 'n':
  1297.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg];
  1298.                 break;
  1299.             case 'ItemCount':
  1300.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg];
  1301.             case 'h':
  1302.             default:
  1303.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg] == $ItemId true false;
  1304.                 break;
  1305.         }
  1306.     }
  1307.     public function GetZeusCardDatas($Name$Order)
  1308.     {
  1309.         $Value '';
  1310.         switch ($Name) {
  1311.             case 'money':
  1312.                 $Value $this->OrderService->calculateCreditTotal($Order);
  1313.                 break;
  1314.             case 'sendid':
  1315.                 $Customer $Order->getCustomer();
  1316.                 $LmCustomer $this->CustomerService->GetLandMarkCustomerId($Customer->getLmCustomerId(), true);
  1317.                 $Value $LmCustomer['customer_bangou'];
  1318.                 break;
  1319.             case 'sendpoint':
  1320.                 $Value $Order->getZeusRequestData();
  1321.                 break;
  1322.             case 'telno':
  1323.                 $Value $Order->getPhoneNumber();
  1324.                 break;
  1325.             case 'email':
  1326.                 $Value $Order->getEmail();
  1327.                 break;
  1328.         }
  1329.         return $Value;
  1330.     }
  1331.     /**
  1332.      * ZeusCardError
  1333.      * カードエラーの場合表示する
  1334.      *
  1335.      */
  1336.     public function GetZeusCardError()
  1337.     {
  1338.         $CardError false;
  1339.         if ($OrderId $this->Session->get(OrderHelper::SESSION_ORDER_ID)) {
  1340.             $Order $this->OrderRepository->find($OrderId);
  1341.             $Paymenr $Order->getPayment();
  1342.             if ($this->CommonService->GetConfig('ZEUS_CARD_PAYMAET_ID') == $Paymenr->getId()) {
  1343.                 $CardError $Order->getLmOrderId();
  1344.             }
  1345.             $this->Session->get(OrderHelper::SESSION_ORDER_IDnull);
  1346.         }
  1347.         return $CardError;
  1348.     }
  1349.     public function GetEstimateType()
  1350.     {
  1351.         if ($this->CommonService->getConfig('BunkaruFlg')) {
  1352.             return 0;
  1353.         }
  1354.         switch ($this->CartService->GetCartType()) {
  1355.             case CartService::CartTypeEstimate:
  1356.                 return $this->CartService->getEstimateType();
  1357.                 break;
  1358.             case CartService::CartTypeNormal:
  1359.             default:
  1360.                 return 0;
  1361.                 break;
  1362.         }
  1363.     }
  1364.     public function GetCartAddLine($CartItem)
  1365.     {
  1366.         $Item $this->GetCartItemData($CartItem);
  1367.         $lineItemId $Item['EstimateId'] . '-' $Item['ProductId'];
  1368.         return $this->Twig->render(self::CartAddLineTwig, [
  1369.             'num' => $this->GetCartSortFlg($CartItem'n'),
  1370.             'ItemId' => $CartItem->getId(),
  1371.             'ProductId' => $Item['ProductId'],
  1372.             'ProductClass' => $Item['ProductClass'],
  1373.             'ClassCategory1Id' => $Item['ClassCategory1Id'],
  1374.             'ClassCategory2Id' => $Item['ClassCategory2Id'],
  1375.             'EstimateId' => $Item['EstimateId'],
  1376.             'lineItemId' => $lineItemId,
  1377.         ]);
  1378.     }
  1379.     protected function GetCartItemData($CartItem)
  1380.     {
  1381.         $ProductClass $CartItem->getProductClass();
  1382.         $Product $ProductClass->getProduct();
  1383.         $ClassCategory1 is_null($ProductClass) ? null $ProductClass->getClassCategory1();
  1384.         $ClassCategory1Id is_null($ClassCategory1) ? null $ClassCategory1->getId();
  1385.         $ClassCategory2 is_null($ProductClass) ? null $ProductClass->getClassCategory2();
  1386.         $ClassCategory2Id is_null($ClassCategory2) ? null $ClassCategory2->getId();
  1387.         return [
  1388.             'ProductClass' => $ProductClass,
  1389.             'Product' => $Product,
  1390.             'ProductId' => $Product->getId(),
  1391.             'ClassCategory1Id' => $ClassCategory1Id,
  1392.             'ClassCategory2Id' => $ClassCategory2Id,
  1393.             'EstimateId' => $CartItem->getEstimateId(),
  1394.         ];
  1395.     }
  1396.     public function GetCartBackBtn()
  1397.     {
  1398.         return $this->LmHelper->getBackUrl();
  1399.     }
  1400.     /********************************************************************************************************************* */
  1401.     /**
  1402.      * メッセージのbaseinfo config Messegeを 変換する
  1403.      * 例 
  1404.      *  {{BaseInfo.shop_name}}
  1405.      *  {{Config.Payment_Charge_free}}
  1406.      *  {{message.common.ResetPassward_messeg02}} or {{trans.common.ResetPassward_messeg02}}
  1407.      */
  1408.     public function BaseInfo($Text)
  1409.     {
  1410.         //     return $Text;
  1411.         return $this->CommonService->BaseInfo($Text);
  1412.     }
  1413.     /**
  1414.      * LMのプライス出力フォーマット
  1415.      * @param int $Price
  1416.      * @param string|false $yen
  1417.      */
  1418.     public function GetLmPrice($Price$yen '円')
  1419.     {
  1420.         if (!is_numeric($Price)) {
  1421.             return $Price;
  1422.         }
  1423.         if ($yen === false) {
  1424.             $yen '';
  1425.         }
  1426.         return number_format($Price) . $yen;
  1427.     }
  1428.     public function FormatPrice($Price)
  1429.     {
  1430.         if (!is_numeric($Price)) {
  1431.             return $Price;
  1432.         }
  1433.         return number_format($Price) . '<span class="prices-unit">円</span>';
  1434.     }
  1435.     /**
  1436.      * LMのプライス出力フォーマット
  1437.      *
  1438.      */
  1439.     public function SetPhone($Phone)
  1440.     {
  1441.         return $this->CommonService->GetPhoneNumber($Phonefalse);
  1442.     }
  1443.     public function SetPost($Post)
  1444.     {
  1445.         $Post str_replace('-'''$Post);
  1446.         if (strlen($Post) < 7) {
  1447.             return $Post;
  1448.         }
  1449.         return substr($Post03) . '-' substr($Post34);
  1450.     }
  1451.     public function SetJWeek($Da)
  1452.     {
  1453.         return \Lm\Util\Date::weekDay($Da\Lm\Util\Date::COUNTRY_JP);
  1454.     }
  1455.     public function GetLmCssList()
  1456.     {
  1457.         //
  1458.         $context = [];
  1459.         //
  1460.         $cssConfig $this->CommonService->GetConfig('Css');
  1461.         $cssRoot $cssConfig['Root'];
  1462.         $cssIndex $cssConfig['CssList'];
  1463.         $cssList = [];
  1464.         //
  1465.         $deviceType strtolower($this->CommonService->GetDevice(false$this->LmMobileDetector));
  1466.         //
  1467.         $pageTypeConfig $this->LmHelper->getPageType();
  1468.         $pageType $pageTypeConfig['type'];
  1469.         //
  1470.         $cssList array_merge($cssList$cssIndex[$deviceType]['common']);
  1471.         $cssList array_merge($cssList$cssIndex[$deviceType][$pageType]);
  1472.         //
  1473.         foreach ($cssList as $css) {
  1474.             $context['CssList'][] = [
  1475.                 'href' => "{$cssRoot}/{$deviceType}/{$css}",
  1476.             ];
  1477.         }
  1478.         //
  1479.         return $this->Twig->render('Common/CssList.twig'$context);
  1480.     }
  1481.     public function isSliderEnabled()
  1482.     {
  1483.         return $this->LmHelper->filterSliderEnabled();
  1484.     }
  1485.     public function GetCustomerBangou($lmCustomerId)
  1486.     {
  1487.         //
  1488.         $result = (new SqlService())
  1489.             ->Select('customer_bangou')
  1490.             ->Table('customer_table')
  1491.             ->Set('customer_id'$lmCustomerId)
  1492.             ->Find();
  1493.         //
  1494.         $customerBangou $result['customer_bangou'];
  1495.         //
  1496.         return $customerBangou;
  1497.     }
  1498.     public function getCatalogNoukiSchedule()
  1499.     {
  1500.         //
  1501.         return (new NoukiEngine())
  1502.             ->getCatalogSendDate();
  1503.     }
  1504.     public function getPageType()
  1505.     {
  1506.         return $this->LmHelper->getPageType();
  1507.     }
  1508.     /**
  1509.      * @param bool|false $strict
  1510.      * @return bool
  1511.      */
  1512.     public function isMobile($strict false)
  1513.     {
  1514.         if ($strict) {
  1515.             return $this->mobileDetector->isMobile();
  1516.         } else {
  1517.             return $this->LmMobileDetector->isMobile();
  1518.         }
  1519.     }
  1520.     /**
  1521.      * @return bool
  1522.      */
  1523.     public function wannaSeePc()
  1524.     {
  1525.         return !$this->isMobile() && $this->isMobile(true);
  1526.     }
  1527.     /**
  1528.      * @param array $paramsAdd
  1529.      * @param array $params
  1530.      * @return string
  1531.      */
  1532.     public function WithGetParams($paramsAdd$params = [])
  1533.     {
  1534.         if (is_array($params) && count($params) === 0) {
  1535.             $params $this->Request->query->all();
  1536.         }
  1537.         $params array_merge($params$paramsAdd);
  1538.         $result http_build_query($params);
  1539.         return $result;
  1540.     }
  1541.     /**
  1542.      * @param int $page
  1543.      * @return string
  1544.      */
  1545.     public function PageWithGetParams($page)
  1546.     {
  1547.         return $this->WithGetParams([
  1548.             'page' => $page,
  1549.         ]);
  1550.     }
  1551.     /**
  1552.      * @param OrderHeader|array|int $order
  1553.      * @return string|null
  1554.      * @throws \Exception
  1555.      */
  1556.     public function showSendScheduleDate($order)
  1557.     {
  1558.         try {
  1559.             /**
  1560.              * @var OrderHeader $orderHeader
  1561.              */
  1562.             if(!$order instanceof OrderHeaderExtended){
  1563.                 throw new \Exception('ERROR');
  1564.             }
  1565.             if ($orderHeader OrderHeader::factory($order)) {
  1566.                 //
  1567.                 return NoukiEngine::showSendScheduleByOrder($orderHeader);
  1568.             } else {
  1569.                 //
  1570.                 return null;
  1571.             }
  1572.         } catch (\Exception $e) {
  1573.             //
  1574.             if (is_string($order)) {
  1575.                 //
  1576.                 if (Date::validate($order'Y/m/d')) {
  1577.                     //
  1578.                     return NoukiEngine::showSendSchedule($order);
  1579.                 } else {
  1580.                     //
  1581.                     return $order;
  1582.                 }
  1583.             } else {
  1584.                 //
  1585.                 throw new \Exception('お届け予定日の計算処理に失敗しました'0$e);
  1586.             }
  1587.         }
  1588.     }
  1589.     /**
  1590.      * @param OrderHeader|array|int $order
  1591.      * @return string
  1592.      * @throws \Exception
  1593.      */
  1594.     public function showSendScheduleMessage($order$isMail false)
  1595.     {
  1596.         $orderHeader OrderHeader::factory($order);
  1597.         return $this->Twig->render(
  1598.             $isMail 'Common/SendScheduleDateMail.twig' 'Common/SendScheduleDate.twig',
  1599.             [
  1600.                 'orderHeader' => $orderHeader,
  1601.                 'isMobile' => $this->isMobile(),
  1602.                 'sendSchedule' => $this->showSendScheduleDate($order),
  1603.                 'paymentAtobarai' => [OrderHeader::PAYMENT_TYPE_ATOBARAIOrderHeader::PAYMENT_TYPE_ATOBARAI_MONTHLY],
  1604.             ]);
  1605.     }
  1606.     public function getOrderPaymentId($Order)
  1607.     {
  1608.         return !empty($Order->getPayment()) ? $Order->getPayment()->getId() : null;
  1609.     }
  1610.     public function getCategoryImageUrlById($categoryId)
  1611.     {
  1612.         return "/category_images/{$categoryId}.webp";
  1613.     }
  1614.     public function showFileSizeUpload($name 'default')
  1615.     {
  1616.         //
  1617.         $config $this->CommonService->GetConfig('FILE_UPLOAD');
  1618.         //
  1619.         if (!isset($config[$name])) {
  1620.             //
  1621.             throw new \Exception('Config name specified is invalid.');
  1622.         }
  1623.         //
  1624.         $FileUploadConfig $config[$name];
  1625.         //
  1626.         return $this->Twig->render('Common/FileUploadNotice.twig', [
  1627.             'FileUploadConfig' => $FileUploadConfig,
  1628.         ]);
  1629.     }
  1630.     public function showInventoryMatrix(GoodsWithRelated $goods)
  1631.     {
  1632.         //
  1633.         $id $goods->getGoodsId();
  1634.         $data $this->GoodsService->getGoodsById($id);
  1635.         $Product $this->ProductRepository->find($id);
  1636.         // $matrixData = $this->inventoryMatrixService->getInventoryMatrixData($goods, $color, $size);
  1637.         $inventoryMatrix = (new InventoryMatrix())
  1638.             ->getMatrixStock($goodsfalse$color$size)
  1639.         ;
  1640.         $colorCnt count($color);
  1641.         $sizeCnt count($size);
  1642.         $SellingColor $this->GoodsService->getSellingColorSql($idcount($color));
  1643.         $isShowMatrixButtonAbove = (($colorCnt * (intval(($sizeCnt 1) / 6) + 1)) >= 10);
  1644.         //
  1645.         return $this->Twig->render('Item/matrix.twig', [
  1646.             'isShowMatrixButtonAbove' => $isShowMatrixButtonAbove,
  1647.             'data' => $data,
  1648.             'goods' => $goods,
  1649.             // 'matrixData' => $matrixData,
  1650.             'Product' => $Product,
  1651.             'SellingColor' => $SellingColor,
  1652.             'inventoryMatrix' => $inventoryMatrix,
  1653.         ]);
  1654.     }
  1655.     /**
  1656.      * Handle format Object or array to json
  1657.      *
  1658.      * @param $data
  1659.      * @return string|null
  1660.      */
  1661.     public function formatDataToJson($data)
  1662.     {
  1663.         if (empty($data)) {
  1664.             return null;
  1665.         }
  1666.         return json_encode($dataJSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES);
  1667.     }
  1668.     public function getCartSessionName($key)
  1669.     {
  1670.         switch ($key) {
  1671.             case 'GROUP_1_NORMAL':
  1672.                 return '通常注文';
  1673.             case 'GROUP_2_RESERVATION':
  1674.                 return '予約注文';
  1675.             case 'GROUP_3_KYOUEI':
  1676.                 return 'メーカー「共栄-KYOEI」';
  1677.             default:
  1678.                 return '商品一覧';
  1679.         }
  1680.     }
  1681.     public function groupItemsHasSameProductId($items)
  1682.     {
  1683.         $result = [];
  1684.         foreach ($items as $item) {
  1685.             $productId $item->getProduct()->getId();
  1686.             if (!isset($result[$productId])) {
  1687.                 $result[$productId] = [];
  1688.             }
  1689.             $result[$productId][] = $item;
  1690.         }
  1691.         return $result;
  1692.     }
  1693.     /**
  1694.      * Get format date. Example: 2023/09/15 -> 2023年9月15日(金)
  1695.      *
  1696.      * @param string $date
  1697.      * @return string
  1698.      */
  1699.     public function formatDate(string $datebool $showDay true)
  1700.     {
  1701.         if (!empty($date) && strtotime($date) !== false) {
  1702.             $weekdays = [
  1703.                 => '月',
  1704.                 => '火',
  1705.                 => '水',
  1706.                 => '木',
  1707.                 => '金',
  1708.                 => '土',
  1709.                 => '日'
  1710.             ];
  1711.             $dateString date('Y年n月j日'strtotime($date));
  1712.             if ($showDay == false) {
  1713.                 return $dateString;
  1714.             }
  1715.             $dayOfWeek date('N'strtotime($date));
  1716.             $day $weekdays[$dayOfWeek];
  1717.             return $dateString '(' $day ')';
  1718.         }
  1719.         return $date;
  1720.     }
  1721.     public function formatMonthAndDay(string $datebool $showDay true$format "n/j")
  1722.     {
  1723.         if (!empty($date) && strtotime($date) !== false) {
  1724.             $weekdays = [
  1725.                 => '月',
  1726.                 => '火',
  1727.                 => '水',
  1728.                 => '木',
  1729.                 => '金',
  1730.                 => '土',
  1731.                 => '日'
  1732.             ];
  1733.             $dateString date($formatstrtotime($date));
  1734.             if ($showDay == false) {
  1735.                 return $dateString;
  1736.             }
  1737.             $dayOfWeek date('N'strtotime($date));
  1738.             $day $weekdays[$dayOfWeek];
  1739.             return $dateString '(' $day ')' ' 頃';
  1740.         }
  1741.         return $date;
  1742.     }
  1743.     /**
  1744.      * Format stock arrival date to a human-readable format
  1745.      *
  1746.      * @param string $date 入荷予定日 (YYYY-MM-DD または MM-DD 形式)
  1747.      * @return string 変換された入荷予定日(例: "3月上旬")
  1748.      * @throws \InvalidArgumentException 無効な日付形式の場合に例外をスロー
  1749.      */
  1750.     public function formatStockArrivalDate(string $date)
  1751.     {
  1752.         // 日付が `MM-DD` 形式でも許容する
  1753.         if (preg_match('/^(\d{1,2})[-\/](\d{1,2})$/'$date$matches)) {
  1754.             $month = (int)$matches[1];
  1755.             $day = (int)$matches[2];
  1756.         } elseif (strtotime($date) !== false) {
  1757.             $month = (int)date('n'strtotime($date));
  1758.             $day = (int)date('j'strtotime($date));
  1759.         } else {
  1760.             throw new \InvalidArgumentException('無効な日付形式です。MM-DD または YYYY-MM-DD 形式で入力してください。');
  1761.         }
  1762.         if ($day >= && $day <= 10) {
  1763.             return "{$month}月上旬〜順次";
  1764.         } elseif ($day >= 11 && $day <= 20) {
  1765.             return "{$month}月中旬〜順次";
  1766.         } else {
  1767.             return "{$month}月下旬〜順次";
  1768.         }
  1769.     }
  1770.     public function getDayOfWeek(string $date)
  1771.     {
  1772.         if (!empty($date) && strtotime($date) !== false) {
  1773.             $weekdays = [
  1774.                 => '月',
  1775.                 => '火',
  1776.                 => '水',
  1777.                 => '木',
  1778.                 => '金',
  1779.                 => '土',
  1780.                 => '日'
  1781.             ];
  1782.             $dayOfWeek date('N'strtotime($date));
  1783.             return $weekdays[$dayOfWeek];
  1784.         }
  1785.         return null;
  1786.     }
  1787.     /**
  1788.      * @param int $goodsId
  1789.      * @param int $janId
  1790.      * @return string
  1791.      */
  1792.     public function showYoyakuFlag($goodsId$janId)
  1793.     {
  1794.         //
  1795.         return Yoyaku::check($goodsIdfalse$janId) ? '(予約)' null;
  1796.     }
  1797.     /**
  1798.      * @param Item|Goods|int
  1799.      * @return string
  1800.      */
  1801.     public function filterLmWebTeika($item) {
  1802.         /**
  1803.          * @var Item $Item
  1804.          */
  1805.         $item Item::factory($item);
  1806.         //
  1807.         return $this->Twig->render('Common/LmWebPrice.twig', [
  1808.             'minPrice' => $item->getMinTeika(),
  1809.             'maxPrice' => $item->getMaxTeika(),
  1810.         ]);
  1811.     }
  1812.     /**
  1813.      * @param Item|Goods|int
  1814.      * @return string
  1815.      */
  1816.     public function filterLmWebPrice($item) {
  1817.         /**
  1818.          * @var Item $Item
  1819.          */
  1820.         $item Item::factory($item);
  1821.         //
  1822.         return $this->Twig->render('Common/LmWebPrice.twig', [
  1823.             'minPrice' => $item->getMinPrice(),
  1824.             'maxPrice' => $item->getMaxPrice(),
  1825.         ]);
  1826.     }
  1827.     /**
  1828.      * @param Goods $goods
  1829.      * @return string
  1830.      */
  1831.     public function showSokujitsuHassouBannerIfSo(Goods $goods)
  1832.     {
  1833.         /**
  1834.          * @var GoodsWithRelated $goods
  1835.          */
  1836.         $goods GoodsWithRelated::factory($goods);
  1837.         //
  1838.         return $this->Twig->render('Common/SokujitsuHassouBanner.twig', [
  1839.             'goods' => $goods,
  1840.         ]);
  1841.     }
  1842. }