<?php
namespace Lm\Entity;
use Lm\Entity\Common\DbEntity;
use Lm\Service\Db\SqlService;
class Goods extends DbEntity
{
/**
* @inheritDoc
*/
const TABLE_NAME = 'goods_table';
/**
* @inheritDoc
*/
const COLUMNS = [
[
'name' => 'goods_id',
'type' => DbEntity::COLUMN_TYPE_INT, // { required: true }
'nullable' => false, // { required: false, default: true }
'default' => null, // { required: false, default: null }
'required' => true, // { required: false, default: true }
],
];
/**
* @inheritDoc
*/
const CONSTRAINTS = [
[
'type' => self::CONSTRAINT_TYPE_PRIMARY_KEY,
'columns' => [
'goods_id',
],
],
];
/**
* 商品ID - 42097: カタログ請求
*/
const GOODS_ID_CATALOG = 42097;
/**
* 商品ステータス - 表示
*/
const GOODS_STATUS_AVAIABLE = 1;
/**
* 商品ステータス - 非表示
*/
const GOODS_STATUS_UNAVAIABLE = 0;
/**
* 社内在庫品 - はい
*/
const GOODS_RECOMMEND_YES = 1;
/**
* 社内在庫品 - いいえ
*/
const GOODS_RECOMMEND_NO = 0;
/**
* サンプル貸出可否 - 可
*/
const GOODS_SAMPLE_RENTAL_AVAILABLE = 1;
/**
* サンプル貸出可否 - 不可
*/
const GOODS_SAMPLE_RENTAL_UNAVAILABLE = 0;
/**
* 名入れ/プリント可否 - 可
*/
const GOODS_NAIRE_PRINT_AVAILABLE = 1;
/**
* 裾上げ可否 - 可
*/
const GOODS_SUSOAGE_AVAILABLE = 1;
/**
* セット品番 - はい
*/
const GOODS_SET_PURCHASE_FLG_YES = 1;
/**
* セット品番 - いいえ
*/
const GOODS_SET_PURCHASE_FLG_NO = 0;
/**
* 性別表記 - 未指定
*/
const TARGET_GENDER_UNDEFINED = 0;
/**
* 性別表記 - 男性用
*/
const TARGET_GENDER_MEN = 1;
/**
* 性別表記 - 女性用
*/
const TARGET_GENDER_WOMEN = 2;
/**
* 性別表記 - 男女兼用
*/
const TARGET_GENDER_UNISEX = 3;
/**
* 性別表記 - 子供用
*/
const TARGET_GENDER_KIDS = 4;
/**
* カテゴリ商品リストアイコンID: アイコンなし
*/
const CATEGORY_LIST_ICON_NO_SHOW = 0;
/**
* カテゴリ商品リストアイコンID: 春夏
*/
const CATEGORY_LIST_ICON_SS = 1;
/**
* カテゴリ商品リストアイコンID: 秋冬
*/
const CATEGORY_LIST_ICON_AW = 2;
/**
* カテゴリ商品リストアイコンID: 通年
*/
const CATEGORY_LIST_ICON_ALL = 3;
/**
* カテゴリ商品リストアイコンID: 防寒
*/
const CATEGORY_LIST_ICON_BOUKAN = 4;
/**
* 販売状況フラグ: 販売中
*/
const VENDING_STATUS_VENDING = 1;
/**
* 販売状況フラグ: 完売
*/
const VENDING_STATUS_SOLD_OUT = 2;
/**
* 販売状況フラグ: 廃番
*/
const VENDING_STATUS_DISCONTINUED = 3;
/**
* @var int
*/
protected $goodsId;
/**
* @var string
*/
protected $goodsCanonicalHinban;
/**
* @var string
*/
protected $goodsName;
/**
* @var string
*/
protected $goodsMakerNameText;
/**
* @var string
*/
protected $goodsGenreText;
/**
* @var string
*/
protected $goodsNewDescription;
/**
* @var string
*/
protected $goodsNewName;
/**
* @var string
*/
protected $goodsNewMaker;
/**
* @var string
*/
protected $goodsNewMaterial;
/**
* @var string
*/
protected $goodsNewSpec;
/**
* @var string
*/
protected $goodsNewAnnotation;
/**
* @var string
*/
protected $goodsMainKataban;
/**
* @var int
*/
protected $goodsRecommend = self::GOODS_RECOMMEND_NO;
/**
* @var int
*/
protected $goodsShiiresaki;
/**
* @var int
*/
protected $goodsStatus;
/**
* @var string
*/
protected $goodsDdate;
/**
* @var int
*/
protected $goodsSampleRental;
/**
* @var int
*/
protected $goodsNairePrint;
/**
* @var int
*/
protected $goodsSusoage;
/**
* @var int
*/
protected $goodsOnetimeRepeat;
/**
* @var int
*/
protected $goodsSetPurchaseFlg;
/**
* @var int
*/
protected $goodsTargetGender = self::TARGET_GENDER_UNDEFINED;
/**
* @var int
*/
protected $goodsCategoryListIconId = self::CATEGORY_LIST_ICON_NO_SHOW;
/**
* @var int
*/
protected $goodsVendingStatus = self::VENDING_STATUS_VENDING;
/**
* @var Shiiresaki
*/
protected $shiiresaki;
/**
* @var GoodsPrice[]
*/
protected $goodsPriceList;
/**
* @var GoodsColor[]
*/
protected $goodsColorList;
/**
* @return array|null
*/
public function findShiiresaki()
{
//
$shiiresakiId = $this->getGoodsShiiresaki();
//
$result = (new SqlService())
->Table(Shiiresaki::TABLE_NAME)
->Set('shiiresaki_id', $shiiresakiId)
->Find()
;
//
return $result;
}
/**
* @return int
*/
public function getGoodsId()
{
return self::intNullable($this->goodsId);
}
/**
* @return string
*/
public function getgoodsCanonicalHinban()
{
return $this->goodsCanonicalHinban;
}
/**
* @return string
*/
public function getGoodsName()
{
return $this->goodsName;
}
/**
* @return string
*/
public function getGoodsMakerNameText()
{
return $this->goodsMakerNameText;
}
/**
* @return string
*/
public function getGoodsGenreText()
{
return $this->goodsGenreText;
}
/**
* @return string
*/
public function getGoodsNewDescription()
{
return $this->goodsNewDescription;
}
/**
* @return string
*/
public function getGoodsNewName()
{
return $this->goodsNewName;
}
/**
* @return string
*/
public function getGoodsNewMaker()
{
return $this->goodsNewMaker;
}
/**
* @return string
*/
public function getGoodsNewMaterial()
{
return $this->goodsNewMaterial;
}
/**
* @return string
*/
public function getGoodsNewSpec()
{
return $this->goodsNewSpec;
}
/**
* @return string
*/
public function getGoodsNewAnnotation()
{
return $this->goodsNewAnnotation;
}
/**
* @return string
*/
public function getGoodsMainKataban()
{
return $this->goodsMainKataban;
}
/**
* @return int
*/
public function getGoodsRecommend()
{
return $this->goodsRecommend;
}
/**
* @return int
*/
public function getGoodsShiiresaki()
{
return self::intNullable($this->goodsShiiresaki);
}
/**
* @return int
*/
public function getGoodsStatus()
{
return self::intNullable($this->goodsStatus);
}
/**
* @return string
*/
public function getGoodsDdate()
{
return $this->goodsDdate;
}
/**
* @return int
*/
public function getGoodsSampleRental()
{
return (int)$this->goodsSampleRental;
}
/**
* @return int
*/
public function getGoodsNairePrint()
{
return (int)$this->goodsNairePrint;
}
/**
* @return int
*/
public function getGoodsSusoage()
{
return (int)$this->goodsSusoage;
}
/**
* @return int
*/
public function getGoodsOnetimeRepeat()
{
return (int)$this->goodsOnetimeRepeat;
}
/**
* @return int
*/
public function getGoodsSetPurchaseFlg()
{
return (int)$this->goodsSetPurchaseFlg;
}
/**
* @return int
*/
public function getGoodsTargetGender()
{
return (int)$this->goodsTargetGender;
}
/**
* @return int
*/
public function getGoodsCategoryListIconId()
{
return (int)$this->goodsCategoryListIconId;
}
/**
* @return int
*/
public function getGoodsVendingStatus()
{
return (int)$this->goodsVendingStatus;
}
/**
* @return Shiiresaki
* @throws \Exception
*/
public function getShiiresaki()
{
//
if (empty($this->shiiresaki)) {
//
$shiiresaki = $this->findShiiresaki();
//
$this->shiiresaki = new Shiiresaki($shiiresaki);
}
return $this->shiiresaki;
}
/**
* @return GoodsPrice[]
* @throws \Exception
*/
public function getGoodsPriceList()
{
return self::compute($this->goodsPriceList, function () {
return GoodsPrice::findByGoodsId($this->getGoodsId());
});
}
/**
* @return GoodsColor[]
* @throws \Exception
*/
public function getGoodsColorList()
{
return self::compute($this->goodsColorList, function () {
return GoodsColor::findByGoodsId($this->getGoodsId());
});
}
}