'ID', 'mall_id' => 'Mall ID', 'activity_id' => '活动id', 'order_id' => '订单id', 'user_id' => '用户id', 'status' => '数据状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData(int $mall_id, array $data) { if (!empty($data['id'])) { $model = self::findOne(['mall_id' => $mall_id, 'id' => $data['id']]); if (empty($model)) { self::$static_error = '数据异常'; return false; } } else { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; unset($data['id']); } foreach ($data as $key => $val) { $model->$key = $val; } if (!$model->save()) { self::$static_error = '保存数据失败:' . $model->getErrorMessage(); return false; } } }