'ID', 'mall_id' => '商城id', 'goods_id' => '商品id', 'enable' => '是否开启社区社区团购[0关闭,1开启]', 'supported_logistics' => '支持物流方式[1:快递配送; 2:站点自提; 3送货上门]', 'status' => '状态[0禁用 1启用 -1删除]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public static function setData(array $params) { try { $model = self::findOne(['mall_id' => $params['mall_id'], 'goods_id' => $params['goods_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() . $e->getLine() . $e->getFile(); return false; } } /** * 商品是否开启社区团购 * @param $mall_id * @param $goods_id * @return bool */ public static function getEnable($mall_id, $goods_id) { return self::find() ->where(['status' => StatusEnum::ENABLED, 'goods_id' => $goods_id, 'enable' => StatusEnum::ENABLED, 'mall_id' => $mall_id]) ->exists(); } }