'ID', 'mall_id' => 'Mall ID', 'store_id' => 'Store ID', 'goods_id' => '商品id', 'content' => '内容', 'status' => '状态[0禁用 1启用 -1删除]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public static function setData(array $params) { try { if (!empty($params['mall_id'])&&!empty($params['store_id'])&&!empty($params['goods_id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'store_id' => $params['store_id'], 'goods_id' => $params['goods_id'], 'status' => [StatusEnum::ENABLED]]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } } 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() . $e->getLine() . $e->getFile(); return false; } } //获取门店商品独立设置模式 public static function getGoodsModel(int $goods_id, string $addons_name, string $type){ if($goods_id && $type){ $goods_model = self::find()->where(['goods_id' => $goods_id])->select('content')->one(); $setting = []; if (!empty($goods_model['content'])) { $content = json_decode($goods_model['content'], true); foreach ($content as $key => $item) { $setting[$key] = json_decode($item, true); } } return $setting[$addons_name][$type]; } } }