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

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.      * @return array|null
  244.      */
  245.     public function findShiiresaki()
  246.     {
  247.         //
  248.         $shiiresakiId $this->getGoodsShiiresaki();
  249.         //
  250.         $result = (new SqlService())
  251.             ->Table(Shiiresaki::TABLE_NAME)
  252.             ->Set('shiiresaki_id'$shiiresakiId)
  253.             ->Find()
  254.         ;
  255.         //
  256.         return $result;
  257.     }
  258.     /**
  259.      * @return int
  260.      */
  261.     public function getGoodsId()
  262.     {
  263.         return self::intNullable($this->goodsId);
  264.     }
  265.     /**
  266.      * @return string
  267.      */
  268.     public function getgoodsCanonicalHinban()
  269.     {
  270.         return $this->goodsCanonicalHinban;
  271.     }
  272.     /**
  273.      * @return string
  274.      */
  275.     public function getGoodsName()
  276.     {
  277.         return $this->goodsName;
  278.     }
  279.     /**
  280.      * @return string
  281.      */
  282.     public function getGoodsMakerNameText()
  283.     {
  284.         return $this->goodsMakerNameText;
  285.     }
  286.     /**
  287.      * @return string
  288.      */
  289.     public function getGoodsGenreText()
  290.     {
  291.         return $this->goodsGenreText;
  292.     }
  293.     /**
  294.      * @return string
  295.      */
  296.     public function getGoodsNewDescription()
  297.     {
  298.         return $this->goodsNewDescription;
  299.     }
  300.     /**
  301.      * @return string
  302.      */
  303.     public function getGoodsNewName()
  304.     {
  305.         return $this->goodsNewName;
  306.     }
  307.     /**
  308.      * @return string
  309.      */
  310.     public function getGoodsNewMaker()
  311.     {
  312.         return $this->goodsNewMaker;
  313.     }
  314.     /**
  315.      * @return string
  316.      */
  317.     public function getGoodsNewMaterial()
  318.     {
  319.         return $this->goodsNewMaterial;
  320.     }
  321.     /**
  322.      * @return string
  323.      */
  324.     public function getGoodsNewSpec()
  325.     {
  326.         return $this->goodsNewSpec;
  327.     }
  328.     /**
  329.      * @return string
  330.      */
  331.     public function getGoodsNewAnnotation()
  332.     {
  333.         return $this->goodsNewAnnotation;
  334.     }
  335.     /**
  336.      * @return string
  337.      */
  338.     public function getGoodsMainKataban()
  339.     {
  340.         return $this->goodsMainKataban;
  341.     }
  342.     /**
  343.      * @return int
  344.      */
  345.     public function getGoodsRecommend()
  346.     {
  347.         return $this->goodsRecommend;
  348.     }
  349.     /**
  350.      * @return int
  351.      */
  352.     public function getGoodsShiiresaki()
  353.     {
  354.         return self::intNullable($this->goodsShiiresaki);
  355.     }
  356.     /**
  357.      * @return int
  358.      */
  359.     public function getGoodsStatus()
  360.     {
  361.         return self::intNullable($this->goodsStatus);
  362.     }
  363.     /**
  364.      * @return string
  365.      */
  366.     public function getGoodsDdate()
  367.     {
  368.         return $this->goodsDdate;
  369.     }
  370.     /**
  371.      * @return int
  372.      */
  373.     public function getGoodsSampleRental()
  374.     {
  375.         return (int)$this->goodsSampleRental;
  376.     }
  377.     /**
  378.      * @return int
  379.      */
  380.     public function getGoodsNairePrint()
  381.     {
  382.         return (int)$this->goodsNairePrint;
  383.     }
  384.     /**
  385.      * @return int
  386.      */
  387.     public function getGoodsSusoage()
  388.     {
  389.         return (int)$this->goodsSusoage;
  390.     }
  391.     /**
  392.      * @return int
  393.      */
  394.     public function getGoodsOnetimeRepeat()
  395.     {
  396.         return (int)$this->goodsOnetimeRepeat;
  397.     }
  398.     /**
  399.      * @return int
  400.      */
  401.     public function getGoodsSetPurchaseFlg()
  402.     {
  403.         return (int)$this->goodsSetPurchaseFlg;
  404.     }
  405.     /**
  406.      * @return int
  407.      */
  408.     public function getGoodsTargetGender()
  409.     {
  410.         return (int)$this->goodsTargetGender;
  411.     }
  412.     /**
  413.      * @return int
  414.      */
  415.     public function getGoodsCategoryListIconId()
  416.     {
  417.         return (int)$this->goodsCategoryListIconId;
  418.     }
  419.     /**
  420.      * @return int
  421.      */
  422.     public function getGoodsVendingStatus()
  423.     {
  424.         return (int)$this->goodsVendingStatus;
  425.     }
  426.     /**
  427.      * @return Shiiresaki
  428.      * @throws \Exception
  429.      */
  430.     public function getShiiresaki()
  431.     {
  432.         //
  433.         if (empty($this->shiiresaki)) {
  434.             //
  435.             $shiiresaki $this->findShiiresaki();
  436.             //
  437.             $this->shiiresaki = new Shiiresaki($shiiresaki);
  438.         }
  439.         return $this->shiiresaki;
  440.     }
  441.     /**
  442.      * @return GoodsPrice[]
  443.      * @throws \Exception
  444.      */
  445.     public function getGoodsPriceList()
  446.     {
  447.         return self::compute($this->goodsPriceList, function () {
  448.             return GoodsPrice::findByGoodsId($this->getGoodsId());
  449.         });
  450.     }
  451.     /**
  452.      * @return GoodsColor[]
  453.      * @throws \Exception
  454.      */
  455.     public function getGoodsColorList()
  456.     {
  457.         return self::compute($this->goodsColorList, function () {
  458.             return GoodsColor::findByGoodsId($this->getGoodsId());
  459.         });
  460.     }
  461.     /**
  462.      * @var Jancode[]
  463.      */
  464.     protected $jancodeList;
  465.     /**
  466.      * @return Jancode[]
  467.      */
  468.     public function getJancodeList()
  469.     {
  470.         return self::compute($this->jancodeList, function () {
  471.             return Jancode::findByGoodsId($this->getGoodsId());
  472.         });
  473.     }
  474.     /**
  475.      * @return bool
  476.      */
  477.     public function hasReturnUnavailableSku()
  478.     {
  479.         foreach ($this->getJancodeList() as $jancode) {
  480.             if ($jancode->isReturnUnavailable()) {
  481.                 return true;
  482.             }
  483.         }
  484.         return false;
  485.     }
  486. }