| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace addons\Happiness\common\models;
- use common\enums\StatusEnum;
- use common\models\goods\Goods;
- use common\models\goods\GoodsAttr;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_happiness_move_goods".
- *
- * @property int $id
- * @property int $goods_id 商品ID
- * @property int $move_id 调货单ID
- * @property int $attr_id 规格ID
- * @property int $num 调货数量
- * @property int $mall_id 商城ID
- * @property int $created_at
- * @property int $updated_at
- * @property int $status
- */
- class HappinessMoveGoods extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_happiness_move_goods';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['goods_id', 'move_id', 'attr_id', 'num', 'mall_id', 'created_at', 'updated_at', 'status'], 'integer'],
- [['total_price'], 'number']
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'goods_id' => 'Goods ID',
- 'move_id' => 'Move ID',
- 'attr_id' => 'Attr ID',
- 'num' => 'Num',
- 'total_price' => 'Total Price',
- 'mall_id' => 'Mall ID',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'status' => 'Status',
- ];
- }
- public function getAttr()
- {
- return $this->hasOne(GoodsAttr::class, ['id' => 'attr_id']);
- }
- public function getGoods()
- {
- return $this->hasOne(Goods::class, ['id' => 'goods_id']);
- }
- public static function setData($params)
- {
- try {
- if(isset($params['id']) && !empty($params['id']))
- $model = self::findOne($params['id']);
- else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|