| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace addons\QiJuhe\common\models;
- use Yii;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%addons_qijuhe_goods_attr}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $supply_id 中台ID
- * @property int $sku_id 商品线上SKU
- * @property int $goods_id 商品表商品ID
- * @property int $supply_goods_id 中台商品表ID
- * @property int $attr_id 商品属性表ID
- * @property int $is_delete
- */
- class GoodsSkuModel extends ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_qijuhe_goods_attr}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'sku_id', 'goods_id', 'attr_id'], 'required'],
- [['mall_id', 'supply_id', 'sku_id', 'goods_id', 'supply_goods_id', 'attr_id', 'is_delete'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'supply_id' => 'Supply ID',
- 'sku_id' => 'Sku ID',
- 'goods_id' => 'Goods ID',
- 'supply_goods_id' => 'Supply Goods ID',
- 'attr_id' => 'Attr ID',
- 'is_delete' => 'Is Delete',
- ];
- }
- /**
- * 获取一个SKUID
- *
- * @param integer $goods_id
- * @param integer $attr_id
- * @return integer
- */
- public static function getSkuId($goods_id, $attr_id)
- {
- return self::find()
- ->where(['goods_id' => $goods_id, 'attr_id' => $attr_id])
- ->select('sku_id')
- ->scalar();
- }
- /**
- * 获取一个SKUID
- *
- * @param integer $goods_id
- * @param integer $attr_id
- * @return GoodsSkuModel
- */
- public static function getSku($goods_id, $attr_id, $field = null)
- {
- $model = self::find();
- $field && $model->select($field);
-
- return $model->where(['goods_id' => $goods_id, 'attr_id' => $attr_id])
- ->one();
- }
- /**
- * 查询
- *
- * @param integer $mall_id
- * @return array
- */
- public static function getImportedGoodsIds(int $mall_id)
- {
- return StorageModel::find()
- ->where(['mall_id' => $mall_id, 'is_import' => 2])
- ->select(['id', 'middle_goods_id'])
- ->all();
- }
- }
|