'ID', 'mall_id' => '商城ID', 'goods_id' => 'Goods ID', 'template_id' => '模板ID[qimall_goods_decoration_template主键]', 'status' => '状态【1启用 0禁用 -1删除】', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } public function getTemplate() { return $this->hasOne(GoodsDecorationTemplate::class, ['id' => 'template_id']); } /** * 保存数据 * @Author bing * @DateTime 2021-08-26 14:16:24 * @copyright: Copyright (c) 2020 广东七件事集团 * @param array $params * @return object|boolean */ public static function setData(array $params) { try { $model = self::findOne(['goods_id' => $params['goods_id'], 'mall_id' => $params['mall_id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if(empty($model)){ $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; } } }