vendor/lm/entity/src/Goods.php line 445

Open in your IDE?
  1. <?php
  2. namespace Lm\Entity;
  3. use Lm\Entity\Common\DbEntity;
  4. use Lm\Service\Db\SqlService;
  5. class Goods extends DbEntity
  6. {
  7.     /**
  8.      * @inheritDoc
  9.      */
  10.     const TABLE_NAME 'goods_table';
  11.     /**
  12.      * @inheritDoc
  13.      */
  14.     const COLUMNS = [
  15.         [
  16.             'name' => 'goods_id',
  17.             'type' => DbEntity::COLUMN_TYPE_INT,    // { required: true }
  18.             'nullable' => false,        // { required: false, default: true }
  19.             'default' => null,            // { required: false, default: null }
  20.             'required' => true,            // { required: false, default: true }
  21.         ],
  22.     ];
  23.     /**
  24.      * @inheritDoc
  25.      */
  26.     const CONSTRAINTS = [
  27.         [
  28.             'type' => self::CONSTRAINT_TYPE_PRIMARY_KEY,
  29.             'columns' => [
  30.                 'goods_id',
  31.             ],
  32.         ],
  33.     ];
  34.     /**
  35.      * 商品ID - 42097: カタログ請求
  36.      */
  37.     const GOODS_ID_CATALOG 42097;
  38.     /**
  39.      * 商品ステータス - 表示
  40.      */
  41.     const GOODS_STATUS_AVAIABLE 1;
  42.     /**
  43.      * 商品ステータス - 非表示
  44.      */
  45.     const GOODS_STATUS_UNAVAIABLE 0;
  46.     /**
  47.      * 社内在庫品 - はい
  48.      */
  49.     const GOODS_RECOMMEND_YES 1;
  50.     /**
  51.      * 社内在庫品 - いいえ
  52.      */
  53.     const GOODS_RECOMMEND_NO 0;
  54.     /**
  55.      * サンプル貸出可否 - 可
  56.      */
  57.     const GOODS_SAMPLE_RENTAL_AVAILABLE 1;
  58.     /**
  59.      * サンプル貸出可否 - 不可
  60.      */
  61.     const GOODS_SAMPLE_RENTAL_UNAVAILABLE 0;
  62.     /**
  63.      * 名入れ/プリント可否 - 可
  64.      */
  65.     const GOODS_NAIRE_PRINT_AVAILABLE 1;
  66.     /**
  67.      * 裾上げ可否 - 可
  68.      */
  69.     const GOODS_SUSOAGE_AVAILABLE 1;
  70.     /**
  71.      * セット品番 - はい
  72.      */
  73.     const GOODS_SET_PURCHASE_FLG_YES 1;
  74.     /**
  75.      * セット品番 - いいえ
  76.      */
  77.     const GOODS_SET_PURCHASE_FLG_NO 0;
  78.     /**
  79.      * 性別表記 - 未指定
  80.      */
  81.     const TARGET_GENDER_UNDEFINED 0;
  82.     /**
  83.      * 性別表記 - 男性用
  84.      */
  85.     const TARGET_GENDER_MEN 1;
  86.     /**
  87.      * 性別表記 - 女性用
  88.      */
  89.     const TARGET_GENDER_WOMEN 2;
  90.     /**
  91.      * 性別表記 - 男女兼用
  92.      */
  93.     const TARGET_GENDER_UNISEX 3;
  94.     /**
  95.      * 性別表記 - 子供用
  96.      */
  97.     const TARGET_GENDER_KIDS 4;
  98.     /**
  99.      * カテゴリ商品リストアイコンID: アイコンなし
  100.      */
  101.     const CATEGORY_LIST_ICON_NO_SHOW 0;
  102.     /**
  103.      * カテゴリ商品リストアイコンID: 春夏
  104.      */
  105.     const CATEGORY_LIST_ICON_SS 1;
  106.     /**
  107.      * カテゴリ商品リストアイコンID: 秋冬
  108.      */
  109.     const CATEGORY_LIST_ICON_AW 2;
  110.     /**
  111.      * カテゴリ商品リストアイコンID: 通年
  112.      */
  113.     const CATEGORY_LIST_ICON_ALL 3;
  114.     /**
  115.      * カテゴリ商品リストアイコンID: 防寒
  116.      */
  117.     const CATEGORY_LIST_ICON_BOUKAN 4;
  118.     /**
  119.      * 販売状況フラグ: 販売中
  120.      */
  121.     const VENDING_STATUS_VENDING 1;
  122.     /**
  123.      * 販売状況フラグ: 完売
  124.      */
  125.     const VENDING_STATUS_SOLD_OUT 2;
  126.     /**
  127.      * 販売状況フラグ: 廃番
  128.      */
  129.     const VENDING_STATUS_DISCONTINUED 3;
  130.     /**
  131.      * 販売状況フラグ: メーカー在庫連携除外(バートルのみ対応)
  132.      */
  133.     const VENDING_STATUS_EXCLUDE_MANUFACTURER_STOCK 4;
  134.     /**
  135.      * @var int
  136.      */
  137.     protected $goodsId;
  138.     /**
  139.      * @var string
  140.      */
  141.     protected $goodsCanonicalHinban;
  142.     /**
  143.      * @var string
  144.      */
  145.     protected $goodsName;
  146.     /**
  147.      * @var string
  148.      */
  149.     protected $goodsMakerNameText;
  150.     /**
  151.      * @var string
  152.      */
  153.     protected $goodsGenreText;
  154.     /**
  155.      * @var string
  156.      */
  157.     protected $goodsNewDescription;
  158.     /**
  159.      * @var string
  160.      */
  161.     protected $goodsNewName;
  162.     /**
  163.      * @var string
  164.      */
  165.     protected $goodsNewMaker;
  166.     /**
  167.      * @var string
  168.      */
  169.     protected $goodsNewMaterial;
  170.     /**
  171.      * @var string
  172.      */
  173.     protected $goodsNewSpec;
  174.     /**
  175.      * @var string
  176.      */
  177.     protected $goodsNewAnnotation;
  178.     /**
  179.      * @var string
  180.      */
  181.     protected $goodsMainKataban;
  182.     /**
  183.      * @var int
  184.      */
  185.     protected $goodsRecommend self::GOODS_RECOMMEND_NO;
  186.     /**
  187.      * @var int
  188.      */
  189.     protected $goodsShiiresaki;
  190.     /**
  191.      * @var int
  192.      */
  193.     protected $goodsStatus;
  194.     /**
  195.      * @var string
  196.      */
  197.     protected $goodsDdate;
  198.     /**
  199.      * @var int
  200.      */
  201.     protected $goodsSampleRental;
  202.     /**
  203.      * @var int
  204.      */
  205.     protected $goodsNairePrint;
  206.     /**
  207.      * @var int
  208.      */
  209.     protected $goodsSusoage;
  210.     /**
  211.      * @var int
  212.      */
  213.     protected $goodsOnetimeRepeat;
  214.     /**
  215.      * @var int
  216.      */
  217.     protected $goodsSetPurchaseFlg;
  218.     /**
  219.      * @var int
  220.      */
  221.     protected $goodsTargetGender self::TARGET_GENDER_UNDEFINED;
  222.     /**
  223.      * @var int
  224.      */
  225.     protected $goodsCategoryListIconId self::CATEGORY_LIST_ICON_NO_SHOW;
  226.     /**
  227.      * @var int
  228.      */
  229.     protected $goodsVendingStatus self::VENDING_STATUS_VENDING;
  230.     /**
  231.      * @var Shiiresaki
  232.      */
  233.     protected $shiiresaki;
  234.     /**
  235.      * @var GoodsPrice[]
  236.      */
  237.     protected $goodsPriceList;
  238.     /**
  239.      * @var GoodsColor[]
  240.      */
  241.     protected $goodsColorList;
  242.     /**
  243.      * よりどりみどり割 対象フラグ
  244.      * @var int
  245.      */
  246.     protected $campaignYoridori;
  247.     /**
  248.      * まとめ割 対象フラグ
  249.      * @var int
  250.      */
  251.     protected $campaignMatome;
  252.     /**
  253.      * @return array|null
  254.      */
  255.     public function findShiiresaki()
  256.     {
  257.         //
  258.         $shiiresakiId $this->getGoodsShiiresaki();
  259.         //
  260.         $result = (new SqlService())
  261.             ->Table(Shiiresaki::TABLE_NAME)
  262.             ->Set('shiiresaki_id'$shiiresakiId)
  263.             ->Find()
  264.         ;
  265.         //
  266.         return $result;
  267.     }
  268.     /**
  269.      * @return int
  270.      */
  271.     public function getGoodsId()
  272.     {
  273.         return self::intNullable($this->goodsId);
  274.     }
  275.     /**
  276.      * @return string
  277.      */
  278.     public function getgoodsCanonicalHinban()
  279.     {
  280.         return $this->goodsCanonicalHinban;
  281.     }
  282.     /**
  283.      * @return string
  284.      */
  285.     public function getGoodsName()
  286.     {
  287.         return $this->goodsName;
  288.     }
  289.     /**
  290.      * @return string
  291.      */
  292.     public function getGoodsMakerNameText()
  293.     {
  294.         return $this->goodsMakerNameText;
  295.     }
  296.     /**
  297.      * @return string
  298.      */
  299.     public function getGoodsGenreText()
  300.     {
  301.         return $this->goodsGenreText;
  302.     }
  303.     /**
  304.      * @return string
  305.      */
  306.     public function getGoodsNewDescription()
  307.     {
  308.         return $this->goodsNewDescription;
  309.     }
  310.     /**
  311.      * @return string
  312.      */
  313.     public function getGoodsNewName()
  314.     {
  315.         return $this->goodsNewName;
  316.     }
  317.     /**
  318.      * @return string
  319.      */
  320.     public function getGoodsNewMaker()
  321.     {
  322.         return $this->goodsNewMaker;
  323.     }
  324.     /**
  325.      * @return string
  326.      */
  327.     public function getGoodsNewMaterial()
  328.     {
  329.         return $this->goodsNewMaterial;
  330.     }
  331.     /**
  332.      * @return string
  333.      */
  334.     public function getGoodsNewSpec()
  335.     {
  336.         return $this->goodsNewSpec;
  337.     }
  338.     /**
  339.      * @return string
  340.      */
  341.     public function getGoodsNewAnnotation()
  342.     {
  343.         return $this->goodsNewAnnotation;
  344.     }
  345.     /**
  346.      * @return string
  347.      */
  348.     public function getGoodsMainKataban()
  349.     {
  350.         return $this->goodsMainKataban;
  351.     }
  352.     /**
  353.      * @return int
  354.      */
  355.     public function getGoodsRecommend()
  356.     {
  357.         return $this->goodsRecommend;
  358.     }
  359.     /**
  360.      * @return int
  361.      */
  362.     public function getGoodsShiiresaki()
  363.     {
  364.         return self::intNullable($this->goodsShiiresaki);
  365.     }
  366.     /**
  367.      * @return int
  368.      */
  369.     public function getGoodsStatus()
  370.     {
  371.         return self::intNullable($this->goodsStatus);
  372.     }
  373.     /**
  374.      * @return string
  375.      */
  376.     public function getGoodsDdate()
  377.     {
  378.         return $this->goodsDdate;
  379.     }
  380.     /**
  381.      * @return int
  382.      */
  383.     public function getGoodsSampleRental()
  384.     {
  385.         return (int)$this->goodsSampleRental;
  386.     }
  387.     /**
  388.      * @return int
  389.      */
  390.     public function getGoodsNairePrint()
  391.     {
  392.         return (int)$this->goodsNairePrint;
  393.     }
  394.     /**
  395.      * @return int
  396.      */
  397.     public function getGoodsSusoage()
  398.     {
  399.         return (int)$this->goodsSusoage;
  400.     }
  401.     /**
  402.      * @return int
  403.      */
  404.     public function getGoodsOnetimeRepeat()
  405.     {
  406.         return (int)$this->goodsOnetimeRepeat;
  407.     }
  408.     /**
  409.      * @return int
  410.      */
  411.     public function getGoodsSetPurchaseFlg()
  412.     {
  413.         return (int)$this->goodsSetPurchaseFlg;
  414.     }
  415.     /**
  416.      * @return int
  417.      */
  418.     public function getGoodsTargetGender()
  419.     {
  420.         return (int)$this->goodsTargetGender;
  421.     }
  422.     /**
  423.      * @return int
  424.      */
  425.     public function getGoodsCategoryListIconId()
  426.     {
  427.         return (int)$this->goodsCategoryListIconId;
  428.     }
  429.     /**
  430.      * @return int
  431.      */
  432.     public function getGoodsVendingStatus()
  433.     {
  434.         return (int)$this->goodsVendingStatus;
  435.     }
  436.     /**
  437.      * @return Shiiresaki
  438.      * @throws \Exception
  439.      */
  440.     public function getShiiresaki()
  441.     {
  442.         //
  443.         if (empty($this->shiiresaki)) {
  444.             //
  445.             $shiiresaki $this->findShiiresaki();
  446.             //
  447.             $this->shiiresaki = new Shiiresaki($shiiresaki);
  448.         }
  449.         return $this->shiiresaki;
  450.     }
  451.     /**
  452.      * @return GoodsPrice[]
  453.      * @throws \Exception
  454.      */
  455.     public function getGoodsPriceList()
  456.     {
  457.         return self::compute($this->goodsPriceList, function () {
  458.             return GoodsPrice::findByGoodsId($this->getGoodsId());
  459.         });
  460.     }
  461.     /**
  462.      * @return GoodsColor[]
  463.      * @throws \Exception
  464.      */
  465.     public function getGoodsColorList()
  466.     {
  467.         return self::compute($this->goodsColorList, function () {
  468.             return GoodsColor::findByGoodsId($this->getGoodsId());
  469.         });
  470.     }
  471.     /**
  472.      * @var Jancode[]
  473.      */
  474.     protected $jancodeList;
  475.     /**
  476.      * @return Jancode[]
  477.      */
  478.     public function getJancodeList()
  479.     {
  480.         return self::compute($this->jancodeList, function () {
  481.             return Jancode::findByGoodsId($this->getGoodsId());
  482.         });
  483.     }
  484.     /**
  485.      * よりどりみどり割 対象か
  486.      * @return int
  487.      */
  488.     public function getCampaignYoridori()
  489.     {
  490.         return (int)$this->campaignYoridori;
  491.     }
  492.     /**
  493.      * まとめ割 対象か
  494.      * @return int
  495.      */
  496.     public function getCampaignMatome()
  497.     {
  498.         return (int)$this->campaignMatome;
  499.     }
  500.     /**
  501.      * @return bool
  502.      */
  503.     public function hasReturnUnavailableSku()
  504.     {
  505.         foreach ($this->getJancodeList() as $jancode) {
  506.             if ($jancode->isReturnUnavailable()) {
  507.                 return true;
  508.             }
  509.         }
  510.         return false;
  511.     }
  512. }