app/Customize/Service/DynamicConverterService.php line 74

Open in your IDE?
  1. <?php
  2. namespace Customize\Service;
  3. use Customize\Entity\CacheTrait;
  4. use Lm\Service\Db\SqlService;
  5. class DynamicConverterService
  6. {
  7.     use CacheTrait;
  8.     public function getFbnrs($params$siteType$webName)
  9.     {
  10.         //
  11.         $cacheKey md5(serialize(compact('params''siteType''webName')));
  12.         //
  13.         return $this->getCacheByKey($cacheKey, function () use ($params$siteType$webName){
  14.             //
  15.             log_info("[HOGE] (*'o')");
  16.             //
  17.             $result = [];
  18.             //
  19.             switch ($params['type']) {
  20.                 case 'item':
  21.                     $goodsId $params['value'];
  22.                     $itemMcWebNames = (array)(new SqlService())
  23.                         ->Table('goods_category_table')
  24.                         ->Select('T2.main_category_webname')
  25.                         ->Join('category_table''T1.category_id = T.gc_category''INNER')
  26.                         ->Join('main_category_table''T2.main_category_id = T1.category_main_category''INNER')
  27.                         ->Set('gc_goods'$goodsId)
  28.                         ->Set('T2.main_category_has_main_categories'1)
  29.                         ->Set('T2.main_category_status'1)
  30.                         ->OrderBy('char_length(T2.main_category_webname) DESC')
  31.                         ->FindAll();
  32.                     foreach ($itemMcWebNames as $itemMcWebName) {
  33.                         $itemFbnr $this->getFbnrByCategoryWebName($siteType$itemMcWebName['main_category_webname']);
  34.                         $result[] = $itemFbnr;
  35.                     }
  36.                     break;
  37.                 case 'main-category':
  38.                 case 'category':
  39.                     $itemFbnr $this->getFbnrByCategoryWebName($siteType$webName);
  40.                     $result[] = $itemFbnr;
  41.                     $main_category_webname addslashes(stripslashes($webName));
  42.                     $mcHasMainCategoryData = (new SqlService())
  43.                         ->Table("main_category_table")
  44.                         ->Select('*')
  45.                         ->Set('main_category_webname'$main_category_webname)
  46.                         ->Set('main_category_status'1)
  47.                         ->Set('main_category_main_category''NOT NULL')
  48.                         ->Find();
  49.                     $itemFbnr $this->getFbnrByCategoryWebName($siteType$mcHasMainCategoryData['main_category_main_category_webname'] ?? null);
  50.                     $result[] = $itemFbnr;
  51.                     break;
  52.                 default:
  53.                     break;
  54.             }
  55.             //
  56.             $sql = (new SqlService())
  57.                 ->Table('floating_banner_table')
  58.                 ->Select('fbnr_content, fbnr_content2')
  59.                 ->Set('fbnr_site_type'$siteType);
  60.             $result[] = $sql->Find();
  61.             //
  62.             return $result;
  63.         });
  64.     }
  65.     public function getFbnrByCategoryWebName($siteType$webName) {
  66.         $itemFbnr null;
  67.         if ($webName) {
  68.             $itemFbnr = (new SqlService())
  69.                 ->Select('fbnr_content, fbnr_content2, T1.main_category_main_category, T1.main_category_main_category_webname')
  70.                 ->Table('floating_banner_table')
  71.                 ->Join('main_category_table''T1.main_category_id = T.target_category''INNER')
  72.                 ->Set('fbnr_site_type'$siteType)
  73.                 ->Set('T1.main_category_has_main_categories'1)
  74.                 ->Set('T1.main_category_webname'$webName)
  75.                 ->Find();
  76.         } else {
  77.             $itemFbnr = (new SqlService())
  78.                 ->Select('fbnr_content, fbnr_content2, T1.main_category_main_category, T1.main_category_main_category_webname')
  79.                 ->Table('floating_banner_table')
  80.                 ->Join('main_category_table''T1.main_category_id = T.target_category''INNER')
  81.                 ->Set('fbnr_site_type'$siteType)
  82.                 ->Set('T1.main_category_has_main_categories'1)
  83.                 ->Set('T1.main_category_webname'$webName)
  84.                 ->Find();
  85.         }
  86.         return $itemFbnr;
  87.     }
  88. }