'ID', 'mall_id' => 'Mall ID', 'create_source_type' => '创建来源类型:0:平台;1:门店', 'store_type' => '店铺类型:1:o2o门店', 'secondary_card_id' => '次卡id', 'store_id' => '门店id', 'status' => '状态[-1:删除;0:禁用;1启用;]', 'created_at' => '创建时间', 'updated_at' => 'Updated At', ]; } public static function setData($mall_id, $secondary_card_id, $store_ids, $create_source_type, $store_type) { try { foreach ($store_ids as $store_id) { $model = self::findOne(['mall_id' => $mall_id, 'secondary_card_id' => $secondary_card_id, 'store_id' => $store_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } $params = [ 'mall_id' => $mall_id, 'secondary_card_id' => $secondary_card_id, 'create_source_type' => $create_source_type, 'store_type' => $store_type, 'store_id' => $store_id, ]; if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); } return true; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }