| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace addons\Xhs\common\models;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "qimall_addons_xhs_goods_visit".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $user_id 用户ID
- * @property int $content_id 内容 id
- * @property int $goods_id 商品 id
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- */
- class AddonsXhsGoodsVisit extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_xhs_goods_visit}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'content_id', 'goods_id'], 'required'],
- [['mall_id', 'user_id', 'content_id', 'goods_id', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'user_id' => '用户ID',
- 'content_id' => '内容 id',
- 'goods_id' => '商品 id',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- /**
- * 保存数据
- * @Author: ltm
- * @DateTime: 2021/12/13 0022 17:13
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param array $params
- * @return AddonsMaterial|bool
- */
- public static function setData(array $params){
- try{
- if (!empty($params['id'])) {
- $model = self::findOne(['and',['id'=>$params['id'],'mall_id'=>$params['mall_id']]]);
- if (empty($model)) throw new Exception('记录不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $params['mall_id'];
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new Exception($model->getErrorMessage());
- }
- return $model;
- }catch(\Exception $e){
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|