'ID', 'mall_id' => '商城ID', 'goods_id' => '商品id', 'content' => '独立配置详情', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @Author: lun * @DateTime: 2021/10/29 0029 17:31 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $params * @return bool */ public static function setData($params) { try{ if (!empty($params['goods_id'])) { $model = self::findOne(['goods_id' => $params['goods_id'], 'mall_id' => $params['mall_id'], 'status' => [StatusEnum::ENABLED]]); if (empty($model)) { $model = new self(); $model->mall_id = $params['mall_id']; $model->goods_id = $params['goods_id']; $model->content = $params['content']; $model->loadDefaultValues(); } } else { throw new \Exception('商品ID不能为空'); } if(!$model->load($params,'') || !$model->save()){ throw new \Exception($model->getErrorMessage()); } return true; }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } }